Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
ffa09cd1
提交
ffa09cd1
authored
6月 20, 2014
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
various verto cleanups and fix a race in double event delivery thread creation
上级
faeb0036
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
26 行增加
和
14 行删除
+26
-14
mod_verto.c
src/mod/endpoints/mod_verto/mod_verto.c
+14
-12
switch_event.c
src/switch_event.c
+12
-2
没有找到文件。
src/mod/endpoints/mod_verto/mod_verto.c
浏览文件 @
ffa09cd1
...
...
@@ -174,6 +174,7 @@ struct jsock_sub_node_head_s;
typedef
struct
jsock_sub_node_s
{
jsock_t
*
jsock
;
uint32_t
serno
;
struct
jsock_sub_node_head_s
*
head
;
struct
jsock_sub_node_s
*
next
;
}
jsock_sub_node_t
;
...
...
@@ -529,7 +530,9 @@ static switch_ssize_t ws_write_json(jsock_t *jsock, cJSON **json, switch_bool_t
if
((
json_text
=
cJSON_PrintUnformatted
(
*
json
)))
{
if
(
jsock
->
profile
->
debug
||
globals
.
debug
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ALERT
,
"WRITE %s [%s]
\n
"
,
jsock
->
name
,
json_text
);
char
*
log_text
=
cJSON_Print
(
*
json
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ALERT
,
"WRITE %s [%s]
\n
"
,
jsock
->
name
,
log_text
);
free
(
log_text
);
}
switch_mutex_lock
(
jsock
->
write_mutex
);
ws_write_frame
(
&
jsock
->
ws
,
WSOC_TEXT
,
json_text
,
strlen
(
json_text
));
...
...
@@ -558,6 +561,7 @@ static void write_event(const char *event_channel, jsock_t *use_jsock, cJSON *ev
if
(
!
use_jsock
||
use_jsock
==
np
->
jsock
)
{
params
=
cJSON_Duplicate
(
event
,
1
);
cJSON_AddItemToObject
(
params
,
"eventSerno"
,
cJSON_CreateNumber
(
np
->
serno
++
));
msg
=
jrpc_new_req
(
"verto.event"
,
NULL
,
&
params
);
ws_write_json
(
np
->
jsock
,
&
msg
,
SWITCH_TRUE
);
}
...
...
@@ -1134,13 +1138,17 @@ static switch_status_t process_input(jsock_t *jsock, uint8_t *data, switch_ssize
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
if
(
ascii
)
{
if
(
jsock
->
profile
->
debug
||
globals
.
debug
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ALERT
,
"READ %s [%s]
\n
"
,
jsock
->
name
,
ascii
);
}
json
=
cJSON_Parse
(
ascii
);
}
if
(
json
)
{
if
(
jsock
->
profile
->
debug
||
globals
.
debug
)
{
char
*
log_text
=
cJSON_Print
(
json
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ALERT
,
"READ %s [%s]
\n
"
,
jsock
->
name
,
log_text
);
free
(
log_text
);
}
if
(
json
->
type
==
cJSON_Array
)
{
/* batch mode */
int
i
,
len
=
cJSON_GetArraySize
(
json
);
...
...
@@ -3860,20 +3868,14 @@ static switch_call_cause_t verto_outgoing_channel(switch_core_session_t *session
void
verto_broadcast
(
const
char
*
event_channel
,
cJSON
*
json
,
const
char
*
key
,
switch_event_channel_id_t
id
)
{
{
if
(
globals
.
debug
>
10
)
{
char
*
json_text
;
if
((
json_text
=
cJSON_Print
(
json
)))
{
if
(
globals
.
debug
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ALERT
,
"EVENT BROADCAST %s %s
\n
"
,
event_channel
,
json_text
);
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ALERT
,
"EVENT BROADCAST %s %s
\n
"
,
event_channel
,
json_text
);
free
(
json_text
);
}
}
jsock_send_event
(
json
);
}
...
...
src/switch_event.c
浏览文件 @
ffa09cd1
...
...
@@ -97,6 +97,7 @@ static switch_hash_t *CUSTOM_HASH = NULL;
static
int
THREAD_COUNT
=
0
;
static
int
DISPATCH_THREAD_COUNT
=
0
;
static
int
EVENT_CHANNEL_DISPATCH_THREAD_COUNT
=
0
;
static
int
EVENT_CHANNEL_DISPATCH_THREAD_STARTING
=
0
;
static
int
SYSTEM_RUNNING
=
0
;
static
uint64_t
EVENT_SEQUENCE_NR
=
0
;
#ifdef SWITCH_EVENT_RECYCLE
...
...
@@ -2876,6 +2877,7 @@ static void *SWITCH_THREAD_FUNC switch_event_channel_deliver_thread(switch_threa
switch_mutex_lock
(
EVENT_QUEUE_MUTEX
);
THREAD_COUNT
++
;
EVENT_CHANNEL_DISPATCH_THREAD_COUNT
++
;
EVENT_CHANNEL_DISPATCH_THREAD_STARTING
=
0
;
switch_mutex_unlock
(
EVENT_QUEUE_MUTEX
);
while
(
SYSTEM_RUNNING
)
{
...
...
@@ -2911,6 +2913,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_channel_broadcast(const char *event
{
event_channel_data_t
*
ecd
=
NULL
;
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
int
launch
=
0
;
if
(
!
SYSTEM_RUNNING
)
{
cJSON_Delete
(
*
json
);
...
...
@@ -2927,7 +2930,14 @@ SWITCH_DECLARE(switch_status_t) switch_event_channel_broadcast(const char *event
*
json
=
NULL
;
if
(
!
EVENT_CHANNEL_DISPATCH_THREAD_COUNT
&&
SYSTEM_RUNNING
)
{
switch_mutex_lock
(
EVENT_QUEUE_MUTEX
);
if
(
!
EVENT_CHANNEL_DISPATCH_THREAD_COUNT
&&
!
EVENT_CHANNEL_DISPATCH_THREAD_STARTING
&&
SYSTEM_RUNNING
)
{
EVENT_CHANNEL_DISPATCH_THREAD_STARTING
=
1
;
launch
=
1
;
}
switch_mutex_unlock
(
EVENT_QUEUE_MUTEX
);
if
(
launch
)
{
switch_thread_data_t
*
td
;
if
(
!
EVENT_CHANNEL_DISPATCH_QUEUE
)
{
...
...
@@ -3189,7 +3199,7 @@ SWITCH_DECLARE(switch_status_t) switch_live_array_bootstrap(switch_live_array_t
cJSON_AddItemToObject
(
msg
,
"eventChannel"
,
cJSON_CreateString
(
la
->
event_channel
));
cJSON_AddItemToObject
(
data
,
"action"
,
cJSON_CreateString
(
"bootObj"
));
cJSON_AddItemToObject
(
data
,
"name"
,
cJSON_CreateString
(
la
->
name
));
cJSON_AddItemToObject
(
data
,
"wireSerno"
,
cJSON_CreateNumber
(
la
->
serno
++
));
cJSON_AddItemToObject
(
data
,
"wireSerno"
,
cJSON_CreateNumber
(
-
1
));
if
(
sessid
)
{
cJSON_AddItemToObject
(
msg
,
"sessid"
,
cJSON_CreateString
(
sessid
));
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论