Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
77ee3fe1
提交
77ee3fe1
authored
3月 13, 2013
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix a few rare race conditions that could lead to a lockup
上级
93bb5ca5
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
34 行增加
和
1 行删除
+34
-1
switch_core_sqldb.c
src/switch_core_sqldb.c
+22
-1
switch_scheduler.c
src/switch_scheduler.c
+12
-0
没有找到文件。
src/switch_core_sqldb.c
浏览文件 @
77ee3fe1
...
...
@@ -1250,6 +1250,7 @@ struct switch_sql_queue_manager {
int
thread_running
;
switch_thread_cond_t
*
cond
;
switch_mutex_t
*
cond_mutex
;
switch_mutex_t
*
cond2_mutex
;
switch_mutex_t
*
mutex
;
char
*
pre_trans_execute
;
char
*
post_trans_execute
;
...
...
@@ -1262,10 +1263,26 @@ struct switch_sql_queue_manager {
static
int
qm_wake
(
switch_sql_queue_manager_t
*
qm
)
{
if
(
switch_mutex_trylock
(
qm
->
cond_mutex
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_status_t
status
;
int
tries
=
0
;
top:
status
=
switch_mutex_trylock
(
qm
->
cond_mutex
);
if
(
status
==
SWITCH_STATUS_SUCCESS
)
{
switch_thread_cond_signal
(
qm
->
cond
);
switch_mutex_unlock
(
qm
->
cond_mutex
);
return
1
;
}
else
{
if
(
switch_mutex_trylock
(
qm
->
cond2_mutex
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_mutex_unlock
(
qm
->
cond2_mutex
);
}
else
{
if
(
++
tries
<
10
)
{
switch_cond_next
();
goto
top
;
}
}
}
return
0
;
...
...
@@ -1407,6 +1424,7 @@ SWITCH_DECLARE(switch_status_t) switch_sql_queue_manager_stop(switch_sql_queue_m
if
(
qm
->
thread
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"%s Stopping SQL thread.
\n
"
,
qm
->
name
);
qm_wake
(
qm
);
switch_thread_join
(
&
status
,
qm
->
thread
);
qm
->
thread
=
NULL
;
status
=
SWITCH_STATUS_SUCCESS
;
...
...
@@ -1596,6 +1614,7 @@ SWITCH_DECLARE(switch_status_t) switch_sql_queue_manager_init_name(const char *n
qm
->
max_trans
=
max_trans
;
switch_mutex_init
(
&
qm
->
cond_mutex
,
SWITCH_MUTEX_NESTED
,
qm
->
pool
);
switch_mutex_init
(
&
qm
->
cond2_mutex
,
SWITCH_MUTEX_NESTED
,
qm
->
pool
);
switch_mutex_init
(
&
qm
->
mutex
,
SWITCH_MUTEX_NESTED
,
qm
->
pool
);
switch_thread_cond_create
(
&
qm
->
cond
,
qm
->
pool
);
...
...
@@ -1850,7 +1869,9 @@ static void *SWITCH_THREAD_FUNC switch_user_sql_thread(switch_thread_t *thread,
check
:
if
((
lc
=
qm_ttl
(
qm
))
==
0
)
{
switch_mutex_lock
(
qm
->
cond2_mutex
);
switch_thread_cond_wait
(
qm
->
cond
,
qm
->
cond_mutex
);
switch_mutex_unlock
(
qm
->
cond2_mutex
);
}
i
=
40
;
...
...
src/switch_scheduler.c
浏览文件 @
77ee3fe1
...
...
@@ -37,6 +37,7 @@ struct switch_scheduler_task_container {
int64_t
executed
;
int
in_thread
;
int
destroyed
;
int
running
;
switch_scheduler_func_t
func
;
switch_memory_pool_t
*
pool
;
uint32_t
flags
;
...
...
@@ -124,7 +125,11 @@ static int task_thread_loop(int done)
tp
->
in_thread
=
1
;
switch_thread_create
(
&
thread
,
thd_attr
,
task_own_thread
,
tp
,
tp
->
pool
);
}
else
{
tp
->
running
=
1
;
switch_mutex_unlock
(
globals
.
task_mutex
);
switch_scheduler_execute
(
tp
);
switch_mutex_lock
(
globals
.
task_mutex
);
tp
->
running
=
0
;
}
}
}
...
...
@@ -238,6 +243,13 @@ SWITCH_DECLARE(uint32_t) switch_scheduler_del_task_id(uint32_t task_id)
tp
->
task
.
task_id
,
tp
->
task
.
group
);
break
;
}
if
(
tp
->
running
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"Attempt made to delete running task #%u (group %s)
\n
"
,
tp
->
task
.
task_id
,
tp
->
task
.
group
);
break
;
}
tp
->
destroyed
++
;
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_DEL_SCHEDULE
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Task-ID"
,
"%u"
,
tp
->
task
.
task_id
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论