Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
0b9e5c82
提交
0b9e5c82
authored
3月 24, 2014
作者:
Chris Rienzo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-6402 mod_rayo/mod_ssml: add mutex to hashes now that iteration is no longer thread-safe
上级
5ac97488
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
41 行增加
和
13 行删除
+41
-13
mod_rayo.c
src/mod/event_handlers/mod_rayo/mod_rayo.c
+11
-4
rayo_cpa_detector.c
src/mod/event_handlers/mod_rayo/rayo_cpa_detector.c
+12
-5
mod_ssml.c
src/mod/formats/mod_ssml/mod_ssml.c
+18
-4
没有找到文件。
src/mod/event_handlers/mod_rayo/mod_rayo.c
浏览文件 @
0b9e5c82
...
@@ -207,6 +207,8 @@ static struct {
...
@@ -207,6 +207,8 @@ static struct {
char
*
mixer_conf_profile
;
char
*
mixer_conf_profile
;
/** to URI prefixes mapped to gateways */
/** to URI prefixes mapped to gateways */
switch_hash_t
*
dial_gateways
;
switch_hash_t
*
dial_gateways
;
/** synchronizes access to dial gateways */
switch_mutex_t
*
dial_gateways_mutex
;
/** console command aliases */
/** console command aliases */
switch_hash_t
*
cmd_aliases
;
switch_hash_t
*
cmd_aliases
;
/** global console */
/** global console */
...
@@ -527,7 +529,7 @@ static void broadcast_event(struct rayo_actor *from, iks *rayo_event, int online
...
@@ -527,7 +529,7 @@ static void broadcast_event(struct rayo_actor *from, iks *rayo_event, int online
{
{
switch_hash_index_t
*
hi
=
NULL
;
switch_hash_index_t
*
hi
=
NULL
;
switch_mutex_lock
(
globals
.
clients_mutex
);
switch_mutex_lock
(
globals
.
clients_mutex
);
for
(
hi
=
switch_core_hash_first
(
globals
.
clients_roster
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
for
(
hi
=
switch_core_hash_first
(
globals
.
clients_roster
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
struct
rayo_client
*
rclient
;
struct
rayo_client
*
rclient
;
const
void
*
key
;
const
void
*
key
;
void
*
val
;
void
*
val
;
...
@@ -569,6 +571,7 @@ static struct dial_gateway *dial_gateway_find(const char *uri)
...
@@ -569,6 +571,7 @@ static struct dial_gateway *dial_gateway_find(const char *uri)
struct
dial_gateway
*
gateway
=
(
struct
dial_gateway
*
)
switch_core_hash_find
(
globals
.
dial_gateways
,
"default"
);
struct
dial_gateway
*
gateway
=
(
struct
dial_gateway
*
)
switch_core_hash_find
(
globals
.
dial_gateways
,
"default"
);
/* find longest prefix match */
/* find longest prefix match */
switch_mutex_lock
(
globals
.
dial_gateways_mutex
);
for
(
hi
=
switch_core_hash_first
(
globals
.
dial_gateways
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
for
(
hi
=
switch_core_hash_first
(
globals
.
dial_gateways
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
struct
dial_gateway
*
candidate
=
NULL
;
struct
dial_gateway
*
candidate
=
NULL
;
const
void
*
prefix
;
const
void
*
prefix
;
...
@@ -584,6 +587,7 @@ static struct dial_gateway *dial_gateway_find(const char *uri)
...
@@ -584,6 +587,7 @@ static struct dial_gateway *dial_gateway_find(const char *uri)
gateway
=
candidate
;
gateway
=
candidate
;
}
}
}
}
switch_mutex_unlock
(
globals
.
dial_gateways_mutex
);
return
gateway
;
return
gateway
;
}
}
...
@@ -1107,7 +1111,7 @@ static void rayo_call_cleanup(struct rayo_actor *actor)
...
@@ -1107,7 +1111,7 @@ static void rayo_call_cleanup(struct rayo_actor *actor)
}
}
/* send <end> to all offered clients */
/* send <end> to all offered clients */
for
(
hi
=
switch_core_hash_first
(
call
->
pcps
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
for
(
hi
=
switch_core_hash_first
(
call
->
pcps
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
const
void
*
key
;
const
void
*
key
;
void
*
val
;
void
*
val
;
const
char
*
client_jid
=
NULL
;
const
char
*
client_jid
=
NULL
;
...
@@ -2893,6 +2897,7 @@ static void rayo_client_command_recv(struct rayo_client *rclient, iks *iq)
...
@@ -2893,6 +2897,7 @@ static void rayo_client_command_recv(struct rayo_client *rclient, iks *iq)
static
void
broadcast_mixer_event
(
struct
rayo_mixer
*
mixer
,
iks
*
rayo_event
)
static
void
broadcast_mixer_event
(
struct
rayo_mixer
*
mixer
,
iks
*
rayo_event
)
{
{
switch_hash_index_t
*
hi
=
NULL
;
switch_hash_index_t
*
hi
=
NULL
;
switch_mutex_lock
(
RAYO_ACTOR
(
mixer
)
->
mutex
);
for
(
hi
=
switch_core_hash_first
(
mixer
->
subscribers
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
for
(
hi
=
switch_core_hash_first
(
mixer
->
subscribers
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
const
void
*
key
;
const
void
*
key
;
void
*
val
;
void
*
val
;
...
@@ -2903,6 +2908,7 @@ static void broadcast_mixer_event(struct rayo_mixer *mixer, iks *rayo_event)
...
@@ -2903,6 +2908,7 @@ static void broadcast_mixer_event(struct rayo_mixer *mixer, iks *rayo_event)
iks_insert_attrib
(
rayo_event
,
"to"
,
subscriber
->
jid
);
iks_insert_attrib
(
rayo_event
,
"to"
,
subscriber
->
jid
);
RAYO_SEND_MESSAGE_DUP
(
mixer
,
subscriber
->
jid
,
rayo_event
);
RAYO_SEND_MESSAGE_DUP
(
mixer
,
subscriber
->
jid
,
rayo_event
);
}
}
switch_mutex_unlock
(
RAYO_ACTOR
(
mixer
)
->
mutex
);
}
}
/**
/**
...
@@ -3609,7 +3615,7 @@ SWITCH_STANDARD_APP(rayo_app)
...
@@ -3609,7 +3615,7 @@ SWITCH_STANDARD_APP(rayo_app)
/* Offer call to all ONLINE clients */
/* Offer call to all ONLINE clients */
/* TODO load balance offers so first session doesn't always get offer first? */
/* TODO load balance offers so first session doesn't always get offer first? */
switch_mutex_lock
(
globals
.
clients_mutex
);
switch_mutex_lock
(
globals
.
clients_mutex
);
for
(
hi
=
switch_core_hash_first
(
globals
.
clients_roster
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
for
(
hi
=
switch_core_hash_first
(
globals
.
clients_roster
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
struct
rayo_client
*
rclient
;
struct
rayo_client
*
rclient
;
const
void
*
key
;
const
void
*
key
;
void
*
val
;
void
*
val
;
...
@@ -4364,7 +4370,7 @@ static switch_status_t list_actors(const char *line, const char *cursor, switch_
...
@@ -4364,7 +4370,7 @@ static switch_status_t list_actors(const char *line, const char *cursor, switch_
struct
rayo_actor
*
actor
;
struct
rayo_actor
*
actor
;
switch_mutex_lock
(
globals
.
actors_mutex
);
switch_mutex_lock
(
globals
.
actors_mutex
);
for
(
hi
=
switch_core_hash_first
(
globals
.
actors
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
for
(
hi
=
switch_core_hash_first
(
globals
.
actors
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
switch_core_hash_this
(
hi
,
&
vvar
,
NULL
,
&
val
);
switch_core_hash_this
(
hi
,
&
vvar
,
NULL
,
&
val
);
actor
=
(
struct
rayo_actor
*
)
val
;
actor
=
(
struct
rayo_actor
*
)
val
;
...
@@ -4549,6 +4555,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rayo_load)
...
@@ -4549,6 +4555,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rayo_load)
switch_core_hash_init
(
&
globals
.
actors_by_id
);
switch_core_hash_init
(
&
globals
.
actors_by_id
);
switch_mutex_init
(
&
globals
.
actors_mutex
,
SWITCH_MUTEX_NESTED
,
pool
);
switch_mutex_init
(
&
globals
.
actors_mutex
,
SWITCH_MUTEX_NESTED
,
pool
);
switch_core_hash_init
(
&
globals
.
dial_gateways
);
switch_core_hash_init
(
&
globals
.
dial_gateways
);
switch_mutex_init
(
&
globals
.
dial_gateways_mutex
,
SWITCH_MUTEX_NESTED
,
pool
);
switch_core_hash_init
(
&
globals
.
cmd_aliases
);
switch_core_hash_init
(
&
globals
.
cmd_aliases
);
switch_thread_rwlock_create
(
&
globals
.
shutdown_rwlock
,
pool
);
switch_thread_rwlock_create
(
&
globals
.
shutdown_rwlock
,
pool
);
switch_queue_create
(
&
globals
.
msg_queue
,
25000
,
pool
);
switch_queue_create
(
&
globals
.
msg_queue
,
25000
,
pool
);
...
...
src/mod/event_handlers/mod_rayo/rayo_cpa_detector.c
浏览文件 @
0b9e5c82
...
@@ -31,6 +31,8 @@
...
@@ -31,6 +31,8 @@
static
struct
{
static
struct
{
/** detectors supported by this module mapped by signal-type */
/** detectors supported by this module mapped by signal-type */
switch_hash_t
*
detectors
;
switch_hash_t
*
detectors
;
/** synchronizes access to detectors */
switch_mutex_t
*
detectors_mutex
;
}
globals
;
}
globals
;
struct
rayo_cpa_detector
;
struct
rayo_cpa_detector
;
...
@@ -390,10 +392,12 @@ static switch_status_t rayo_cpa_detector_signal_types(const char *line, const ch
...
@@ -390,10 +392,12 @@ static switch_status_t rayo_cpa_detector_signal_types(const char *line, const ch
const
void
*
vvar
;
const
void
*
vvar
;
switch_console_callback_match_t
*
my_matches
=
NULL
;
switch_console_callback_match_t
*
my_matches
=
NULL
;
for
(
hi
=
switch_core_hash_first
(
globals
.
detectors
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
switch_mutex_lock
(
globals
.
detectors_mutex
);
for
(
hi
=
switch_core_hash_first
(
globals
.
detectors
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
switch_core_hash_this
(
hi
,
&
vvar
,
NULL
,
&
val
);
switch_core_hash_this
(
hi
,
&
vvar
,
NULL
,
&
val
);
switch_console_push_match
(
&
my_matches
,
(
const
char
*
)
vvar
);
switch_console_push_match
(
&
my_matches
,
(
const
char
*
)
vvar
);
}
}
switch_mutex_unlock
(
globals
.
detectors_mutex
);
if
(
my_matches
)
{
if
(
my_matches
)
{
*
matches
=
my_matches
;
*
matches
=
my_matches
;
...
@@ -414,16 +418,19 @@ switch_status_t rayo_cpa_detector_load(switch_loadable_module_interface_t **modu
...
@@ -414,16 +418,19 @@ switch_status_t rayo_cpa_detector_load(switch_loadable_module_interface_t **modu
{
{
switch_api_interface_t
*
api_interface
;
switch_api_interface_t
*
api_interface
;
switch_core_hash_init
(
&
globals
.
detectors
);
switch_mutex_init
(
&
globals
.
detectors_mutex
,
SWITCH_MUTEX_NESTED
,
pool
);
if
(
do_config
(
pool
,
config_file
)
!=
SWITCH_STATUS_SUCCESS
)
{
return
SWITCH_STATUS_TERM
;
}
SWITCH_ADD_API
(
api_interface
,
"rayo_cpa"
,
"Query rayo status"
,
rayo_cpa_detector_api
,
RAYO_CPA_DETECTOR_SYNTAX
);
SWITCH_ADD_API
(
api_interface
,
"rayo_cpa"
,
"Query rayo status"
,
rayo_cpa_detector_api
,
RAYO_CPA_DETECTOR_SYNTAX
);
switch_console_set_complete
(
"add rayo_cpa ::console::list_uuid ::rayo_cpa::list_signal_types start"
);
switch_console_set_complete
(
"add rayo_cpa ::console::list_uuid ::rayo_cpa::list_signal_types start"
);
switch_console_set_complete
(
"add rayo_cpa ::console::list_uuid ::rayo_cpa::list_signal_types stop"
);
switch_console_set_complete
(
"add rayo_cpa ::console::list_uuid ::rayo_cpa::list_signal_types stop"
);
switch_console_add_complete_func
(
"::rayo_cpa::list_signal_types"
,
rayo_cpa_detector_signal_types
);
switch_console_add_complete_func
(
"::rayo_cpa::list_signal_types"
,
rayo_cpa_detector_signal_types
);
switch_core_hash_init
(
&
globals
.
detectors
);
if
(
do_config
(
pool
,
config_file
)
!=
SWITCH_STATUS_SUCCESS
)
{
return
SWITCH_STATUS_TERM
;
}
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
...
...
src/mod/formats/mod_ssml/mod_ssml.c
浏览文件 @
0b9e5c82
/*
/*
* mod_ssml for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* mod_ssml for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013, Grasshopper
* Copyright (C) 2013
-2014
, Grasshopper
*
*
* Version: MPL 1.1
* Version: MPL 1.1
*
*
...
@@ -64,8 +64,12 @@ static struct {
...
@@ -64,8 +64,12 @@ static struct {
switch_hash_t
*
voice_cache
;
switch_hash_t
*
voice_cache
;
/** Mapping of voice names */
/** Mapping of voice names */
switch_hash_t
*
say_voice_map
;
switch_hash_t
*
say_voice_map
;
/** Synchronizes access to say_voice_map */
switch_mutex_t
*
say_voice_map_mutex
;
/** Mapping of voice names */
/** Mapping of voice names */
switch_hash_t
*
tts_voice_map
;
switch_hash_t
*
tts_voice_map
;
/** Synchronizes access to tts_voice_map */
switch_mutex_t
*
tts_voice_map_mutex
;
/** Mapping of interpret-as value to macro */
/** Mapping of interpret-as value to macro */
switch_hash_t
*
interpret_as_map
;
switch_hash_t
*
interpret_as_map
;
/** Mapping of ISO language code to say-module */
/** Mapping of ISO language code to say-module */
...
@@ -339,7 +343,7 @@ static struct voice *find_voice(struct ssml_node *cur_node, switch_hash_t *map,
...
@@ -339,7 +343,7 @@ static struct voice *find_voice(struct ssml_node *cur_node, switch_hash_t *map,
}
}
/* find best language, name, gender match */
/* find best language, name, gender match */
for
(
hi
=
switch_core_hash_first
(
map
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
for
(
hi
=
switch_core_hash_first
(
map
);
hi
;
hi
=
switch_core_hash_next
(
hi
))
{
const
void
*
key
;
const
void
*
key
;
void
*
val
;
void
*
val
;
struct
voice
*
candidate
;
struct
voice
*
candidate
;
...
@@ -371,7 +375,11 @@ done:
...
@@ -371,7 +375,11 @@ done:
*/
*/
static
struct
voice
*
find_tts_voice
(
struct
ssml_node
*
cur_node
)
static
struct
voice
*
find_tts_voice
(
struct
ssml_node
*
cur_node
)
{
{
return
find_voice
(
cur_node
,
globals
.
tts_voice_map
,
"tts"
,
0
);
struct
voice
*
v
;
switch_mutex_lock
(
globals
.
tts_voice_map_mutex
);
v
=
find_voice
(
cur_node
,
globals
.
tts_voice_map
,
"tts"
,
0
);
switch_mutex_unlock
(
globals
.
tts_voice_map_mutex
);
return
v
;
}
}
/**
/**
...
@@ -381,7 +389,11 @@ static struct voice *find_tts_voice(struct ssml_node *cur_node)
...
@@ -381,7 +389,11 @@ static struct voice *find_tts_voice(struct ssml_node *cur_node)
*/
*/
static
struct
voice
*
find_say_voice
(
struct
ssml_node
*
cur_node
)
static
struct
voice
*
find_say_voice
(
struct
ssml_node
*
cur_node
)
{
{
return
find_voice
(
cur_node
,
globals
.
say_voice_map
,
"say"
,
1
);
struct
voice
*
v
;
switch_mutex_lock
(
globals
.
say_voice_map_mutex
);
v
=
find_voice
(
cur_node
,
globals
.
say_voice_map
,
"say"
,
1
);
switch_mutex_unlock
(
globals
.
say_voice_map_mutex
);
return
v
;
}
}
/**
/**
...
@@ -1112,7 +1124,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_ssml_load)
...
@@ -1112,7 +1124,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_ssml_load)
globals
.
pool
=
pool
;
globals
.
pool
=
pool
;
switch_core_hash_init
(
&
globals
.
voice_cache
);
switch_core_hash_init
(
&
globals
.
voice_cache
);
switch_core_hash_init
(
&
globals
.
tts_voice_map
);
switch_core_hash_init
(
&
globals
.
tts_voice_map
);
switch_mutex_init
(
&
globals
.
tts_voice_map_mutex
,
SWITCH_MUTEX_NESTED
,
pool
);
switch_core_hash_init
(
&
globals
.
say_voice_map
);
switch_core_hash_init
(
&
globals
.
say_voice_map
);
switch_mutex_init
(
&
globals
.
say_voice_map_mutex
,
SWITCH_MUTEX_NESTED
,
pool
);
switch_core_hash_init
(
&
globals
.
interpret_as_map
);
switch_core_hash_init
(
&
globals
.
interpret_as_map
);
switch_core_hash_init
(
&
globals
.
language_map
);
switch_core_hash_init
(
&
globals
.
language_map
);
switch_core_hash_init
(
&
globals
.
tag_defs
);
switch_core_hash_init
(
&
globals
.
tag_defs
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论