Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
61cdf0da
提交
61cdf0da
authored
3月 04, 2011
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add limits to simo open sql handles
上级
8fe24a29
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
47 行增加
和
3 行删除
+47
-3
switch.conf.xml
conf/autoload_configs/switch.conf.xml
+5
-0
switch_core_pvt.h
src/include/private/switch_core_pvt.h
+2
-0
switch_core.c
src/switch_core.c
+20
-1
switch_core_sqldb.c
src/switch_core_sqldb.c
+20
-2
没有找到文件。
conf/autoload_configs/switch.conf.xml
浏览文件 @
61cdf0da
...
@@ -24,6 +24,11 @@
...
@@ -24,6 +24,11 @@
<!--Colorize the Console -->
<!--Colorize the Console -->
<param
name=
"colorize-console"
value=
"true"
/>
<param
name=
"colorize-console"
value=
"true"
/>
<!-- maximum number of simo db handles open -->
<param
name=
"max-db-handles"
value=
"50"
/>
<!-- maximum number of seconds to wait for a new db handle before failing -->
<param
name=
"db-handle-timeout"
value=
"10"
/>
<!-- minimum idle CPU before refusing calls -->
<!-- minimum idle CPU before refusing calls -->
<!--<param name="min-idle-cpu" value="25"/>-->
<!--<param name="min-idle-cpu" value="25"/>-->
...
...
src/include/private/switch_core_pvt.h
浏览文件 @
61cdf0da
...
@@ -249,6 +249,8 @@ struct switch_runtime {
...
@@ -249,6 +249,8 @@ struct switch_runtime {
switch_dbtype_t
odbc_dbtype
;
switch_dbtype_t
odbc_dbtype
;
char
hostname
[
256
];
char
hostname
[
256
];
int
multiple_registrations
;
int
multiple_registrations
;
uint32_t
max_db_handles
;
uint32_t
db_handle_timeout
;
};
};
extern
struct
switch_runtime
runtime
;
extern
struct
switch_runtime
runtime
;
...
...
src/switch_core.c
浏览文件 @
61cdf0da
...
@@ -1283,7 +1283,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
...
@@ -1283,7 +1283,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
memset
(
&
runtime
,
0
,
sizeof
(
runtime
));
memset
(
&
runtime
,
0
,
sizeof
(
runtime
));
gethostname
(
runtime
.
hostname
,
sizeof
(
runtime
.
hostname
));
gethostname
(
runtime
.
hostname
,
sizeof
(
runtime
.
hostname
));
runtime
.
max_db_handles
=
50
;
runtime
.
db_handle_timeout
=
5000000
;;
runtime
.
runlevel
++
;
runtime
.
runlevel
++
;
runtime
.
sql_buffer_len
=
1024
*
32
;
runtime
.
sql_buffer_len
=
1024
*
32
;
runtime
.
max_sql_buffer_len
=
1024
*
1024
;
runtime
.
max_sql_buffer_len
=
1024
*
1024
;
...
@@ -1550,6 +1552,23 @@ static void switch_load_core_config(const char *file)
...
@@ -1550,6 +1552,23 @@ static void switch_load_core_config(const char *file)
if
(
tmp
>
-
1
&&
tmp
<
11
)
{
if
(
tmp
>
-
1
&&
tmp
<
11
)
{
switch_core_session_ctl
(
SCSC_DEBUG_LEVEL
,
&
tmp
);
switch_core_session_ctl
(
SCSC_DEBUG_LEVEL
,
&
tmp
);
}
}
}
else
if
(
!
strcasecmp
(
var
,
"max-db-handles"
))
{
long
tmp
=
atol
(
val
);
if
(
tmp
>
4
&&
tmp
<
5001
)
{
runtime
.
max_db_handles
=
(
uint32_t
)
tmp
;
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"max-db-handles must be between 5 and 5000
\n
"
);
}
}
else
if
(
!
strcasecmp
(
var
,
"db-handle-timeout"
))
{
long
tmp
=
atol
(
val
);
if
(
tmp
>
0
&&
tmp
<
5001
)
{
runtime
.
db_handle_timeout
=
(
uint32_t
)
tmp
*
1000000
;
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"db-handle-timeout must be between 1 and 5000
\n
"
);
}
}
else
if
(
!
strcasecmp
(
var
,
"multiple-registrations"
))
{
}
else
if
(
!
strcasecmp
(
var
,
"multiple-registrations"
))
{
runtime
.
multiple_registrations
=
switch_true
(
val
);
runtime
.
multiple_registrations
=
switch_true
(
val
);
}
else
if
(
!
strcasecmp
(
var
,
"sql-buffer-len"
))
{
}
else
if
(
!
strcasecmp
(
var
,
"sql-buffer-len"
))
{
...
...
src/switch_core_sqldb.c
浏览文件 @
61cdf0da
...
@@ -66,8 +66,8 @@ static struct {
...
@@ -66,8 +66,8 @@ static struct {
switch_cache_db_handle_t
*
handle_pool
;
switch_cache_db_handle_t
*
handle_pool
;
switch_thread_cond_t
*
cond
;
switch_thread_cond_t
*
cond
;
switch_mutex_t
*
cond_mutex
;
switch_mutex_t
*
cond_mutex
;
in
t
total_handles
;
uint32_
t
total_handles
;
in
t
total_used_handles
;
uint32_
t
total_used_handles
;
}
sql_manager
;
}
sql_manager
;
...
@@ -273,11 +273,29 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_h
...
@@ -273,11 +273,29 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_h
char
db_callsite_str
[
CACHE_DB_LEN
]
=
""
;
char
db_callsite_str
[
CACHE_DB_LEN
]
=
""
;
switch_cache_db_handle_t
*
new_dbh
=
NULL
;
switch_cache_db_handle_t
*
new_dbh
=
NULL
;
switch_ssize_t
hlen
=
-
1
;
switch_ssize_t
hlen
=
-
1
;
int
waiting
=
0
;
uint32_t
yield_len
=
100000
,
total_yield
=
0
;
const
char
*
db_name
=
NULL
;
const
char
*
db_name
=
NULL
;
const
char
*
db_user
=
NULL
;
const
char
*
db_user
=
NULL
;
const
char
*
db_pass
=
NULL
;
const
char
*
db_pass
=
NULL
;
while
(
runtime
.
max_db_handles
&&
sql_manager
.
total_handles
>=
runtime
.
max_db_handles
&&
sql_manager
.
total_used_handles
>=
sql_manager
.
total_handles
)
{
if
(
!
waiting
++
)
{
switch_log_printf
(
SWITCH_CHANNEL_ID_LOG
,
file
,
func
,
line
,
NULL
,
SWITCH_LOG_WARNING
,
"Max handles %u exceeded, blocking....
\n
"
,
runtime
.
max_db_handles
);
}
switch_yield
(
yield_len
);
total_yield
+=
yield_len
;
if
(
runtime
.
db_handle_timeout
&&
total_yield
>
runtime
.
db_handle_timeout
)
{
switch_log_printf
(
SWITCH_CHANNEL_ID_LOG
,
file
,
func
,
line
,
NULL
,
SWITCH_LOG_ERROR
,
"Error connecting
\n
"
);
*
dbh
=
NULL
;
return
SWITCH_STATUS_FALSE
;
}
}
switch
(
type
)
{
switch
(
type
)
{
case
SCDB_TYPE_ODBC
:
case
SCDB_TYPE_ODBC
:
{
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论