Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
07487114
提交
07487114
authored
9月 20, 2010
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MODAPP-453
上级
b834a0e5
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
20 行增加
和
27 行删除
+20
-27
mod_fifo.c
src/mod/applications/mod_fifo/mod_fifo.c
+20
-27
没有找到文件。
src/mod/applications/mod_fifo/mod_fifo.c
浏览文件 @
07487114
...
@@ -439,7 +439,7 @@ static switch_status_t moh_on_dtmf(switch_core_session_t *session, void *input,
...
@@ -439,7 +439,7 @@ static switch_status_t moh_on_dtmf(switch_core_session_t *session, void *input,
#define check_string(s) if (!zstr(s) && !strcasecmp(s, "undef")) { s = NULL; }
#define check_string(s) if (!zstr(s) && !strcasecmp(s, "undef")) { s = NULL; }
static
int
node_c
onsumer_wait
_count
(
fifo_node_t
*
node
)
static
int
node_c
aller
_count
(
fifo_node_t
*
node
)
{
{
int
i
,
len
=
0
;
int
i
,
len
=
0
;
...
@@ -458,7 +458,7 @@ static void node_remove_uuid(fifo_node_t *node, const char *uuid)
...
@@ -458,7 +458,7 @@ static void node_remove_uuid(fifo_node_t *node, const char *uuid)
fifo_queue_popfly
(
node
->
fifo_list
[
i
],
uuid
);
fifo_queue_popfly
(
node
->
fifo_list
[
i
],
uuid
);
}
}
if
(
!
node_c
onsumer_wait
_count
(
node
))
{
if
(
!
node_c
aller
_count
(
node
))
{
node
->
start_waiting
=
0
;
node
->
start_waiting
=
0
;
}
}
...
@@ -1683,7 +1683,7 @@ static void find_consumers(fifo_node_t *node)
...
@@ -1683,7 +1683,7 @@ static void find_consumers(fifo_node_t *node)
switch
(
node
->
outbound_strategy
)
{
switch
(
node
->
outbound_strategy
)
{
case
NODE_STRATEGY_ENTERPRISE
:
case
NODE_STRATEGY_ENTERPRISE
:
{
{
int
need
=
node_c
onsumer_wait
_count
(
node
);
int
need
=
node_c
aller
_count
(
node
);
if
(
node
->
outbound_per_cycle
&&
node
->
outbound_per_cycle
<
need
)
{
if
(
node
->
outbound_per_cycle
&&
node
->
outbound_per_cycle
<
need
)
{
need
=
node
->
outbound_per_cycle
;
need
=
node
->
outbound_per_cycle
;
...
@@ -1753,7 +1753,7 @@ static void *SWITCH_THREAD_FUNC node_thread_run(switch_thread_t *thread, void *o
...
@@ -1753,7 +1753,7 @@ static void *SWITCH_THREAD_FUNC node_thread_run(switch_thread_t *thread, void *o
if
((
node
=
(
fifo_node_t
*
)
val
))
{
if
((
node
=
(
fifo_node_t
*
)
val
))
{
if
(
node
->
outbound_priority
==
0
)
node
->
outbound_priority
=
5
;
if
(
node
->
outbound_priority
==
0
)
node
->
outbound_priority
=
5
;
if
(
node
->
has_outbound
&&
node
->
ready
&&
!
node
->
busy
&&
node
->
outbound_priority
==
cur_priority
)
{
if
(
node
->
has_outbound
&&
node
->
ready
&&
!
node
->
busy
&&
node
->
outbound_priority
==
cur_priority
)
{
ppl_waiting
=
node_c
onsumer_wait
_count
(
node
);
ppl_waiting
=
node_c
aller
_count
(
node
);
consumer_total
=
node
->
consumer_count
;
consumer_total
=
node
->
consumer_count
;
idle_consumers
=
node_idle_consumers
(
node
);
idle_consumers
=
node_idle_consumers
(
node
);
...
@@ -1831,7 +1831,7 @@ static void check_cancel(fifo_node_t *node)
...
@@ -1831,7 +1831,7 @@ static void check_cancel(fifo_node_t *node)
return
;
return
;
}
}
ppl_waiting
=
node_c
onsumer_wait
_count
(
node
);
ppl_waiting
=
node_c
aller
_count
(
node
);
if
(
node
->
ring_consumer_count
>
0
&&
ppl_waiting
<
1
)
{
if
(
node
->
ring_consumer_count
>
0
&&
ppl_waiting
<
1
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Outbound call count (%d) exceeds required value for queue %s (%d), "
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Outbound call count (%d) exceeds required value for queue %s (%d), "
...
@@ -1855,7 +1855,7 @@ static void send_presence(fifo_node_t *node)
...
@@ -1855,7 +1855,7 @@ static void send_presence(fifo_node_t *node)
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
"park"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
"park"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
node
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
node
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
node
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
node
->
name
);
if
((
wait_count
=
node_c
onsumer_wait
_count
(
node
))
>
0
)
{
if
((
wait_count
=
node_c
aller
_count
(
node
))
>
0
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"status"
,
"Active (%d waiting)"
,
wait_count
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"status"
,
"Active (%d waiting)"
,
wait_count
);
}
else
{
}
else
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"status"
,
"Idle"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"status"
,
"Idle"
);
...
@@ -2296,7 +2296,6 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2296,7 +2296,6 @@ SWITCH_STANDARD_APP(fifo_function)
switch_channel_answer
(
channel
);
switch_channel_answer
(
channel
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
node
->
caller_count
++
;
if
((
pri
=
switch_channel_get_variable
(
channel
,
"fifo_priority"
)))
{
if
((
pri
=
switch_channel_get_variable
(
channel
,
"fifo_priority"
)))
{
p
=
atoi
(
pri
);
p
=
atoi
(
pri
);
...
@@ -2306,7 +2305,7 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2306,7 +2305,7 @@ SWITCH_STANDARD_APP(fifo_function)
p
=
MAX_PRI
-
1
;
p
=
MAX_PRI
-
1
;
}
}
if
(
!
node_c
onsumer_wait
_count
(
node
))
{
if
(
!
node_c
aller
_count
(
node
))
{
node
->
start_waiting
=
switch_micro_time_now
();
node
->
start_waiting
=
switch_micro_time_now
();
}
}
...
@@ -2442,7 +2441,6 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2442,7 +2441,6 @@ SWITCH_STANDARD_APP(fifo_function)
switch_mutex_lock
(
globals
.
mutex
);
switch_mutex_lock
(
globals
.
mutex
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
node_remove_uuid
(
node
,
uuid
);
node_remove_uuid
(
node
,
uuid
);
node
->
caller_count
--
;
switch_thread_rwlock_unlock
(
node
->
rwlock
);
switch_thread_rwlock_unlock
(
node
->
rwlock
);
send_presence
(
node
);
send_presence
(
node
);
check_cancel
(
node
);
check_cancel
(
node
);
...
@@ -2583,7 +2581,7 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2583,7 +2581,7 @@ SWITCH_STANDARD_APP(fifo_function)
continue
;
continue
;
}
}
if
((
waiting
=
node_c
onsumer_wait
_count
(
node
)))
{
if
((
waiting
=
node_c
aller
_count
(
node
)))
{
if
(
!
importance
||
node
->
importance
>
importance
)
{
if
(
!
importance
||
node
->
importance
>
importance
)
{
if
(
strat
==
STRAT_WAITING_LONGER
)
{
if
(
strat
==
STRAT_WAITING_LONGER
)
{
...
@@ -2671,7 +2669,7 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2671,7 +2669,7 @@ SWITCH_STANDARD_APP(fifo_function)
}
}
}
}
if
(
pop
&&
!
node_c
onsumer_wait
_count
(
node
))
{
if
(
pop
&&
!
node_c
aller
_count
(
node
))
{
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
node
->
start_waiting
=
0
;
node
->
start_waiting
=
0
;
switch_thread_rwlock_unlock
(
node
->
rwlock
);
switch_thread_rwlock_unlock
(
node
->
rwlock
);
...
@@ -2787,9 +2785,6 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2787,9 +2785,6 @@ SWITCH_STANDARD_APP(fifo_function)
const
char
*
arg
=
switch_channel_get_variable
(
other_channel
,
"current_application_data"
);
const
char
*
arg
=
switch_channel_get_variable
(
other_channel
,
"current_application_data"
);
switch_caller_extension_t
*
extension
=
NULL
;
switch_caller_extension_t
*
extension
=
NULL
;
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
node
->
caller_count
--
;
switch_thread_rwlock_unlock
(
node
->
rwlock
);
send_presence
(
node
);
send_presence
(
node
);
check_cancel
(
node
);
check_cancel
(
node
);
...
@@ -2955,8 +2950,6 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2955,8 +2950,6 @@ SWITCH_STANDARD_APP(fifo_function)
switch_channel_set_variable
(
other_channel
,
"fifo_status"
,
"DONE"
);
switch_channel_set_variable
(
other_channel
,
"fifo_status"
,
"DONE"
);
switch_channel_set_variable
(
other_channel
,
"fifo_timestamp"
,
date
);
switch_channel_set_variable
(
other_channel
,
"fifo_timestamp"
,
date
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
node
->
caller_count
--
;
switch_thread_rwlock_unlock
(
node
->
rwlock
);
switch_thread_rwlock_unlock
(
node
->
rwlock
);
send_presence
(
node
);
send_presence
(
node
);
check_cancel
(
node
);
check_cancel
(
node
);
...
@@ -3070,7 +3063,7 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -3070,7 +3063,7 @@ SWITCH_STANDARD_APP(fifo_function)
done
:
done
:
switch_mutex_lock
(
globals
.
mutex
);
switch_mutex_lock
(
globals
.
mutex
);
if
(
node
&&
node
->
ready
==
FIFO_DELAY_DESTROY
&&
node
->
consumer_count
==
0
&&
node
->
caller_count
==
0
)
{
if
(
node
&&
node
->
ready
==
FIFO_DELAY_DESTROY
&&
node
->
consumer_count
==
0
&&
node
_caller_count
(
node
)
==
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_NOTICE
,
"%s removed.
\n
"
,
node
->
name
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_NOTICE
,
"%s removed.
\n
"
,
node
->
name
);
switch_core_hash_delete
(
globals
.
fifo_hash
,
node
->
name
);
switch_core_hash_delete
(
globals
.
fifo_hash
,
node
->
name
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
...
@@ -3505,9 +3498,9 @@ static void list_node(fifo_node_t *node, switch_xml_t x_report, int *off, int ve
...
@@ -3505,9 +3498,9 @@ static void list_node(fifo_node_t *node, switch_xml_t x_report, int *off, int ve
switch_xml_set_attr_d
(
x_fifo
,
"name"
,
node
->
name
);
switch_xml_set_attr_d
(
x_fifo
,
"name"
,
node
->
name
);
switch_snprintf
(
tmp
,
sizeof
(
buffer
),
"%d"
,
node
->
consumer_count
);
switch_snprintf
(
tmp
,
sizeof
(
buffer
),
"%d"
,
node
->
consumer_count
);
switch_xml_set_attr_d
(
x_fifo
,
"consumer_count"
,
tmp
);
switch_xml_set_attr_d
(
x_fifo
,
"consumer_count"
,
tmp
);
switch_snprintf
(
tmp
,
sizeof
(
buffer
),
"%d"
,
node
->
caller_count
);
switch_snprintf
(
tmp
,
sizeof
(
buffer
),
"%d"
,
node
_caller_count
(
node
)
);
switch_xml_set_attr_d
(
x_fifo
,
"caller_count"
,
tmp
);
switch_xml_set_attr_d
(
x_fifo
,
"caller_count"
,
tmp
);
switch_snprintf
(
tmp
,
sizeof
(
buffer
),
"%d"
,
node_c
onsumer_wait
_count
(
node
));
switch_snprintf
(
tmp
,
sizeof
(
buffer
),
"%d"
,
node_c
aller
_count
(
node
));
switch_xml_set_attr_d
(
x_fifo
,
"waiting_count"
,
tmp
);
switch_xml_set_attr_d
(
x_fifo
,
"waiting_count"
,
tmp
);
switch_snprintf
(
tmp
,
sizeof
(
buffer
),
"%u"
,
node
->
importance
);
switch_snprintf
(
tmp
,
sizeof
(
buffer
),
"%u"
,
node
->
importance
);
switch_xml_set_attr_d
(
x_fifo
,
"importance"
,
tmp
);
switch_xml_set_attr_d
(
x_fifo
,
"importance"
,
tmp
);
...
@@ -3569,7 +3562,7 @@ void node_dump(switch_stream_handle_t *stream)
...
@@ -3569,7 +3562,7 @@ void node_dump(switch_stream_handle_t *stream)
node
->
outbound_priority
,
node
->
outbound_priority
,
node
->
busy
,
node
->
busy
,
node
->
ready
,
node
->
ready
,
node_c
onsumer_wait
_count
(
node
)
node_c
aller
_count
(
node
)
);
);
}
}
...
@@ -3687,9 +3680,9 @@ SWITCH_STANDARD_API(fifo_api_function)
...
@@ -3687,9 +3680,9 @@ SWITCH_STANDARD_API(fifo_api_function)
for
(
hi
=
switch_hash_first
(
NULL
,
globals
.
fifo_hash
);
hi
;
hi
=
switch_hash_next
(
hi
))
{
for
(
hi
=
switch_hash_first
(
NULL
,
globals
.
fifo_hash
);
hi
;
hi
=
switch_hash_next
(
hi
))
{
switch_hash_this
(
hi
,
&
var
,
NULL
,
&
val
);
switch_hash_this
(
hi
,
&
var
,
NULL
,
&
val
);
node
=
(
fifo_node_t
*
)
val
;
node
=
(
fifo_node_t
*
)
val
;
len
=
node_c
onsumer_wait
_count
(
node
);
len
=
node_c
aller
_count
(
node
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
stream
->
write_function
(
stream
,
"%s:%d:%d:%d
\n
"
,
(
char
*
)
var
,
node
->
consumer_count
,
node
->
caller_count
,
len
);
stream
->
write_function
(
stream
,
"%s:%d:%d:%d
\n
"
,
(
char
*
)
var
,
node
->
consumer_count
,
node
_caller_count
(
node
)
,
len
);
switch_thread_rwlock_unlock
(
node
->
rwlock
);
switch_thread_rwlock_unlock
(
node
->
rwlock
);
x
++
;
x
++
;
}
}
...
@@ -3698,9 +3691,9 @@ SWITCH_STANDARD_API(fifo_api_function)
...
@@ -3698,9 +3691,9 @@ SWITCH_STANDARD_API(fifo_api_function)
stream
->
write_function
(
stream
,
"none
\n
"
);
stream
->
write_function
(
stream
,
"none
\n
"
);
}
}
}
else
if
((
node
=
switch_core_hash_find
(
globals
.
fifo_hash
,
argv
[
1
])))
{
}
else
if
((
node
=
switch_core_hash_find
(
globals
.
fifo_hash
,
argv
[
1
])))
{
len
=
node_c
onsumer_wait
_count
(
node
);
len
=
node_c
aller
_count
(
node
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
stream
->
write_function
(
stream
,
"%s:%d:%d:%d
\n
"
,
argv
[
1
],
node
->
consumer_count
,
node
->
caller_count
,
len
);
stream
->
write_function
(
stream
,
"%s:%d:%d:%d
\n
"
,
argv
[
1
],
node
->
consumer_count
,
node
_caller_count
(
node
)
,
len
);
switch_thread_rwlock_unlock
(
node
->
rwlock
);
switch_thread_rwlock_unlock
(
node
->
rwlock
);
}
else
{
}
else
{
stream
->
write_function
(
stream
,
"none
\n
"
);
stream
->
write_function
(
stream
,
"none
\n
"
);
...
@@ -3710,7 +3703,7 @@ SWITCH_STANDARD_API(fifo_api_function)
...
@@ -3710,7 +3703,7 @@ SWITCH_STANDARD_API(fifo_api_function)
for
(
hi
=
switch_hash_first
(
NULL
,
globals
.
fifo_hash
);
hi
;
hi
=
switch_hash_next
(
hi
))
{
for
(
hi
=
switch_hash_first
(
NULL
,
globals
.
fifo_hash
);
hi
;
hi
=
switch_hash_next
(
hi
))
{
switch_hash_this
(
hi
,
&
var
,
NULL
,
&
val
);
switch_hash_this
(
hi
,
&
var
,
NULL
,
&
val
);
node
=
(
fifo_node_t
*
)
val
;
node
=
(
fifo_node_t
*
)
val
;
len
=
node_c
onsumer_wait
_count
(
node
);
len
=
node_c
aller
_count
(
node
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
stream
->
write_function
(
stream
,
"%s:%d
\n
"
,
(
char
*
)
var
,
node
->
has_outbound
);
stream
->
write_function
(
stream
,
"%s:%d
\n
"
,
(
char
*
)
var
,
node
->
has_outbound
);
switch_thread_rwlock_unlock
(
node
->
rwlock
);
switch_thread_rwlock_unlock
(
node
->
rwlock
);
...
@@ -3721,7 +3714,7 @@ SWITCH_STANDARD_API(fifo_api_function)
...
@@ -3721,7 +3714,7 @@ SWITCH_STANDARD_API(fifo_api_function)
stream
->
write_function
(
stream
,
"none
\n
"
);
stream
->
write_function
(
stream
,
"none
\n
"
);
}
}
}
else
if
((
node
=
switch_core_hash_find
(
globals
.
fifo_hash
,
argv
[
1
])))
{
}
else
if
((
node
=
switch_core_hash_find
(
globals
.
fifo_hash
,
argv
[
1
])))
{
len
=
node_c
onsumer_wait
_count
(
node
);
len
=
node_c
aller
_count
(
node
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
switch_thread_rwlock_wrlock
(
node
->
rwlock
);
stream
->
write_function
(
stream
,
"%s:%d
\n
"
,
argv
[
1
],
node
->
has_outbound
);
stream
->
write_function
(
stream
,
"%s:%d
\n
"
,
argv
[
1
],
node
->
has_outbound
);
switch_thread_rwlock_unlock
(
node
->
rwlock
);
switch_thread_rwlock_unlock
(
node
->
rwlock
);
...
@@ -4072,7 +4065,7 @@ static switch_status_t load_config(int reload, int del_all)
...
@@ -4072,7 +4065,7 @@ static switch_status_t load_config(int reload, int del_all)
continue
;
continue
;
}
}
if
(
node_c
onsumer_wait
_count
(
node
)
||
node
->
consumer_count
||
node_idle_consumers
(
node
))
{
if
(
node_c
aller
_count
(
node
)
||
node
->
consumer_count
||
node_idle_consumers
(
node
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"%s removal delayed, still in use.
\n
"
,
node
->
name
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"%s removal delayed, still in use.
\n
"
,
node
->
name
);
node
->
ready
=
FIFO_DELAY_DESTROY
;
node
->
ready
=
FIFO_DELAY_DESTROY
;
}
else
{
}
else
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论