Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
2ffe8312
提交
2ffe8312
authored
10月 16, 2013
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor and add more plumbing
上级
af4c9176
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
93 行增加
和
6 行删除
+93
-6
switch_event.h
src/include/switch_event.h
+3
-0
switch_types.h
src/include/switch_types.h
+1
-0
switch_event.c
src/switch_event.c
+89
-6
没有找到文件。
src/include/switch_event.h
浏览文件 @
2ffe8312
...
...
@@ -453,6 +453,9 @@ SWITCH_DECLARE(void) switch_live_array_set_command_handler(switch_live_array_t *
SWITCH_DECLARE
(
void
)
switch_live_array_parse_json
(
cJSON
*
json
,
switch_event_channel_id_t
channel_id
);
SWITCH_DECLARE
(
switch_bool_t
)
switch_live_array_add_alias
(
switch_live_array_t
*
la
,
const
char
*
event_channel
,
const
char
*
name
);
SWITCH_DECLARE
(
switch_bool_t
)
switch_live_array_clear_alias
(
switch_live_array_t
*
la
,
const
char
*
event_channel
,
const
char
*
name
);
SWITCH_DECLARE
(
switch_bool_t
)
switch_event_channel_permission_verify
(
const
char
*
cookie
,
const
char
*
event_channel
);
SWITCH_DECLARE
(
void
)
switch_event_channel_permission_modify
(
const
char
*
cookie
,
const
char
*
event_channel
,
switch_bool_t
set
);
SWITCH_DECLARE
(
void
)
switch_event_channel_permission_clear
(
const
char
*
cookie
);
///\}
...
...
src/include/switch_types.h
浏览文件 @
2ffe8312
...
...
@@ -1320,6 +1320,7 @@ typedef enum {
CF_CONFIRM_BLIND_TRANSFER
,
CF_NO_PRESENCE
,
CF_CONFERENCE
,
CF_CONFERENCE_ADV
,
CF_RECOVERING
,
CF_RECOVERING_BRIDGE
,
CF_TRACKED
,
...
...
src/switch_event.c
浏览文件 @
2ffe8312
...
...
@@ -72,6 +72,7 @@ static struct {
switch_event_channel_id_t
ID
;
switch_thread_rwlock_t
*
rwlock
;
switch_hash_t
*
hash
;
switch_hash_t
*
perm_hash
;
switch_hash_t
*
lahash
;
switch_mutex_t
*
lamutex
;
}
event_channel_manager
;
...
...
@@ -586,6 +587,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_shutdown(void)
}
switch_core_hash_destroy
(
&
event_channel_manager
.
lahash
);
switch_core_hash_destroy
(
&
event_channel_manager
.
hash
);
switch_core_hash_destroy
(
&
event_channel_manager
.
perm_hash
);
switch_core_hash_destroy
(
&
CUSTOM_HASH
);
switch_core_memory_reclaim_events
();
...
...
@@ -675,6 +678,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_init(switch_memory_pool_t *pool)
switch_thread_rwlock_create
(
&
event_channel_manager
.
rwlock
,
RUNTIME_POOL
);
switch_core_hash_init
(
&
event_channel_manager
.
hash
,
RUNTIME_POOL
);
switch_core_hash_init
(
&
event_channel_manager
.
perm_hash
,
RUNTIME_POOL
);
event_channel_manager
.
ID
=
1
;
switch_mutex_lock
(
EVENT_QUEUE_MUTEX
);
...
...
@@ -2676,21 +2680,27 @@ static uint32_t switch_event_channel_unsub_head(switch_event_channel_func_t func
static
void
unsub_all_switch_event_channel
(
void
)
{
switch_hash_index_t
*
hi
;
const
void
*
var
;
void
*
val
;
switch_event_channel_sub_node_head_t
*
head
;
switch_thread_rwlock_wrlock
(
event_channel_manager
.
rwlock
);
top:
head
=
NULL
;
for
(
hi
=
switch_hash_first
(
NULL
,
event_channel_manager
.
hash
);
hi
;
hi
=
switch_hash_next
(
hi
))
{
while
((
hi
=
switch_hash_first
(
NULL
,
event_channel_manager
.
perm_hash
)))
{
switch_event_t
*
vals
=
NULL
;
switch_hash_this
(
hi
,
&
var
,
NULL
,
&
val
);
vals
=
(
switch_event_t
*
)
val
;
switch_core_hash_delete
(
event_channel_manager
.
perm_hash
,
var
);
switch_event_destroy
(
&
vals
);
}
while
((
hi
=
switch_hash_first
(
NULL
,
event_channel_manager
.
hash
)))
{
switch_hash_this
(
hi
,
NULL
,
NULL
,
&
val
);
head
=
(
switch_event_channel_sub_node_head_t
*
)
val
;
switch_event_channel_unsub_head
(
NULL
,
head
);
switch_core_hash_delete
(
event_channel_manager
.
hash
,
head
->
event_channel
);
free
(
head
->
event_channel
);
free
(
head
);
goto
top
;
}
switch_thread_rwlock_unlock
(
event_channel_manager
.
rwlock
);
...
...
@@ -2963,9 +2973,61 @@ SWITCH_DECLARE(switch_status_t) switch_event_channel_bind(const char *event_chan
return
status
;
}
SWITCH_DECLARE
(
switch_bool_t
)
switch_event_channel_permission_verify
(
const
char
*
cookie
,
const
char
*
event_channel
)
{
switch_event_t
*
vals
;
switch_bool_t
r
=
SWITCH_FALSE
;
switch_thread_rwlock_rdlock
(
event_channel_manager
.
rwlock
);
if
((
vals
=
switch_core_hash_find
(
event_channel_manager
.
perm_hash
,
cookie
)))
{
r
=
switch_true
(
switch_event_get_header
(
vals
,
event_channel
));
}
switch_thread_rwlock_unlock
(
event_channel_manager
.
rwlock
);
return
r
;
}
SWITCH_DECLARE
(
void
)
switch_event_channel_permission_modify
(
const
char
*
cookie
,
const
char
*
event_channel
,
switch_bool_t
set
)
{
switch_event_t
*
vals
;
switch_thread_rwlock_wrlock
(
event_channel_manager
.
rwlock
);
if
(
!
(
vals
=
switch_core_hash_find
(
event_channel_manager
.
perm_hash
,
cookie
)))
{
if
(
!
set
)
goto
end
;
switch_event_create_plain
(
&
vals
,
SWITCH_EVENT_CHANNEL_DATA
);
switch_core_hash_insert
(
event_channel_manager
.
perm_hash
,
cookie
,
vals
);
}
if
(
set
)
{
switch_event_add_header_string
(
vals
,
SWITCH_STACK_BOTTOM
,
event_channel
,
"true"
);
}
else
{
switch_event_del_header
(
vals
,
event_channel
);
}
end
:
switch_thread_rwlock_unlock
(
event_channel_manager
.
rwlock
);
}
SWITCH_DECLARE
(
void
)
switch_event_channel_permission_clear
(
const
char
*
cookie
)
{
switch_event_t
*
vals
;
switch_thread_rwlock_wrlock
(
event_channel_manager
.
rwlock
);
if
((
vals
=
switch_core_hash_find
(
event_channel_manager
.
perm_hash
,
cookie
)))
{
switch_core_hash_delete
(
event_channel_manager
.
perm_hash
,
cookie
);
switch_event_destroy
(
&
vals
);
}
switch_thread_rwlock_unlock
(
event_channel_manager
.
rwlock
);
}
typedef
struct
alias_node_s
{
char
*
event_channel
;
char
*
name
;
char
*
key
;
struct
alias_node_s
*
next
;
}
alias_node_t
;
...
...
@@ -3152,6 +3214,7 @@ SWITCH_DECLARE(switch_status_t) switch_live_array_destroy(switch_live_array_t **
{
switch_live_array_t
*
la
=
*
live_arrayP
;
switch_memory_pool_t
*
pool
;
alias_node_t
*
np
;
*
live_arrayP
=
NULL
;
...
...
@@ -3163,6 +3226,9 @@ SWITCH_DECLARE(switch_status_t) switch_live_array_destroy(switch_live_array_t **
switch_mutex_lock
(
event_channel_manager
.
lamutex
);
switch_core_hash_delete
(
event_channel_manager
.
lahash
,
la
->
key
);
for
(
np
=
la
->
aliases
;
np
;
np
=
np
->
next
)
{
switch_core_hash_delete
(
event_channel_manager
.
lahash
,
np
->
key
);
}
switch_mutex_unlock
(
event_channel_manager
.
lamutex
);
switch_core_destroy_memory_pool
(
&
pool
);
...
...
@@ -3177,13 +3243,14 @@ SWITCH_DECLARE(switch_bool_t) switch_live_array_isnew(switch_live_array_t *la)
SWITCH_DECLARE
(
switch_bool_t
)
switch_live_array_clear_alias
(
switch_live_array_t
*
la
,
const
char
*
event_channel
,
const
char
*
name
)
{
alias_node_t
*
np
,
*
last
=
NULL
;
alias_node_t
*
np
,
*
last
=
NULL
,
*
del
=
NULL
;
switch_bool_t
r
=
SWITCH_FALSE
;
switch_mutex_lock
(
la
->
mutex
);
for
(
np
=
la
->
aliases
;
np
;
np
=
np
->
next
)
{
if
(
!
strcmp
(
np
->
event_channel
,
event_channel
)
&&
!
strcmp
(
np
->
name
,
name
))
{
r
=
SWITCH_TRUE
;
del
=
np
;
if
(
last
)
{
last
->
next
=
np
->
next
;
...
...
@@ -3196,6 +3263,13 @@ SWITCH_DECLARE(switch_bool_t) switch_live_array_clear_alias(switch_live_array_t
}
switch_mutex_unlock
(
la
->
mutex
);
if
(
r
)
{
switch_mutex_lock
(
event_channel_manager
.
lamutex
);
switch_core_hash_delete
(
event_channel_manager
.
lahash
,
del
->
key
);
switch_mutex_unlock
(
event_channel_manager
.
lamutex
);
}
return
r
;
}
...
...
@@ -3216,6 +3290,8 @@ SWITCH_DECLARE(switch_bool_t) switch_live_array_add_alias(switch_live_array_t *l
node
=
switch_core_alloc
(
la
->
pool
,
sizeof
(
*
node
));
node
->
event_channel
=
switch_core_strdup
(
la
->
pool
,
event_channel
);
node
->
name
=
switch_core_strdup
(
la
->
pool
,
name
);
node
->
key
=
switch_core_sprintf
(
la
->
pool
,
"%s.%s"
,
event_channel
,
name
);
if
(
np
)
{
np
->
next
=
node
;
}
else
{
...
...
@@ -3225,6 +3301,13 @@ SWITCH_DECLARE(switch_bool_t) switch_live_array_add_alias(switch_live_array_t *l
switch_mutex_unlock
(
la
->
mutex
);
if
(
!
exist
)
{
switch_mutex_lock
(
event_channel_manager
.
lamutex
);
switch_core_hash_insert
(
event_channel_manager
.
lahash
,
node
->
key
,
la
);
switch_mutex_unlock
(
event_channel_manager
.
lamutex
);
}
return
!
exist
;
}
...
...
@@ -3474,7 +3557,7 @@ SWITCH_DECLARE(void) switch_live_array_parse_json(cJSON *json, switch_event_chan
if
((
context
=
cJSON_GetObjectCstr
(
jla
,
"context"
))
&&
(
name
=
cJSON_GetObjectCstr
(
jla
,
"name"
)))
{
const
char
*
command
=
cJSON_GetObjectCstr
(
jla
,
"command"
);
const
char
*
sessid
=
cJSON_GetObjectCstr
(
json
,
"sessid"
);
if
(
command
)
{
switch_live_array_create
(
context
,
name
,
channel_id
,
&
la
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论