Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
a84daf95
提交
a84daf95
authored
5月 29, 2019
作者:
lazedo
提交者:
Andrey Volk
7月 25, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-11860 [core] allow configurable separator in event_channel and
process all parts of key
上级
abdf7960
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
61 行增加
和
11 行删除
+61
-11
switch_core_pvt.h
src/include/private/switch_core_pvt.h
+1
-0
switch_core.h
src/include/switch_core.h
+1
-0
switch_types.h
src/include/switch_types.h
+2
-1
switch_core.c
src/switch_core.c
+18
-0
switch_event.c
src/switch_event.c
+39
-10
没有找到文件。
src/include/private/switch_core_pvt.h
浏览文件 @
a84daf95
...
...
@@ -313,6 +313,7 @@ struct switch_runtime {
char
*
core_db_inner_post_trans_execute
;
int
events_use_dispatch
;
uint32_t
port_alloc_flags
;
char
*
event_channel_key_separator
;
};
extern
struct
switch_runtime
runtime
;
...
...
src/include/switch_core.h
浏览文件 @
a84daf95
...
...
@@ -2817,6 +2817,7 @@ SWITCH_DECLARE(void) switch_core_autobind_cpu(void);
SWITCH_DECLARE
(
switch_status_t
)
switch_core_session_start_text_thread
(
switch_core_session_t
*
session
);
SWITCH_DECLARE
(
const
char
*
)
switch_core_get_event_channel_key_separator
(
void
);
SWITCH_END_EXTERN_C
#endif
...
...
src/include/switch_types.h
浏览文件 @
a84daf95
...
...
@@ -386,7 +386,8 @@ typedef enum {
SCF_SESSION_THREAD_POOL
=
(
1
<<
23
),
SCF_DIALPLAN_TIMESTAMPS
=
(
1
<<
24
),
SCF_CPF_SOFT_PREFIX
=
(
1
<<
25
),
SCF_CPF_SOFT_LOOKUP
=
(
1
<<
26
)
SCF_CPF_SOFT_LOOKUP
=
(
1
<<
26
),
SCF_EVENT_CHANNEL_ENABLE_HIERARCHY_DELIVERY
=
(
1
<<
27
)
}
switch_core_flag_enum_t
;
typedef
uint32_t
switch_core_flag_t
;
...
...
src/switch_core.c
浏览文件 @
a84daf95
...
...
@@ -2360,10 +2360,23 @@ static void switch_load_core_config(const char *file)
}
else
{
switch_clear_flag
((
&
runtime
),
SCF_CPF_SOFT_LOOKUP
);
}
}
else
if
(
!
strcasecmp
(
var
,
"event-channel-key-separator"
)
&&
!
zstr
(
val
))
{
runtime
.
event_channel_key_separator
=
switch_core_strdup
(
runtime
.
memory_pool
,
val
);
}
else
if
(
!
strcasecmp
(
var
,
"event-channel-enable-hierarchy-deliver"
)
&&
!
zstr
(
val
))
{
int
v
=
switch_true
(
val
);
if
(
v
)
{
switch_set_flag
((
&
runtime
),
SCF_EVENT_CHANNEL_ENABLE_HIERARCHY_DELIVERY
);
}
else
{
switch_clear_flag
((
&
runtime
),
SCF_EVENT_CHANNEL_ENABLE_HIERARCHY_DELIVERY
);
}
}
}
}
if
(
runtime
.
event_channel_key_separator
==
NULL
)
{
runtime
.
event_channel_key_separator
=
switch_core_strdup
(
runtime
.
memory_pool
,
"."
);
}
if
((
settings
=
switch_xml_child
(
cfg
,
"variables"
)))
{
for
(
param
=
switch_xml_child
(
settings
,
"variable"
);
param
;
param
=
param
->
next
)
{
const
char
*
var
=
switch_xml_attr_soft
(
param
,
"name"
);
...
...
@@ -3375,6 +3388,11 @@ SWITCH_DECLARE(uint16_t) switch_core_get_rtp_port_range_end_port()
return
end_port
;
}
SWITCH_DECLARE
(
const
char
*
)
switch_core_get_event_channel_key_separator
(
void
)
{
return
runtime
.
event_channel_key_separator
;
}
/* For Emacs:
* Local Variables:
* mode:c
...
...
src/switch_event.c
浏览文件 @
a84daf95
...
...
@@ -2915,24 +2915,53 @@ static void destroy_ecd(event_channel_data_t **ecdP)
free
(
ecd
);
}
#ifndef SWITCH_CHANNEL_DISPATCH_MAX_KEY_PARTS
#define SWITCH_CHANNEL_DISPATCH_MAX_KEY_PARTS 10
#endif
static
void
ecd_deliver
(
event_channel_data_t
**
ecdP
)
{
event_channel_data_t
*
ecd
=
*
ecdP
;
char
*
p
;
char
*
key
;
uint32_t
t
=
0
;
*
ecdP
=
NULL
;
_switch_event_channel_broadcast
(
ecd
->
event_channel
,
ecd
->
event_channel
,
ecd
->
json
,
ecd
->
key
,
ecd
->
id
);
t
=
_switch_event_channel_broadcast
(
ecd
->
event_channel
,
ecd
->
event_channel
,
ecd
->
json
,
ecd
->
key
,
ecd
->
id
);
key
=
strdup
(
ecd
->
event_channel
);
if
(
switch_core_test_flag
(
SCF_EVENT_CHANNEL_ENABLE_HIERARCHY_DELIVERY
))
{
const
char
*
sep
=
switch_core_get_event_channel_key_separator
();
char
*
x_argv
[
SWITCH_CHANNEL_DISPATCH_MAX_KEY_PARTS
]
=
{
0
};
int
x_argc
=
switch_separate_string_string
(
key
,
(
char
*
)
sep
,
x_argv
,
SWITCH_CHANNEL_DISPATCH_MAX_KEY_PARTS
);
char
buf
[
512
];
int
i
;
for
(
i
=
x_argc
-
1
;
i
>
0
;
i
--
)
{
int
z
;
memset
(
buf
,
0
,
512
);
sprintf
(
buf
,
"%s"
,
x_argv
[
0
]);
for
(
z
=
1
;
z
<
i
;
z
++
)
{
strcat
(
buf
,
sep
);
strcat
(
buf
,
x_argv
[
z
]);
}
t
+=
_switch_event_channel_broadcast
(
buf
,
ecd
->
event_channel
,
ecd
->
json
,
ecd
->
key
,
ecd
->
id
);
}
}
else
{
char
*
p
=
NULL
;
if
((
p
=
strchr
(
key
,
'.'
)))
{
*
p
=
'\0'
;
t
+=
_switch_event_channel_broadcast
(
key
,
ecd
->
event_channel
,
ecd
->
json
,
ecd
->
key
,
ecd
->
id
);
}
}
switch_safe_free
(
key
);
if
((
p
=
strchr
(
ecd
->
event_channel
,
'.'
)))
{
char
*
main_channel
=
strdup
(
ecd
->
event_channel
);
switch_assert
(
main_channel
);
p
=
strchr
(
main_channel
,
'.'
);
*
p
=
'\0'
;
_switch_event_channel_broadcast
(
main_channel
,
ecd
->
event_channel
,
ecd
->
json
,
ecd
->
key
,
ecd
->
id
);
free
(
main_channel
);
t
+=
_switch_event_channel_broadcast
(
SWITCH_EVENT_CHANNEL_GLOBAL
,
ecd
->
event_channel
,
ecd
->
json
,
ecd
->
key
,
ecd
->
id
);
if
(
t
==
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"no subscribers for %s , %s
\n
"
,
ecd
->
event_channel
,
ecd
->
key
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG1
,
"delivered to %u subscribers for %s
\n
"
,
t
,
ecd
->
event_channel
);
}
_switch_event_channel_broadcast
(
SWITCH_EVENT_CHANNEL_GLOBAL
,
ecd
->
event_channel
,
ecd
->
json
,
ecd
->
key
,
ecd
->
id
);
destroy_ecd
(
&
ecd
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论