Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
2ac5dd54
提交
2ac5dd54
authored
7月 13, 2010
作者:
Anthony Minessale
提交者:
Jeff Lenk
7月 15, 2010
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tweak
上级
41852592
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
51 行增加
和
23 行删除
+51
-23
mod_fifo.c
src/mod/applications/mod_fifo/mod_fifo.c
+51
-23
没有找到文件。
src/mod/applications/mod_fifo/mod_fifo.c
浏览文件 @
2ac5dd54
...
...
@@ -679,6 +679,26 @@ struct callback_helper {
};
static
switch_status_t
hanguphook
(
switch_core_session_t
*
session
)
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
switch_channel_state_t
state
=
switch_channel_get_state
(
channel
);
const
char
*
uuid
=
NULL
;
char
sql
[
256
]
=
""
;
if
(
state
==
CS_HANGUP
||
state
==
CS_ROUTING
)
{
if
((
uuid
=
switch_channel_get_variable
(
channel
,
"fifo_outbound_uuid"
)))
{
switch_snprintf
(
sql
,
sizeof
(
sql
),
"update fifo_outbound set use_count=use_count-1, "
"outbound_call_count=outbound_call_count+1, next_avail=%ld + lag where uuid='%s' and use_count > 0"
,
(
long
)
switch_epoch_time_now
(
NULL
),
uuid
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
}
switch_core_event_hook_remove_state_change
(
session
,
hanguphook
);
}
return
SWITCH_STATUS_SUCCESS
;
}
static
void
*
SWITCH_THREAD_FUNC
ringall_thread_run
(
switch_thread_t
*
thread
,
void
*
obj
)
{
...
...
@@ -824,13 +844,23 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
switch_event_fire
(
&
event
);
}
for
(
i
=
0
;
i
<
cbh
->
rowcount
;
i
++
)
{
struct
call_helper
*
h
=
cbh
->
rows
[
i
];
char
*
sql
=
switch_mprintf
(
"update fifo_outbound set use_count=use_count+1,outbound_fail_count=0 where uuid='%s'"
,
h
->
uuid
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
}
status
=
switch_ivr_originate
(
NULL
,
&
session
,
&
cause
,
originate_string
,
timeout
,
NULL
,
NULL
,
NULL
,
NULL
,
ovars
,
SOF_NONE
,
NULL
);
if
(
status
!=
SWITCH_STATUS_SUCCESS
)
{
for
(
i
=
0
;
i
<
cbh
->
rowcount
;
i
++
)
{
struct
call_helper
*
h
=
cbh
->
rows
[
i
];
char
*
sql
=
switch_mprintf
(
"update fifo_outbound set outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%q'"
,
(
long
)
switch_epoch_time_now
(
NULL
),
h
->
uuid
);
char
*
sql
=
switch_mprintf
(
"update fifo_outbound set use_count=use_count-1, "
"outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%q' and use_count > 0"
,
(
long
)
switch_epoch_time_now
(
NULL
),
h
->
uuid
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
...
...
@@ -865,6 +895,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
switch_channel_set_variable
(
channel
,
"fifo_pop_order"
,
NULL
);
switch_core_event_hook_add_state_change
(
session
,
hanguphook
);
app_name
=
"fifo"
;
arg
=
switch_core_session_sprintf
(
session
,
"%s out nowait"
,
node_name
);
...
...
@@ -910,6 +941,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
switch_event_t
*
ovars
=
NULL
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
switch_event_t
*
event
=
NULL
;
char
*
sql
=
NULL
;
switch_mutex_lock
(
globals
.
mutex
);
node
=
switch_core_hash_find
(
globals
.
fifo_hash
,
h
->
node_name
);
...
...
@@ -951,6 +983,11 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
switch_event_fire
(
&
event
);
}
sql
=
switch_mprintf
(
"update fifo_outbound set use_count=use_count+1,outbound_fail_count=0 where uuid='%s'"
,
h
->
uuid
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
status
=
switch_ivr_originate
(
NULL
,
&
session
,
&
cause
,
originate_string
,
h
->
timeout
,
NULL
,
NULL
,
NULL
,
NULL
,
ovars
,
SOF_NONE
,
NULL
);
free
(
originate_string
);
...
...
@@ -958,6 +995,12 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
if
(
status
!=
SWITCH_STATUS_SUCCESS
)
{
sql
=
switch_mprintf
(
"update fifo_outbound set use_count=use_count-1, "
"outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%q' and use_count > 0"
,
(
long
)
switch_epoch_time_now
(
NULL
),
h
->
uuid
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Name"
,
node
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Action"
,
"post-dial"
);
...
...
@@ -992,6 +1035,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
}
}
switch_core_event_hook_add_state_change
(
session
,
hanguphook
);
switch_channel_set_variable
(
channel
,
"fifo_outbound_uuid"
,
h
->
uuid
);
app_name
=
"fifo"
;
arg
=
switch_core_session_sprintf
(
session
,
"%s out %s"
,
h
->
node_name
,
member_wait
?
member_wait
:
"wait"
);
...
...
@@ -1360,27 +1404,6 @@ SWITCH_STANDARD_API(fifo_add_outbound_function)
}
static
switch_status_t
hanguphook
(
switch_core_session_t
*
session
)
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
switch_channel_state_t
state
=
switch_channel_get_state
(
channel
);
const
char
*
uuid
=
NULL
;
char
sql
[
256
]
=
""
;
if
(
state
==
CS_HANGUP
||
state
==
CS_ROUTING
)
{
if
((
uuid
=
switch_channel_get_variable
(
channel
,
"fifo_outbound_uuid"
)))
{
switch_snprintf
(
sql
,
sizeof
(
sql
),
"update fifo_outbound set use_count=use_count-1, "
"outbound_call_count=outbound_call_count+1, next_avail=%ld + lag where uuid='%s'"
,
(
long
)
switch_epoch_time_now
(
NULL
),
uuid
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
}
switch_core_event_hook_remove_state_change
(
session
,
hanguphook
);
}
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_STANDARD_APP
(
fifo_member_usage_function
)
{
char
*
sql
;
...
...
@@ -1762,7 +1785,12 @@ SWITCH_STANDARD_APP(fifo_function)
const
char
*
caller_uuid
=
NULL
;
switch_event_t
*
call_event
;
const
char
*
outbound_id
=
switch_channel_get_variable
(
channel
,
"fifo_outbound_uuid"
);
const
char
*
track_use_count
=
switch_channel_get_variable
(
channel
,
"fifo_track_use_count"
);
if
(
!
switch_true
(
track_use_count
))
{
outbound_id
=
NULL
;
}
if
(
!
zstr
(
strat_str
))
{
if
(
!
strcasecmp
(
strat_str
,
"more_ppl"
))
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论