Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
929f52b1
提交
929f52b1
authored
6月 28, 2013
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix race condition on device state destroy
上级
5e2f808d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
45 行增加
和
13 行删除
+45
-13
mod_skel.c
src/mod/applications/mod_skel/mod_skel.c
+25
-0
switch_channel.c
src/switch_channel.c
+20
-13
没有找到文件。
src/mod/applications/mod_skel/mod_skel.c
浏览文件 @
929f52b1
...
@@ -157,6 +157,28 @@ SWITCH_STANDARD_API(skel_function)
...
@@ -157,6 +157,28 @@ SWITCH_STANDARD_API(skel_function)
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
static
void
mycb
(
switch_core_session_t
*
session
,
switch_channel_callstate_t
callstate
,
switch_device_record_t
*
drec
)
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
switch_log_printf
(
SWITCH_CHANNEL_CHANNEL_LOG
(
channel
),
SWITCH_LOG_CRIT
,
"%s device: %s
\n
State: %s Dev State: %s/%s Total:%u Offhook:%u Active:%u Held:%u Hungup:%u Dur: %u %s
\n
"
,
switch_channel_get_name
(
channel
),
drec
->
device_id
,
switch_channel_callstate2str
(
callstate
),
switch_channel_device_state2str
(
drec
->
last_state
),
switch_channel_device_state2str
(
drec
->
state
),
drec
->
stats
.
total
,
drec
->
stats
.
offhook
,
drec
->
stats
.
active
,
drec
->
stats
.
held
,
drec
->
stats
.
hup
,
drec
->
active_stop
?
(
uint32_t
)(
drec
->
active_stop
-
drec
->
active_start
)
/
1000
:
0
,
switch_channel_test_flag
(
channel
,
CF_FINAL_DEVICE_LEG
)
?
"FINAL LEG"
:
""
);
}
/* Macro expands to: switch_status_t mod_skel_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */
/* Macro expands to: switch_status_t mod_skel_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */
SWITCH_MODULE_LOAD_FUNCTION
(
mod_skel_load
)
SWITCH_MODULE_LOAD_FUNCTION
(
mod_skel_load
)
{
{
...
@@ -170,6 +192,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skel_load)
...
@@ -170,6 +192,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skel_load)
SWITCH_ADD_API
(
api_interface
,
"skel"
,
"Skel API"
,
skel_function
,
"syntax"
);
SWITCH_ADD_API
(
api_interface
,
"skel"
,
"Skel API"
,
skel_function
,
"syntax"
);
switch_channel_bind_device_state_handler
(
mycb
,
NULL
);
/* indicate that the module should continue to be loaded */
/* indicate that the module should continue to be loaded */
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
...
@@ -180,6 +204,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skel_load)
...
@@ -180,6 +204,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skel_load)
SWITCH_MODULE_SHUTDOWN_FUNCTION
(
mod_skel_shutdown
)
SWITCH_MODULE_SHUTDOWN_FUNCTION
(
mod_skel_shutdown
)
{
{
/* Cleanup dynamically allocated config settings */
/* Cleanup dynamically allocated config settings */
switch_channel_unbind_device_state_handler
(
mycb
);
switch_xml_config_cleanup
(
instructions
);
switch_xml_config_cleanup
(
instructions
);
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
...
...
src/switch_channel.c
浏览文件 @
929f52b1
...
@@ -4681,31 +4681,36 @@ SWITCH_DECLARE(void) switch_channel_clear_device_record(switch_channel_t *channe
...
@@ -4681,31 +4681,36 @@ SWITCH_DECLARE(void) switch_channel_clear_device_record(switch_channel_t *channe
static
void
process_device_hup
(
switch_channel_t
*
channel
)
static
void
process_device_hup
(
switch_channel_t
*
channel
)
{
{
switch_hold_record_t
*
hr
,
*
newhr
,
*
last
=
NULL
;
switch_hold_record_t
*
hr
,
*
newhr
,
*
last
=
NULL
;
switch_device_record_t
*
drec
=
NULL
;
switch_device_node_t
*
node
;
if
(
!
channel
->
device_node
)
{
if
(
!
channel
->
device_node
)
{
return
;
return
;
}
}
switch_mutex_lock
(
globals
.
device_mutex
);
switch_mutex_lock
(
globals
.
device_mutex
);
channel
->
device_node
->
hup_profile
=
switch_caller_profile_dup
(
channel
->
device_node
->
parent
->
pool
,
channel
->
caller_profile
)
;
node
=
channel
->
device_node
;
fetch_device_stats
(
channel
->
device_node
->
parent
)
;
drec
=
channel
->
device_node
->
parent
;
switch_ivr_generate_xml_cdr
(
channel
->
session
,
&
channel
->
device_node
->
xml_cdr
);
node
->
hup_profile
=
switch_caller_profile_dup
(
drec
->
pool
,
channel
->
caller_profile
);
if
(
switch_event_create
(
&
channel
->
device_node
->
event
,
SWITCH_EVENT_CALL_DETAIL
)
==
SWITCH_STATUS_SUCCESS
)
{
fetch_device_stats
(
drec
);
switch_channel_event_set_extended_data
(
channel
,
channel
->
device_node
->
event
);
switch_ivr_generate_xml_cdr
(
channel
->
session
,
&
node
->
xml_cdr
);
if
(
switch_event_create
(
&
node
->
event
,
SWITCH_EVENT_CALL_DETAIL
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_channel_event_set_extended_data
(
channel
,
node
->
event
);
}
}
for
(
hr
=
channel
->
hold_record
;
hr
;
hr
=
hr
->
next
)
{
for
(
hr
=
channel
->
hold_record
;
hr
;
hr
=
hr
->
next
)
{
newhr
=
switch_core_alloc
(
channel
->
device_node
->
parent
->
pool
,
sizeof
(
*
newhr
));
newhr
=
switch_core_alloc
(
drec
->
pool
,
sizeof
(
*
newhr
));
newhr
->
on
=
hr
->
on
;
newhr
->
on
=
hr
->
on
;
newhr
->
off
=
hr
->
off
;
newhr
->
off
=
hr
->
off
;
if
(
hr
->
uuid
)
{
if
(
hr
->
uuid
)
{
newhr
->
uuid
=
switch_core_strdup
(
channel
->
device_node
->
parent
->
pool
,
hr
->
uuid
);
newhr
->
uuid
=
switch_core_strdup
(
drec
->
pool
,
hr
->
uuid
);
}
}
if
(
!
channel
->
device_
node
->
hold_record
)
{
if
(
!
node
->
hold_record
)
{
channel
->
device_
node
->
hold_record
=
newhr
;
node
->
hold_record
=
newhr
;
}
else
{
}
else
{
last
->
next
=
newhr
;
last
->
next
=
newhr
;
}
}
...
@@ -4713,15 +4718,17 @@ static void process_device_hup(switch_channel_t *channel)
...
@@ -4713,15 +4718,17 @@ static void process_device_hup(switch_channel_t *channel)
last
=
newhr
;
last
=
newhr
;
}
}
if
(
!
channel
->
device_node
->
parent
->
stats
.
offhook
)
{
/* this is final call */
if
(
!
drec
->
stats
.
offhook
)
{
/* this is final call */
switch_core_hash_delete
(
globals
.
device_hash
,
channel
->
device_node
->
parent
->
device_id
);
switch_core_hash_delete
(
globals
.
device_hash
,
drec
->
device_id
);
switch_log_printf
(
SWITCH_CHANNEL_CHANNEL_LOG
(
channel
),
SWITCH_LOG_DEBUG
,
"Processing last call from device [%s]
\n
"
,
switch_log_printf
(
SWITCH_CHANNEL_CHANNEL_LOG
(
channel
),
SWITCH_LOG_DEBUG
,
"Processing last call from device [%s]
\n
"
,
channel
->
device_node
->
parent
->
device_id
);
drec
->
device_id
);
switch_channel_set_flag
(
channel
,
CF_FINAL_DEVICE_LEG
);
switch_channel_set_flag
(
channel
,
CF_FINAL_DEVICE_LEG
);
}
else
{
channel
->
device_node
=
NULL
;
}
}
channel
->
device_node
->
parent
->
refs
--
;
drec
->
refs
--
;
switch_mutex_unlock
(
globals
.
device_mutex
);
switch_mutex_unlock
(
globals
.
device_mutex
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论