Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
121e57a1
提交
121e57a1
authored
8月 22, 2010
作者:
Andrew Thompson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Switch from mutex to a rwlock to increase throughput
上级
5ef61c96
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
27 行增加
和
26 行删除
+27
-26
handle_msg.c
src/mod/event_handlers/mod_erlang_event/handle_msg.c
+2
-2
mod_erlang_event.c
src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c
+24
-23
mod_erlang_event.h
src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h
+1
-1
没有找到文件。
src/mod/event_handlers/mod_erlang_event/handle_msg.c
浏览文件 @
121e57a1
...
...
@@ -646,7 +646,7 @@ static switch_status_t handle_msg_bind(listener_t *listener, erlang_msg * msg, e
binding
->
process
.
pid
=
msg
->
from
;
binding
->
listener
=
listener
;
switch_
mutex_lock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_wrlock
(
globals
.
listener_rwlock
);
for
(
ptr
=
bindings
.
head
;
ptr
&&
ptr
->
next
;
ptr
=
ptr
->
next
);
...
...
@@ -657,7 +657,7 @@ static switch_status_t handle_msg_bind(listener_t *listener, erlang_msg * msg, e
}
switch_xml_set_binding_sections
(
bindings
.
search_binding
,
switch_xml_get_binding_sections
(
bindings
.
search_binding
)
|
section
);
switch_
mutex_unlock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_unlock
(
globals
.
listener_rwlock
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"sections %d
\n
"
,
switch_xml_get_binding_sections
(
bindings
.
search_binding
));
...
...
src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c
浏览文件 @
121e57a1
...
...
@@ -57,7 +57,7 @@ static switch_status_t socket_logger(const switch_log_node_t *node, switch_log_l
{
listener_t
*
l
;
switch_
mutex_lock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_rdlock
(
globals
.
listener_rwlock
);
for
(
l
=
listen_list
.
listeners
;
l
;
l
=
l
->
next
)
{
if
(
switch_test_flag
(
l
,
LFLAG_LOG
)
&&
l
->
level
>=
node
->
level
)
{
...
...
@@ -80,7 +80,7 @@ static switch_status_t socket_logger(const switch_log_node_t *node, switch_log_l
}
}
}
switch_
mutex_unlock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_unlock
(
globals
.
listener_rwlock
);
return
SWITCH_STATUS_SUCCESS
;
}
...
...
@@ -107,7 +107,7 @@ static void remove_binding(listener_t *listener, erlang_pid * pid)
{
struct
erlang_binding
*
ptr
,
*
lst
=
NULL
;
switch_
mutex_lock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_wrlock
(
globals
.
listener_rwlock
);
switch_xml_set_binding_sections
(
bindings
.
search_binding
,
SWITCH_XML_SECTION_MAX
);
...
...
@@ -134,7 +134,7 @@ static void remove_binding(listener_t *listener, erlang_pid * pid)
}
}
switch_
mutex_unlock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_unlock
(
globals
.
listener_rwlock
);
}
...
...
@@ -194,7 +194,7 @@ static void event_handler(switch_event_t *event)
lp
=
listen_list
.
listeners
;
switch_
mutex_lock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_rdlock
(
globals
.
listener_rwlock
);
while
(
lp
)
{
uint8_t
send
=
0
;
...
...
@@ -250,7 +250,7 @@ static void event_handler(switch_event_t *event)
}
}
switch_
mutex_unlock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_unlock
(
globals
.
listener_rwlock
);
}
...
...
@@ -276,10 +276,10 @@ static void close_socket(int *sock)
static
void
add_listener
(
listener_t
*
listener
)
{
/* add me to the listeners so I get events */
switch_
mutex_lock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_wrlock
(
globals
.
listener_rwlock
);
listener
->
next
=
listen_list
.
listeners
;
listen_list
.
listeners
=
listener
;
switch_
mutex_unlock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_unlock
(
globals
.
listener_rwlock
);
}
...
...
@@ -287,7 +287,7 @@ static void remove_listener(listener_t *listener)
{
listener_t
*
l
,
*
last
=
NULL
;
switch_
mutex_lock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_wrlock
(
globals
.
listener_rwlock
);
for
(
l
=
listen_list
.
listeners
;
l
;
l
=
l
->
next
)
{
if
(
l
==
listener
)
{
if
(
last
)
{
...
...
@@ -298,7 +298,7 @@ static void remove_listener(listener_t *listener)
}
last
=
l
;
}
switch_
mutex_unlock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_unlock
(
globals
.
listener_rwlock
);
}
/* Search for a listener already talking to the specified node */
...
...
@@ -306,13 +306,13 @@ static listener_t *find_listener(char *nodename)
{
listener_t
*
l
=
NULL
;
switch_
mutex_lock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_rdlock
(
globals
.
listener_rwlock
);
for
(
l
=
listen_list
.
listeners
;
l
;
l
=
l
->
next
)
{
if
(
!
strncmp
(
nodename
,
l
->
peer_nodename
,
MAXNODELEN
))
{
break
;
}
}
switch_
mutex_unlock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_unlock
(
globals
.
listener_rwlock
);
return
l
;
}
...
...
@@ -968,9 +968,10 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
void
*
value
;
switch_hash_index_t
*
iter
;
switch_mutex_lock
(
globals
.
listener_mutex
);
/* TODO - should we have a different mutex for this? */
switch_thread_rwlock_wrlock
(
globals
.
listener_rwlock
);
prefs
.
threads
++
;
switch_
mutex_unlock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_unlock
(
globals
.
listener_rwlock
);
switch_assert
(
listener
!=
NULL
);
...
...
@@ -1018,9 +1019,9 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
switch_core_destroy_memory_pool
(
&
pool
);
}
switch_
mutex_lock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_wrlock
(
globals
.
listener_rwlock
);
prefs
.
threads
--
;
switch_
mutex_unlock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_unlock
(
globals
.
listener_rwlock
);
return
NULL
;
}
...
...
@@ -1537,7 +1538,7 @@ SWITCH_STANDARD_API(erlang_cmd)
if
(
!
strcasecmp
(
argv
[
0
],
"listeners"
))
{
listener_t
*
l
;
switch_
mutex_lock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_rdlock
(
globals
.
listener_rwlock
);
if
(
listen_list
.
listeners
)
{
for
(
l
=
listen_list
.
listeners
;
l
;
l
=
l
->
next
)
{
...
...
@@ -1547,12 +1548,12 @@ SWITCH_STANDARD_API(erlang_cmd)
stream
->
write_function
(
stream
,
"No active listeners
\n
"
);
}
switch_
mutex_unlock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_unlock
(
globals
.
listener_rwlock
);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"sessions"
)
&&
argc
==
2
)
{
listener_t
*
l
;
int
found
=
0
;
switch_
mutex_lock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_rdlock
(
globals
.
listener_rwlock
);
for
(
l
=
listen_list
.
listeners
;
l
;
l
=
l
->
next
)
{
if
(
!
strcasecmp
(
l
->
peer_nodename
,
argv
[
1
]))
{
session_elem_t
*
sp
;
...
...
@@ -1578,7 +1579,7 @@ SWITCH_STANDARD_API(erlang_cmd)
break
;
}
}
switch_
mutex_unlock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_unlock
(
globals
.
listener_rwlock
);
if
(
!
found
)
stream
->
write_function
(
stream
,
"Could not find a listener for %s
\n
"
,
argv
[
1
]);
...
...
@@ -1604,7 +1605,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_erlang_event_load)
memset
(
&
prefs
,
0
,
sizeof
(
prefs
));
switch_
mutex_init
(
&
globals
.
listener_mutex
,
SWITCH_MUTEX_NESTED
,
pool
);
switch_
thread_rwlock_create
(
&
globals
.
listener_rwlock
,
pool
);
switch_mutex_init
(
&
globals
.
fetch_reply_mutex
,
SWITCH_MUTEX_DEFAULT
,
pool
);
switch_core_hash_init
(
&
globals
.
fetch_reply_hash
,
pool
);
...
...
@@ -1853,7 +1854,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_erlang_event_shutdown)
switch_event_unbind
(
&
globals
.
node
);
switch_xml_unbind_search_function_ptr
(
erlang_fetch
);
switch_
mutex_lock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_wrlock
(
globals
.
listener_rwlock
);
for
(
l
=
listen_list
.
listeners
;
l
;
l
=
l
->
next
)
{
close_socket
(
&
l
->
sockfd
);
...
...
@@ -1863,7 +1864,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_erlang_event_shutdown)
WSACleanup
();
#endif
switch_
mutex_unlock
(
globals
.
listener_mutex
);
switch_
thread_rwlock_unlock
(
globals
.
listener_rwlock
);
switch_sleep
(
1500000
);
/* sleep for 1.5 seconds */
...
...
src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h
浏览文件 @
121e57a1
...
...
@@ -162,7 +162,7 @@ struct api_command_struct {
};
struct
globals_struct
{
switch_
mutex_t
*
listener_mutex
;
switch_
thread_rwlock_t
*
listener_rwlock
;
switch_event_node_t
*
node
;
switch_mutex_t
*
ref_mutex
;
switch_mutex_t
*
fetch_reply_mutex
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论