Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
82af87f3
提交
82af87f3
authored
7月 17, 2011
作者:
Travis Cross
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
M-x whitespace-cleanup
上级
130e1c87
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
167 行增加
和
167 行删除
+167
-167
mod_fifo.c
src/mod/applications/mod_fifo/mod_fifo.c
+167
-167
没有找到文件。
src/mod/applications/mod_fifo/mod_fifo.c
浏览文件 @
82af87f3
...
@@ -82,7 +82,7 @@ static void add_bridge_call(const char *key);
...
@@ -82,7 +82,7 @@ static void add_bridge_call(const char *key);
static
void
del_bridge_call
(
const
char
*
key
);
static
void
del_bridge_call
(
const
char
*
key
);
switch_status_t
fifo_queue_create
(
fifo_queue_t
**
queue
,
int
size
,
switch_memory_pool_t
*
pool
)
switch_status_t
fifo_queue_create
(
fifo_queue_t
**
queue
,
int
size
,
switch_memory_pool_t
*
pool
)
{
{
fifo_queue_t
*
q
;
fifo_queue_t
*
q
;
...
@@ -91,9 +91,9 @@ switch_status_t fifo_queue_create(fifo_queue_t **queue, int size, switch_memory_
...
@@ -91,9 +91,9 @@ switch_status_t fifo_queue_create(fifo_queue_t **queue, int size, switch_memory_
q
->
nelm
=
size
-
1
;
q
->
nelm
=
size
-
1
;
q
->
data
=
switch_core_alloc
(
pool
,
size
*
sizeof
(
switch_event_t
*
));
q
->
data
=
switch_core_alloc
(
pool
,
size
*
sizeof
(
switch_event_t
*
));
switch_mutex_init
(
&
q
->
mutex
,
SWITCH_MUTEX_NESTED
,
pool
);
switch_mutex_init
(
&
q
->
mutex
,
SWITCH_MUTEX_NESTED
,
pool
);
*
queue
=
q
;
*
queue
=
q
;
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
...
@@ -110,13 +110,13 @@ static void change_pos(switch_event_t *event, int pos)
...
@@ -110,13 +110,13 @@ static void change_pos(switch_event_t *event, int pos)
if
(
!
(
session
=
switch_core_session_locate
(
uuid
)))
{
if
(
!
(
session
=
switch_core_session_locate
(
uuid
)))
{
return
;
return
;
}
}
channel
=
switch_core_session_get_channel
(
session
);
channel
=
switch_core_session_get_channel
(
session
);
switch_snprintf
(
tmp
,
sizeof
(
tmp
),
"%d"
,
pos
);
switch_snprintf
(
tmp
,
sizeof
(
tmp
),
"%d"
,
pos
);
switch_channel_set_variable
(
channel
,
"fifo_position"
,
tmp
);
switch_channel_set_variable
(
channel
,
"fifo_position"
,
tmp
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"fifo_position"
,
tmp
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"fifo_position"
,
tmp
);
switch_core_session_rwunlock
(
session
);
switch_core_session_rwunlock
(
session
);
...
@@ -176,17 +176,17 @@ static switch_status_t fifo_queue_pop(fifo_queue_t *queue, switch_event_t **pop,
...
@@ -176,17 +176,17 @@ static switch_status_t fifo_queue_pop(fifo_queue_t *queue, switch_event_t **pop,
switch_mutex_unlock
(
queue
->
mutex
);
switch_mutex_unlock
(
queue
->
mutex
);
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
}
}
if
(
remove
)
{
if
(
remove
)
{
for
(
i
=
j
+
1
;
i
<
queue
->
idx
;
i
++
)
{
for
(
i
=
j
+
1
;
i
<
queue
->
idx
;
i
++
)
{
queue
->
data
[
i
-
1
]
=
queue
->
data
[
i
];
queue
->
data
[
i
-
1
]
=
queue
->
data
[
i
];
queue
->
data
[
i
]
=
NULL
;
queue
->
data
[
i
]
=
NULL
;
change_pos
(
queue
->
data
[
i
-
1
],
i
);
change_pos
(
queue
->
data
[
i
-
1
],
i
);
}
}
queue
->
idx
--
;
queue
->
idx
--
;
}
}
switch_mutex_unlock
(
queue
->
mutex
);
switch_mutex_unlock
(
queue
->
mutex
);
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
...
@@ -232,17 +232,17 @@ static switch_status_t fifo_queue_pop_nameval(fifo_queue_t *queue, const char *n
...
@@ -232,17 +232,17 @@ static switch_status_t fifo_queue_pop_nameval(fifo_queue_t *queue, const char *n
switch_mutex_unlock
(
queue
->
mutex
);
switch_mutex_unlock
(
queue
->
mutex
);
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
}
}
if
(
remove
)
{
if
(
remove
)
{
for
(
i
=
j
+
1
;
i
<
queue
->
idx
;
i
++
)
{
for
(
i
=
j
+
1
;
i
<
queue
->
idx
;
i
++
)
{
queue
->
data
[
i
-
1
]
=
queue
->
data
[
i
];
queue
->
data
[
i
-
1
]
=
queue
->
data
[
i
];
queue
->
data
[
i
]
=
NULL
;
queue
->
data
[
i
]
=
NULL
;
change_pos
(
queue
->
data
[
i
-
1
],
i
);
change_pos
(
queue
->
data
[
i
-
1
],
i
);
}
}
queue
->
idx
--
;
queue
->
idx
--
;
}
}
switch_mutex_unlock
(
queue
->
mutex
);
switch_mutex_unlock
(
queue
->
mutex
);
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
...
@@ -277,9 +277,9 @@ static switch_status_t fifo_queue_popfly(fifo_queue_t *queue, const char *uuid)
...
@@ -277,9 +277,9 @@ static switch_status_t fifo_queue_popfly(fifo_queue_t *queue, const char *uuid)
queue
->
data
[
i
]
=
NULL
;
queue
->
data
[
i
]
=
NULL
;
change_pos
(
queue
->
data
[
i
-
1
],
i
);
change_pos
(
queue
->
data
[
i
-
1
],
i
);
}
}
queue
->
idx
--
;
queue
->
idx
--
;
switch_mutex_unlock
(
queue
->
mutex
);
switch_mutex_unlock
(
queue
->
mutex
);
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
...
@@ -337,7 +337,7 @@ static const char *strat_parse(outbound_strategy_t s)
...
@@ -337,7 +337,7 @@ static const char *strat_parse(outbound_strategy_t s)
default:
default:
break
;
break
;
}
}
return
"invalid"
;
return
"invalid"
;
}
}
...
@@ -497,7 +497,7 @@ static switch_status_t chime_read_frame_callback(switch_core_session_t *session,
...
@@ -497,7 +497,7 @@ static switch_status_t chime_read_frame_callback(switch_core_session_t *session,
cd
->
do_orbit
=
1
;
cd
->
do_orbit
=
1
;
return
SWITCH_STATUS_BREAK
;
return
SWITCH_STATUS_BREAK
;
}
}
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
...
@@ -537,7 +537,7 @@ static switch_status_t caller_read_frame_callback(switch_core_session_t *session
...
@@ -537,7 +537,7 @@ static switch_status_t caller_read_frame_callback(switch_core_session_t *session
cd
->
next
=
switch_epoch_time_now
(
NULL
)
+
cd
->
freq
;
cd
->
next
=
switch_epoch_time_now
(
NULL
)
+
cd
->
freq
;
cd
->
index
++
;
cd
->
index
++
;
}
}
}
}
return
chime_read_frame_callback
(
session
,
frame
,
user_data
);
return
chime_read_frame_callback
(
session
,
frame
,
user_data
);
}
}
...
@@ -629,10 +629,10 @@ static void cancel_caller_outbound_call(const char *key, switch_call_cause_t cau
...
@@ -629,10 +629,10 @@ static void cancel_caller_outbound_call(const char *key, switch_call_cause_t cau
if
(
!
key
)
return
;
if
(
!
key
)
return
;
switch_mutex_lock
(
globals
.
caller_orig_mutex
);
switch_mutex_lock
(
globals
.
caller_orig_mutex
);
if
((
cancel_cause
=
(
switch_call_cause_t
*
)
switch_core_hash_find
(
globals
.
caller_orig_hash
,
key
)))
{
if
((
cancel_cause
=
(
switch_call_cause_t
*
)
switch_core_hash_find
(
globals
.
caller_orig_hash
,
key
)))
{
*
cancel_cause
=
cause
;
*
cancel_cause
=
cause
;
}
}
switch_mutex_unlock
(
globals
.
caller_orig_mutex
);
switch_mutex_unlock
(
globals
.
caller_orig_mutex
);
fifo_caller_del
(
key
);
fifo_caller_del
(
key
);
...
@@ -709,10 +709,10 @@ static void cancel_consumer_outbound_call(const char *key, switch_call_cause_t c
...
@@ -709,10 +709,10 @@ static void cancel_consumer_outbound_call(const char *key, switch_call_cause_t c
if
(
!
key
)
return
;
if
(
!
key
)
return
;
switch_mutex_lock
(
globals
.
consumer_orig_mutex
);
switch_mutex_lock
(
globals
.
consumer_orig_mutex
);
if
((
cancel_cause
=
(
switch_call_cause_t
*
)
switch_core_hash_find
(
globals
.
consumer_orig_hash
,
key
)))
{
if
((
cancel_cause
=
(
switch_call_cause_t
*
)
switch_core_hash_find
(
globals
.
consumer_orig_hash
,
key
)))
{
*
cancel_cause
=
cause
;
*
cancel_cause
=
cause
;
}
}
switch_mutex_unlock
(
globals
.
consumer_orig_mutex
);
switch_mutex_unlock
(
globals
.
consumer_orig_mutex
);
}
}
...
@@ -757,7 +757,7 @@ static switch_status_t fifo_execute_sql(char *sql, switch_mutex_t *mutex)
...
@@ -757,7 +757,7 @@ static switch_status_t fifo_execute_sql(char *sql, switch_mutex_t *mutex)
}
}
if
(
globals
.
debug
>
1
)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"sql: %s
\n
"
,
sql
);
if
(
globals
.
debug
>
1
)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"sql: %s
\n
"
,
sql
);
status
=
switch_cache_db_execute_sql
(
dbh
,
sql
,
NULL
);
status
=
switch_cache_db_execute_sql
(
dbh
,
sql
,
NULL
);
end:
end:
...
@@ -897,7 +897,7 @@ static void do_unbridge(switch_core_session_t *consumer_session, switch_core_ses
...
@@ -897,7 +897,7 @@ static void do_unbridge(switch_core_session_t *consumer_session, switch_core_ses
{
{
switch_channel_t
*
consumer_channel
=
switch_core_session_get_channel
(
consumer_session
);
switch_channel_t
*
consumer_channel
=
switch_core_session_get_channel
(
consumer_session
);
switch_channel_t
*
caller_channel
=
NULL
;
switch_channel_t
*
caller_channel
=
NULL
;
if
(
caller_session
)
{
if
(
caller_session
)
{
caller_channel
=
switch_core_session_get_channel
(
caller_session
);
caller_channel
=
switch_core_session_get_channel
(
caller_session
);
}
}
...
@@ -911,23 +911,23 @@ static void do_unbridge(switch_core_session_t *consumer_session, switch_core_ses
...
@@ -911,23 +911,23 @@ static void do_unbridge(switch_core_session_t *consumer_session, switch_core_ses
const
char
*
epoch_start_a
=
NULL
;
const
char
*
epoch_start_a
=
NULL
;
char
*
sql
;
char
*
sql
;
switch_event_t
*
event
;
switch_event_t
*
event
;
switch_channel_clear_app_flag_key
(
FIFO_APP_KEY
,
consumer_channel
,
FIFO_APP_BRIDGE_TAG
);
switch_channel_clear_app_flag_key
(
FIFO_APP_KEY
,
consumer_channel
,
FIFO_APP_BRIDGE_TAG
);
switch_channel_set_variable
(
consumer_channel
,
"fifo_bridged"
,
NULL
);
switch_channel_set_variable
(
consumer_channel
,
"fifo_bridged"
,
NULL
);
ts
=
switch_micro_time_now
();
ts
=
switch_micro_time_now
();
switch_time_exp_lt
(
&
tm
,
ts
);
switch_time_exp_lt
(
&
tm
,
ts
);
switch_strftime_nocheck
(
date
,
&
retsize
,
sizeof
(
date
),
"%Y-%m-%d %T"
,
&
tm
);
switch_strftime_nocheck
(
date
,
&
retsize
,
sizeof
(
date
),
"%Y-%m-%d %T"
,
&
tm
);
sql
=
switch_mprintf
(
"delete from fifo_bridge where consumer_uuid='%q'"
,
switch_core_session_get_uuid
(
consumer_session
));
sql
=
switch_mprintf
(
"delete from fifo_bridge where consumer_uuid='%q'"
,
switch_core_session_get_uuid
(
consumer_session
));
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
switch_channel_set_variable
(
consumer_channel
,
"fifo_status"
,
"WAITING"
);
switch_channel_set_variable
(
consumer_channel
,
"fifo_status"
,
"WAITING"
);
switch_channel_set_variable
(
consumer_channel
,
"fifo_timestamp"
,
date
);
switch_channel_set_variable
(
consumer_channel
,
"fifo_timestamp"
,
date
);
if
(
caller_channel
)
{
if
(
caller_channel
)
{
switch_channel_set_variable
(
caller_channel
,
"fifo_status"
,
"DONE"
);
switch_channel_set_variable
(
caller_channel
,
"fifo_status"
,
"DONE"
);
switch_channel_set_variable
(
caller_channel
,
"fifo_timestamp"
,
date
);
switch_channel_set_variable
(
caller_channel
,
"fifo_timestamp"
,
date
);
...
@@ -936,12 +936,12 @@ static void do_unbridge(switch_core_session_t *consumer_session, switch_core_ses
...
@@ -936,12 +936,12 @@ static void do_unbridge(switch_core_session_t *consumer_session, switch_core_ses
if
((
epoch_start_a
=
switch_channel_get_variable
(
consumer_channel
,
"fifo_epoch_start_bridge"
)))
{
if
((
epoch_start_a
=
switch_channel_get_variable
(
consumer_channel
,
"fifo_epoch_start_bridge"
)))
{
epoch_start
=
atol
(
epoch_start_a
);
epoch_start
=
atol
(
epoch_start_a
);
}
}
epoch_end
=
(
long
)
switch_epoch_time_now
(
NULL
);
epoch_end
=
(
long
)
switch_epoch_time_now
(
NULL
);
switch_channel_set_variable_printf
(
consumer_channel
,
"fifo_epoch_stop_bridge"
,
"%ld"
,
epoch_end
);
switch_channel_set_variable_printf
(
consumer_channel
,
"fifo_epoch_stop_bridge"
,
"%ld"
,
epoch_end
);
switch_channel_set_variable_printf
(
consumer_channel
,
"fifo_bridge_seconds"
,
"%d"
,
epoch_end
-
epoch_start
);
switch_channel_set_variable_printf
(
consumer_channel
,
"fifo_bridge_seconds"
,
"%d"
,
epoch_end
-
epoch_start
);
if
(
caller_channel
)
{
if
(
caller_channel
)
{
switch_channel_set_variable_printf
(
caller_channel
,
"fifo_epoch_stop_bridge"
,
"%ld"
,
epoch_end
);
switch_channel_set_variable_printf
(
caller_channel
,
"fifo_epoch_stop_bridge"
,
"%ld"
,
epoch_end
);
switch_channel_set_variable_printf
(
caller_channel
,
"fifo_bridge_seconds"
,
"%d"
,
epoch_end
-
epoch_start
);
switch_channel_set_variable_printf
(
caller_channel
,
"fifo_bridge_seconds"
,
"%d"
,
epoch_end
-
epoch_start
);
...
@@ -988,8 +988,8 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
...
@@ -988,8 +988,8 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
if
(
!
outbound_id
)
return
SWITCH_STATUS_SUCCESS
;
if
(
!
outbound_id
)
return
SWITCH_STATUS_SUCCESS
;
switch
(
msg
->
message_id
)
{
switch
(
msg
->
message_id
)
{
case
SWITCH_MESSAGE_INDICATE_BRIDGE
:
case
SWITCH_MESSAGE_INDICATE_BRIDGE
:
case
SWITCH_MESSAGE_INDICATE_UNBRIDGE
:
case
SWITCH_MESSAGE_INDICATE_UNBRIDGE
:
if
(
msg
->
numeric_arg
==
42
)
{
if
(
msg
->
numeric_arg
==
42
)
{
goto
end
;
goto
end
;
}
}
...
@@ -1011,11 +1011,11 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
...
@@ -1011,11 +1011,11 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
goto
end
;
goto
end
;
default:
default:
goto
end
;
goto
end
;
}
}
switch
(
msg
->
message_id
)
{
switch
(
msg
->
message_id
)
{
case
SWITCH_MESSAGE_INDICATE_BRIDGE
:
case
SWITCH_MESSAGE_INDICATE_BRIDGE
:
{
{
...
@@ -1026,20 +1026,20 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
...
@@ -1026,20 +1026,20 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
switch_time_exp_t
tm
;
switch_time_exp_t
tm
;
switch_size_t
retsize
;
switch_size_t
retsize
;
const
char
*
ced_name
,
*
ced_number
,
*
cid_name
,
*
cid_number
;
const
char
*
ced_name
,
*
ced_number
,
*
cid_name
,
*
cid_number
;
if
(
switch_channel_test_app_flag_key
(
FIFO_APP_KEY
,
consumer_channel
,
FIFO_APP_BRIDGE_TAG
))
{
if
(
switch_channel_test_app_flag_key
(
FIFO_APP_KEY
,
consumer_channel
,
FIFO_APP_BRIDGE_TAG
))
{
goto
end
;
goto
end
;
}
}
switch_channel_set_app_flag_key
(
FIFO_APP_KEY
,
consumer_channel
,
FIFO_APP_BRIDGE_TAG
);
switch_channel_set_app_flag_key
(
FIFO_APP_KEY
,
consumer_channel
,
FIFO_APP_BRIDGE_TAG
);
switch_channel_set_variable
(
consumer_channel
,
"fifo_bridged"
,
"true"
);
switch_channel_set_variable
(
consumer_channel
,
"fifo_bridged"
,
"true"
);
switch_channel_set_variable
(
consumer_channel
,
"fifo_manual_bridge"
,
"true"
);
switch_channel_set_variable
(
consumer_channel
,
"fifo_manual_bridge"
,
"true"
);
switch_channel_set_variable
(
consumer_channel
,
"fifo_role"
,
"consumer"
);
switch_channel_set_variable
(
consumer_channel
,
"fifo_role"
,
"consumer"
);
if
(
caller_channel
)
{
if
(
caller_channel
)
{
switch_channel_set_variable
(
caller_channel
,
"fifo_role"
,
"caller"
);
switch_channel_set_variable
(
caller_channel
,
"fifo_role"
,
"caller"
);
switch_process_import
(
consumer_session
,
caller_channel
,
"fifo_caller_consumer_import"
,
switch_process_import
(
consumer_session
,
caller_channel
,
"fifo_caller_consumer_import"
,
switch_channel_get_variable
(
consumer_channel
,
"fifo_import_prefix"
));
switch_channel_get_variable
(
consumer_channel
,
"fifo_import_prefix"
));
switch_process_import
(
caller_session
,
consumer_channel
,
"fifo_consumer_caller_import"
,
switch_process_import
(
caller_session
,
consumer_channel
,
"fifo_consumer_caller_import"
,
switch_channel_get_variable
(
caller_channel
,
"fifo_import_prefix"
));
switch_channel_get_variable
(
caller_channel
,
"fifo_import_prefix"
));
...
@@ -1055,7 +1055,7 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
...
@@ -1055,7 +1055,7 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
if
(
zstr
(
ced_name
)
||
!
strcmp
(
ced_name
,
cid_name
))
{
if
(
zstr
(
ced_name
)
||
!
strcmp
(
ced_name
,
cid_name
))
{
ced_name
=
ced_number
;
ced_name
=
ced_number
;
}
}
if
(
zstr
(
ced_number
)
||
!
strcmp
(
ced_number
,
cid_number
))
{
if
(
zstr
(
ced_number
)
||
!
strcmp
(
ced_number
,
cid_number
))
{
ced_name
=
switch_channel_get_variable
(
consumer_channel
,
"destination_number"
);
ced_name
=
switch_channel_get_variable
(
consumer_channel
,
"destination_number"
);
ced_number
=
ced_name
;
ced_number
=
ced_name
;
...
@@ -1064,7 +1064,7 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
...
@@ -1064,7 +1064,7 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
ced_name
=
cid_name
;
ced_name
=
cid_name
;
ced_number
=
cid_number
;
ced_number
=
cid_number
;
}
}
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_channel_event_set_data
(
consumer_channel
,
event
);
switch_channel_event_set_data
(
consumer_channel
,
event
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Name"
,
MANUAL_QUEUE_NAME
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Name"
,
MANUAL_QUEUE_NAME
);
...
@@ -1073,7 +1073,7 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
...
@@ -1073,7 +1073,7 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Caller-CID-Number"
,
ced_number
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Caller-CID-Number"
,
ced_number
);
switch_event_fire
(
&
event
);
switch_event_fire
(
&
event
);
}
}
if
(
caller_channel
)
{
if
(
caller_channel
)
{
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_channel_event_set_data
(
caller_channel
,
event
);
switch_channel_event_set_data
(
caller_channel
,
event
);
...
@@ -1081,7 +1081,7 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
...
@@ -1081,7 +1081,7 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Action"
,
"bridge-caller-start"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Action"
,
"bridge-caller-start"
);
switch_event_fire
(
&
event
);
switch_event_fire
(
&
event
);
}
}
sql
=
switch_mprintf
(
"insert into fifo_bridge "
sql
=
switch_mprintf
(
"insert into fifo_bridge "
"(fifo_name,caller_uuid,caller_caller_id_name,caller_caller_id_number,consumer_uuid,consumer_outgoing_uuid,bridge_start) "
"(fifo_name,caller_uuid,caller_caller_id_name,caller_caller_id_number,consumer_uuid,consumer_outgoing_uuid,bridge_start) "
"values ('%q','%q','%q','%q','%q','%q',%ld)"
,
"values ('%q','%q','%q','%q','%q','%q',%ld)"
,
...
@@ -1106,11 +1106,11 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
...
@@ -1106,11 +1106,11 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
(
long
)
switch_epoch_time_now
(
NULL
)
(
long
)
switch_epoch_time_now
(
NULL
)
);
);
}
}
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
epoch_start
=
(
long
)
switch_epoch_time_now
(
NULL
);
epoch_start
=
(
long
)
switch_epoch_time_now
(
NULL
);
ts
=
switch_micro_time_now
();
ts
=
switch_micro_time_now
();
...
@@ -1124,7 +1124,7 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
...
@@ -1124,7 +1124,7 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
switch_channel_set_variable
(
consumer_channel
,
"fifo_timestamp"
,
date
);
switch_channel_set_variable
(
consumer_channel
,
"fifo_timestamp"
,
date
);
switch_channel_set_variable_printf
(
consumer_channel
,
"fifo_epoch_start_bridge"
,
"%ld"
,
epoch_start
);
switch_channel_set_variable_printf
(
consumer_channel
,
"fifo_epoch_start_bridge"
,
"%ld"
,
epoch_start
);
switch_channel_set_variable
(
consumer_channel
,
"fifo_role"
,
"consumer"
);
switch_channel_set_variable
(
consumer_channel
,
"fifo_role"
,
"consumer"
);
if
(
caller_channel
)
{
if
(
caller_channel
)
{
switch_channel_set_variable
(
caller_channel
,
"fifo_status"
,
"TALKING"
);
switch_channel_set_variable
(
caller_channel
,
"fifo_status"
,
"TALKING"
);
switch_channel_set_variable
(
caller_channel
,
"fifo_timestamp"
,
date
);
switch_channel_set_variable
(
caller_channel
,
"fifo_timestamp"
,
date
);
...
@@ -1176,7 +1176,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -1176,7 +1176,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
int
x
=
0
;
int
x
=
0
;
switch_event_t
*
event
;
switch_event_t
*
event
;
switch_uuid_t
uuid
;
switch_uuid_t
uuid
;
char
uuid_str
[
SWITCH_UUID_FORMATTED_LENGTH
+
1
];
char
uuid_str
[
SWITCH_UUID_FORMATTED_LENGTH
+
1
];
switch_call_cause_t
cancel_cause
=
0
;
switch_call_cause_t
cancel_cause
=
0
;
char
*
uuid_list
=
NULL
;
char
*
uuid_list
=
NULL
;
int
total
=
0
;
int
total
=
0
;
...
@@ -1188,11 +1188,11 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -1188,11 +1188,11 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
switch_mutex_lock
(
globals
.
mutex
);
switch_mutex_lock
(
globals
.
mutex
);
globals
.
threads
++
;
globals
.
threads
++
;
switch_mutex_unlock
(
globals
.
mutex
);
switch_mutex_unlock
(
globals
.
mutex
);
if
(
!
globals
.
running
)
goto
dpool
;
if
(
!
globals
.
running
)
goto
dpool
;
switch_uuid_get
(
&
uuid
);
switch_uuid_get
(
&
uuid
);
switch_uuid_format
(
uuid_str
,
&
uuid
);
switch_uuid_format
(
uuid_str
,
&
uuid
);
if
(
!
cbh
->
rowcount
)
{
if
(
!
cbh
->
rowcount
)
{
goto
end
;
goto
end
;
...
@@ -1206,7 +1206,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -1206,7 +1206,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
for
(
i
=
0
;
i
<
cbh
->
rowcount
;
i
++
)
{
for
(
i
=
0
;
i
<
cbh
->
rowcount
;
i
++
)
{
struct
call_helper
*
h
=
cbh
->
rows
[
i
];
struct
call_helper
*
h
=
cbh
->
rows
[
i
];
if
(
check_consumer_outbound_call
(
h
->
uuid
)
||
check_bridge_call
(
h
->
uuid
))
{
if
(
check_consumer_outbound_call
(
h
->
uuid
)
||
check_bridge_call
(
h
->
uuid
))
{
continue
;
continue
;
}
}
...
@@ -1222,9 +1222,9 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -1222,9 +1222,9 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
}
}
cbh
->
rowcount
=
rowcount
;
cbh
->
rowcount
=
rowcount
;
cbh
->
ready
=
1
;
cbh
->
ready
=
1
;
if
(
!
total
)
{
if
(
!
total
)
{
goto
end
;
goto
end
;
}
}
...
@@ -1245,38 +1245,38 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -1245,38 +1245,38 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
switch_event_create
(
&
ovars
,
SWITCH_EVENT_REQUEST_PARAMS
);
switch_event_create
(
&
ovars
,
SWITCH_EVENT_REQUEST_PARAMS
);
switch_assert
(
ovars
);
switch_assert
(
ovars
);
for
(
i
=
0
;
i
<
cbh
->
rowcount
;
i
++
)
{
for
(
i
=
0
;
i
<
cbh
->
rowcount
;
i
++
)
{
struct
call_helper
*
h
=
cbh
->
rows
[
i
];
struct
call_helper
*
h
=
cbh
->
rows
[
i
];
char
*
parsed
=
NULL
;
char
*
parsed
=
NULL
;
switch_event_create_brackets
(
h
->
originate_string
,
'{'
,
'}'
,
','
,
&
ovars
,
&
parsed
,
SWITCH_TRUE
);
switch_event_create_brackets
(
h
->
originate_string
,
'{'
,
'}'
,
','
,
&
ovars
,
&
parsed
,
SWITCH_TRUE
);
switch_event_del_header
(
ovars
,
"fifo_outbound_uuid"
);
switch_event_del_header
(
ovars
,
"fifo_outbound_uuid"
);
if
(
!
h
->
timeout
)
h
->
timeout
=
node
->
ring_timeout
;
if
(
!
h
->
timeout
)
h
->
timeout
=
node
->
ring_timeout
;
if
(
timeout
<
h
->
timeout
)
timeout
=
h
->
timeout
;
if
(
timeout
<
h
->
timeout
)
timeout
=
h
->
timeout
;
stream
.
write_function
(
&
stream
,
"[leg_timeout=%d,fifo_outbound_uuid=%s,fifo_name=%s]%s,"
,
stream
.
write_function
(
&
stream
,
"[leg_timeout=%d,fifo_outbound_uuid=%s,fifo_name=%s]%s,"
,
h
->
timeout
,
h
->
uuid
,
node
->
name
,
parsed
?
parsed
:
h
->
originate_string
);
h
->
timeout
,
h
->
uuid
,
node
->
name
,
parsed
?
parsed
:
h
->
originate_string
);
stream2
.
write_function
(
&
stream2
,
"%s,"
,
h
->
uuid
);
stream2
.
write_function
(
&
stream2
,
"%s,"
,
h
->
uuid
);
switch_safe_free
(
parsed
);
switch_safe_free
(
parsed
);
}
}
originate_string
=
(
char
*
)
stream
.
data
;
originate_string
=
(
char
*
)
stream
.
data
;
if
(
originate_string
)
{
if
(
originate_string
)
{
end_of
(
originate_string
)
=
'\0'
;
end_of
(
originate_string
)
=
'\0'
;
}
}
uuid_list
=
(
char
*
)
stream2
.
data
;
uuid_list
=
(
char
*
)
stream2
.
data
;
if
(
uuid_list
)
{
if
(
uuid_list
)
{
end_of
(
uuid_list
)
=
'\0'
;
end_of
(
uuid_list
)
=
'\0'
;
}
}
if
(
!
timeout
)
timeout
=
60
;
if
(
!
timeout
)
timeout
=
60
;
pop
=
pop_dup
=
NULL
;
pop
=
pop_dup
=
NULL
;
for
(
x
=
0
;
x
<
MAX_PRI
;
x
++
)
{
for
(
x
=
0
;
x
<
MAX_PRI
;
x
++
)
{
...
@@ -1300,7 +1300,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -1300,7 +1300,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
if
(
!
pop
)
{
if
(
!
pop
)
{
goto
end
;
goto
end
;
}
}
if
(
!
switch_event_get_header
(
ovars
,
"origination_caller_id_name"
))
{
if
(
!
switch_event_get_header
(
ovars
,
"origination_caller_id_name"
))
{
if
((
caller_id_name
=
switch_event_get_header
(
pop
,
"caller-caller-id-name"
)))
{
if
((
caller_id_name
=
switch_event_get_header
(
pop
,
"caller-caller-id-name"
)))
{
if
(
!
zstr
(
node
->
outbound_name
))
{
if
(
!
zstr
(
node
->
outbound_name
))
{
...
@@ -1310,13 +1310,13 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -1310,13 +1310,13 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
}
}
}
}
}
}
if
(
!
switch_event_get_header
(
ovars
,
"origination_caller_id_number"
))
{
if
(
!
switch_event_get_header
(
ovars
,
"origination_caller_id_number"
))
{
if
((
cid_num
=
switch_event_get_header
(
pop
,
"caller-caller-id-number"
)))
{
if
((
cid_num
=
switch_event_get_header
(
pop
,
"caller-caller-id-number"
)))
{
switch_event_add_header_string
(
ovars
,
SWITCH_STACK_BOTTOM
,
"origination_caller_id_number"
,
cid_num
);
switch_event_add_header_string
(
ovars
,
SWITCH_STACK_BOTTOM
,
"origination_caller_id_number"
,
cid_num
);
}
}
}
}
if
((
id
=
switch_event_get_header
(
pop
,
"unique-id"
)))
{
if
((
id
=
switch_event_get_header
(
pop
,
"unique-id"
)))
{
switch_event_add_header_string
(
ovars
,
SWITCH_STACK_BOTTOM
,
"fifo_bridge_uuid"
,
id
);
switch_event_add_header_string
(
ovars
,
SWITCH_STACK_BOTTOM
,
"fifo_bridge_uuid"
,
id
);
}
}
...
@@ -1333,7 +1333,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -1333,7 +1333,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
switch_channel_event_set_data
(
channel
,
event
);
switch_channel_event_set_data
(
channel
,
event
);
switch_core_session_rwunlock
(
session
);
switch_core_session_rwunlock
(
session
);
}
}
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Name"
,
node
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Name"
,
node
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Action"
,
"pre-dial"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Action"
,
"pre-dial"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"outbound-strategy"
,
"ringall"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"outbound-strategy"
,
"ringall"
);
...
@@ -1347,10 +1347,10 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -1347,10 +1347,10 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
for
(
i
=
0
;
i
<
cbh
->
rowcount
;
i
++
)
{
for
(
i
=
0
;
i
<
cbh
->
rowcount
;
i
++
)
{
struct
call_helper
*
h
=
cbh
->
rows
[
i
];
struct
call_helper
*
h
=
cbh
->
rows
[
i
];
char
*
sql
=
switch_mprintf
(
"update fifo_outbound set ring_count=ring_count+1 where uuid='%s'"
,
h
->
uuid
);
char
*
sql
=
switch_mprintf
(
"update fifo_outbound set ring_count=ring_count+1 where uuid='%s'"
,
h
->
uuid
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
}
}
if
(
!
total
)
goto
end
;
if
(
!
total
)
goto
end
;
...
@@ -1359,7 +1359,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -1359,7 +1359,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
const
char
*
rate
=
switch_event_get_header
(
pop
,
"variable_sip_use_codec_rate"
);
const
char
*
rate
=
switch_event_get_header
(
pop
,
"variable_sip_use_codec_rate"
);
const
char
*
ptime
=
switch_event_get_header
(
pop
,
"variable_sip_use_codec_ptime"
);
const
char
*
ptime
=
switch_event_get_header
(
pop
,
"variable_sip_use_codec_ptime"
);
char
nstr
[
256
]
=
""
;
char
nstr
[
256
]
=
""
;
if
(
strcasecmp
(
codec
,
"PCMU"
)
&&
strcasecmp
(
codec
,
"PCMA"
))
{
if
(
strcasecmp
(
codec
,
"PCMU"
)
&&
strcasecmp
(
codec
,
"PCMA"
))
{
switch_snprintf
(
nstr
,
sizeof
(
nstr
),
"%s@%si@%sh,PCMU@%si,PCMA@%si"
,
codec
,
ptime
,
rate
,
ptime
,
ptime
);
switch_snprintf
(
nstr
,
sizeof
(
nstr
),
"%s@%si@%sh,PCMU@%si,PCMA@%si"
,
codec
,
ptime
,
rate
,
ptime
,
ptime
);
}
else
{
}
else
{
...
@@ -1377,10 +1377,10 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -1377,10 +1377,10 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
del_caller_outbound_call
(
id
);
del_caller_outbound_call
(
id
);
if
(
status
!=
SWITCH_STATUS_SUCCESS
||
cause
!=
SWITCH_CAUSE_SUCCESS
)
{
if
(
status
!=
SWITCH_STATUS_SUCCESS
||
cause
!=
SWITCH_CAUSE_SUCCESS
)
{
const
char
*
acceptable
=
"false"
;
const
char
*
acceptable
=
"false"
;
switch
(
cause
)
{
switch
(
cause
)
{
case
SWITCH_CAUSE_ORIGINATOR_CANCEL
:
case
SWITCH_CAUSE_ORIGINATOR_CANCEL
:
case
SWITCH_CAUSE_PICKED_OFF
:
case
SWITCH_CAUSE_PICKED_OFF
:
...
@@ -1394,7 +1394,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -1394,7 +1394,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
}
}
}
}
break
;
break
;
default:
default:
...
@@ -1425,7 +1425,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -1425,7 +1425,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Outbound-UUID-List"
,
uuid_list
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Outbound-UUID-List"
,
uuid_list
);
switch_event_fire
(
&
event
);
switch_event_fire
(
&
event
);
}
}
goto
end
;
goto
end
;
}
}
...
@@ -1460,7 +1460,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -1460,7 +1460,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
for
(
i
=
0
;
i
<
cbh
->
rowcount
;
i
++
)
{
for
(
i
=
0
;
i
<
cbh
->
rowcount
;
i
++
)
{
struct
call_helper
*
h
=
cbh
->
rows
[
i
];
struct
call_helper
*
h
=
cbh
->
rows
[
i
];
char
*
sql
=
switch_mprintf
(
"update fifo_outbound set ring_count=ring_count-1 where uuid='%q' and ring_count > 0"
,
h
->
uuid
);
char
*
sql
=
switch_mprintf
(
"update fifo_outbound set ring_count=ring_count-1 where uuid='%q' and ring_count > 0"
,
h
->
uuid
);
...
@@ -1495,7 +1495,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
...
@@ -1495,7 +1495,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
if
(
pop_dup
)
{
if
(
pop_dup
)
{
switch_event_destroy
(
&
pop_dup
);
switch_event_destroy
(
&
pop_dup
);
}
}
dpool:
dpool:
pool
=
cbh
->
pool
;
pool
=
cbh
->
pool
;
...
@@ -1524,7 +1524,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
...
@@ -1524,7 +1524,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
switch_event_t
*
event
=
NULL
;
switch_event_t
*
event
=
NULL
;
char
*
sql
=
NULL
;
char
*
sql
=
NULL
;
if
(
!
globals
.
running
)
return
NULL
;
if
(
!
globals
.
running
)
return
NULL
;
switch_mutex_lock
(
globals
.
mutex
);
switch_mutex_lock
(
globals
.
mutex
);
globals
.
threads
++
;
globals
.
threads
++
;
...
@@ -1559,7 +1559,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
...
@@ -1559,7 +1559,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
"origination_caller_id_name=Queue,origination_caller_id_number='Queue: %q'}%s"
,
"origination_caller_id_name=Queue,origination_caller_id_number='Queue: %q'}%s"
,
node
->
name
,
node
->
name
,
node
->
name
,
h
->
originate_string
);
node
->
name
,
node
->
name
,
node
->
name
,
h
->
originate_string
);
}
}
}
}
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
...
@@ -1571,7 +1571,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
...
@@ -1571,7 +1571,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
switch_event_fire
(
&
event
);
switch_event_fire
(
&
event
);
}
}
sql
=
switch_mprintf
(
"update fifo_outbound set ring_count=ring_count+1 where uuid='%s'"
,
h
->
uuid
);
sql
=
switch_mprintf
(
"update fifo_outbound set ring_count=ring_count+1 where uuid='%s'"
,
h
->
uuid
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
...
@@ -1586,7 +1586,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
...
@@ -1586,7 +1586,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
(
long
)
switch_epoch_time_now
(
NULL
),
h
->
uuid
);
(
long
)
switch_epoch_time_now
(
NULL
),
h
->
uuid
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
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-Name"
,
node
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Action"
,
"post-dial"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Action"
,
"post-dial"
);
...
@@ -1661,7 +1661,7 @@ static int place_call_ringall_callback(void *pArg, int argc, char **argv, char *
...
@@ -1661,7 +1661,7 @@ static int place_call_ringall_callback(void *pArg, int argc, char **argv, char *
h
->
node_name
=
switch_core_strdup
(
h
->
pool
,
argv
[
1
]);
h
->
node_name
=
switch_core_strdup
(
h
->
pool
,
argv
[
1
]);
h
->
originate_string
=
switch_core_strdup
(
h
->
pool
,
argv
[
2
]);
h
->
originate_string
=
switch_core_strdup
(
h
->
pool
,
argv
[
2
]);
h
->
timeout
=
atoi
(
argv
[
5
]);
h
->
timeout
=
atoi
(
argv
[
5
]);
cbh
->
rows
[
cbh
->
rowcount
++
]
=
h
;
cbh
->
rows
[
cbh
->
rowcount
++
]
=
h
;
if
(
cbh
->
rowcount
==
MAX_ROWS
)
return
-
1
;
if
(
cbh
->
rowcount
==
MAX_ROWS
)
return
-
1
;
...
@@ -1672,7 +1672,7 @@ static int place_call_ringall_callback(void *pArg, int argc, char **argv, char *
...
@@ -1672,7 +1672,7 @@ static int place_call_ringall_callback(void *pArg, int argc, char **argv, char *
}
}
return
0
;
return
0
;
}
}
static
int
place_call_enterprise_callback
(
void
*
pArg
,
int
argc
,
char
**
argv
,
char
**
columnNames
)
static
int
place_call_enterprise_callback
(
void
*
pArg
,
int
argc
,
char
**
argv
,
char
**
columnNames
)
...
@@ -1716,8 +1716,8 @@ static void find_consumers(fifo_node_t *node)
...
@@ -1716,8 +1716,8 @@ static void find_consumers(fifo_node_t *node)
"order by next_avail, outbound_fail_count, outbound_call_count"
,
"order by next_avail, outbound_fail_count, outbound_call_count"
,
node
->
name
,
(
long
)
switch_epoch_time_now
(
NULL
)
node
->
name
,
(
long
)
switch_epoch_time_now
(
NULL
)
);
);
switch
(
node
->
outbound_strategy
)
{
switch
(
node
->
outbound_strategy
)
{
case
NODE_STRATEGY_ENTERPRISE
:
case
NODE_STRATEGY_ENTERPRISE
:
...
@@ -1743,7 +1743,7 @@ static void find_consumers(fifo_node_t *node)
...
@@ -1743,7 +1743,7 @@ static void find_consumers(fifo_node_t *node)
cbh
=
switch_core_alloc
(
pool
,
sizeof
(
*
cbh
));
cbh
=
switch_core_alloc
(
pool
,
sizeof
(
*
cbh
));
cbh
->
pool
=
pool
;
cbh
->
pool
=
pool
;
cbh
->
need
=
1
;
cbh
->
need
=
1
;
if
(
node
->
outbound_per_cycle
!=
cbh
->
need
)
{
if
(
node
->
outbound_per_cycle
!=
cbh
->
need
)
{
cbh
->
need
=
node
->
outbound_per_cycle
;
cbh
->
need
=
node
->
outbound_per_cycle
;
}
}
...
@@ -1781,11 +1781,11 @@ static void *SWITCH_THREAD_FUNC node_thread_run(switch_thread_t *thread, void *o
...
@@ -1781,11 +1781,11 @@ static void *SWITCH_THREAD_FUNC node_thread_run(switch_thread_t *thread, void *o
void
*
val
;
void
*
val
;
const
void
*
var
;
const
void
*
var
;
int
ppl_waiting
,
consumer_total
,
idle_consumers
,
found
=
0
;
int
ppl_waiting
,
consumer_total
,
idle_consumers
,
found
=
0
;
switch_mutex_lock
(
globals
.
mutex
);
switch_mutex_lock
(
globals
.
mutex
);
if
(
globals
.
debug
)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Trying priority: %d
\n
"
,
cur_priority
);
if
(
globals
.
debug
)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Trying priority: %d
\n
"
,
cur_priority
);
restart:
restart:
...
@@ -1805,7 +1805,7 @@ static void *SWITCH_THREAD_FUNC node_thread_run(switch_thread_t *thread, void *o
...
@@ -1805,7 +1805,7 @@ static void *SWITCH_THREAD_FUNC node_thread_run(switch_thread_t *thread, void *o
switch_event_destroy
(
&
pop
);
switch_event_destroy
(
&
pop
);
}
}
}
}
node
->
ready
=
0
;
node
->
ready
=
0
;
switch_core_hash_destroy
(
&
node
->
consumer_hash
);
switch_core_hash_destroy
(
&
node
->
consumer_hash
);
switch_mutex_unlock
(
node
->
mutex
);
switch_mutex_unlock
(
node
->
mutex
);
...
@@ -1815,7 +1815,7 @@ static void *SWITCH_THREAD_FUNC node_thread_run(switch_thread_t *thread, void *o
...
@@ -1815,7 +1815,7 @@ static void *SWITCH_THREAD_FUNC node_thread_run(switch_thread_t *thread, void *o
goto
restart
;
goto
restart
;
}
}
}
}
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
)
{
...
@@ -1824,12 +1824,12 @@ static void *SWITCH_THREAD_FUNC node_thread_run(switch_thread_t *thread, void *o
...
@@ -1824,12 +1824,12 @@ static void *SWITCH_THREAD_FUNC node_thread_run(switch_thread_t *thread, void *o
idle_consumers
=
node_idle_consumers
(
node
);
idle_consumers
=
node_idle_consumers
(
node
);
if
(
globals
.
debug
)
{
if
(
globals
.
debug
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"%s waiting %d consumer_total %d idle_consumers %d ring_consumers %d pri %d
\n
"
,
"%s waiting %d consumer_total %d idle_consumers %d ring_consumers %d pri %d
\n
"
,
node
->
name
,
ppl_waiting
,
consumer_total
,
idle_consumers
,
node
->
ring_consumer_count
,
node
->
outbound_priority
);
node
->
name
,
ppl_waiting
,
consumer_total
,
idle_consumers
,
node
->
ring_consumer_count
,
node
->
outbound_priority
);
}
}
if
((
ppl_waiting
-
node
->
ring_consumer_count
>
0
)
&&
(
!
consumer_total
||
!
idle_consumers
))
{
if
((
ppl_waiting
-
node
->
ring_consumer_count
>
0
)
&&
(
!
consumer_total
||
!
idle_consumers
))
{
found
++
;
found
++
;
find_consumers
(
node
);
find_consumers
(
node
);
...
@@ -1842,9 +1842,9 @@ static void *SWITCH_THREAD_FUNC node_thread_run(switch_thread_t *thread, void *o
...
@@ -1842,9 +1842,9 @@ static void *SWITCH_THREAD_FUNC node_thread_run(switch_thread_t *thread, void *o
if
(
++
cur_priority
>
10
)
{
if
(
++
cur_priority
>
10
)
{
cur_priority
=
1
;
cur_priority
=
1
;
}
}
switch_mutex_unlock
(
globals
.
mutex
);
switch_mutex_unlock
(
globals
.
mutex
);
if
(
cur_priority
==
1
)
{
if
(
cur_priority
==
1
)
{
switch_yield
(
1000000
);
switch_yield
(
1000000
);
}
}
...
@@ -1891,7 +1891,7 @@ static void check_ocancel(switch_core_session_t *session)
...
@@ -1891,7 +1891,7 @@ static void check_ocancel(switch_core_session_t *session)
static
void
check_cancel
(
fifo_node_t
*
node
)
static
void
check_cancel
(
fifo_node_t
*
node
)
{
{
int
ppl_waiting
;
int
ppl_waiting
;
if
(
node
->
outbound_strategy
!=
NODE_STRATEGY_ENTERPRISE
)
{
if
(
node
->
outbound_strategy
!=
NODE_STRATEGY_ENTERPRISE
)
{
return
;
return
;
...
@@ -1899,13 +1899,13 @@ static void check_cancel(fifo_node_t *node)
...
@@ -1899,13 +1899,13 @@ static void check_cancel(fifo_node_t *node)
ppl_waiting
=
node_caller_count
(
node
);
ppl_waiting
=
node_caller_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), "
"Ending extraneous calls
\n
"
,
node
->
ring_consumer_count
,
node
->
name
,
ppl_waiting
);
"Ending extraneous calls
\n
"
,
node
->
ring_consumer_count
,
node
->
name
,
ppl_waiting
);
switch_core_session_hupall_matching_var
(
"fifo_hangup_check"
,
node
->
name
,
SWITCH_CAUSE_ORIGINATOR_CANCEL
);
switch_core_session_hupall_matching_var
(
"fifo_hangup_check"
,
node
->
name
,
SWITCH_CAUSE_ORIGINATOR_CANCEL
);
}
}
}
}
static
void
send_presence
(
fifo_node_t
*
node
)
static
void
send_presence
(
fifo_node_t
*
node
)
...
@@ -1992,7 +1992,7 @@ static uint32_t fifo_add_outbound(const char *node_name, const char *url, uint32
...
@@ -1992,7 +1992,7 @@ static uint32_t fifo_add_outbound(const char *node_name, const char *url, uint32
switch_event_create
(
&
call_event
,
SWITCH_EVENT_CHANNEL_DATA
);
switch_event_create
(
&
call_event
,
SWITCH_EVENT_CHANNEL_DATA
);
switch_event_add_header_string
(
call_event
,
SWITCH_STACK_BOTTOM
,
"dial-url"
,
url
);
switch_event_add_header_string
(
call_event
,
SWITCH_STACK_BOTTOM
,
"dial-url"
,
url
);
fifo_queue_push
(
node
->
fifo_list
[
priority
],
call_event
);
fifo_queue_push
(
node
->
fifo_list
[
priority
],
call_event
);
call_event
=
NULL
;
call_event
=
NULL
;
...
@@ -2064,9 +2064,9 @@ static void dec_use_count(switch_core_session_t *session, switch_bool_t send_eve
...
@@ -2064,9 +2064,9 @@ static void dec_use_count(switch_core_session_t *session, switch_bool_t send_eve
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
del_bridge_call
(
outbound_id
);
del_bridge_call
(
outbound_id
);
sql
=
switch_mprintf
(
"update fifo_outbound set use_count=use_count-1, stop_time=%ld, next_avail=%ld + lag + 1 where use_count > 0 and uuid='%q'"
,
sql
=
switch_mprintf
(
"update fifo_outbound set use_count=use_count-1, stop_time=%ld, next_avail=%ld + lag + 1 where use_count > 0 and uuid='%q'"
,
now
,
now
,
outbound_id
);
now
,
now
,
outbound_id
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
}
}
...
@@ -2083,9 +2083,9 @@ static void dec_use_count(switch_core_session_t *session, switch_bool_t send_eve
...
@@ -2083,9 +2083,9 @@ static void dec_use_count(switch_core_session_t *session, switch_bool_t send_eve
static
switch_status_t
hanguphook
(
switch_core_session_t
*
session
)
static
switch_status_t
hanguphook
(
switch_core_session_t
*
session
)
{
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
switch_channel_state_t
state
=
switch_channel_get_state
(
channel
);
switch_channel_state_t
state
=
switch_channel_get_state
(
channel
);
if
(
state
>=
CS_HANGUP
&&
!
switch_channel_test_app_flag_key
(
FIFO_APP_KEY
,
channel
,
FIFO_APP_DID_HOOK
))
{
if
(
state
>=
CS_HANGUP
&&
!
switch_channel_test_app_flag_key
(
FIFO_APP_KEY
,
channel
,
FIFO_APP_DID_HOOK
))
{
dec_use_count
(
session
,
SWITCH_TRUE
);
dec_use_count
(
session
,
SWITCH_TRUE
);
switch_core_event_hook_remove_state_change
(
session
,
hanguphook
);
switch_core_event_hook_remove_state_change
(
session
,
hanguphook
);
...
@@ -2101,7 +2101,7 @@ SWITCH_STANDARD_APP(fifo_track_call_function)
...
@@ -2101,7 +2101,7 @@ SWITCH_STANDARD_APP(fifo_track_call_function)
char
*
sql
;
char
*
sql
;
const
char
*
col1
=
NULL
,
*
col2
=
NULL
,
*
cid_name
,
*
cid_number
;
const
char
*
col1
=
NULL
,
*
col2
=
NULL
,
*
cid_name
,
*
cid_number
;
switch_event_t
*
event
;
switch_event_t
*
event
;
if
(
zstr
(
data
))
{
if
(
zstr
(
data
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Invalid!
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Invalid!
\n
"
);
return
;
return
;
...
@@ -2124,7 +2124,7 @@ SWITCH_STANDARD_APP(fifo_track_call_function)
...
@@ -2124,7 +2124,7 @@ SWITCH_STANDARD_APP(fifo_track_call_function)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"%s tracking call on uuid %s!
\n
"
,
switch_channel_get_name
(
channel
),
data
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"%s tracking call on uuid %s!
\n
"
,
switch_channel_get_name
(
channel
),
data
);
if
(
switch_channel_direction
(
channel
)
==
SWITCH_CALL_DIRECTION_OUTBOUND
)
{
if
(
switch_channel_direction
(
channel
)
==
SWITCH_CALL_DIRECTION_OUTBOUND
)
{
col1
=
"manual_calls_in_count"
;
col1
=
"manual_calls_in_count"
;
col2
=
"manual_calls_in_total_count"
;
col2
=
"manual_calls_in_total_count"
;
...
@@ -2133,13 +2133,13 @@ SWITCH_STANDARD_APP(fifo_track_call_function)
...
@@ -2133,13 +2133,13 @@ SWITCH_STANDARD_APP(fifo_track_call_function)
col2
=
"manual_calls_out_total_count"
;
col2
=
"manual_calls_out_total_count"
;
}
}
sql
=
switch_mprintf
(
"update fifo_outbound set stop_time=0,start_time=%ld,outbound_fail_count=0,use_count=use_count+1,%s=%s+1,%s=%s+1 where uuid='%q'"
,
sql
=
switch_mprintf
(
"update fifo_outbound set stop_time=0,start_time=%ld,outbound_fail_count=0,use_count=use_count+1,%s=%s+1,%s=%s+1 where uuid='%q'"
,
(
long
)
switch_epoch_time_now
(
NULL
),
col1
,
col1
,
col2
,
col2
,
data
);
(
long
)
switch_epoch_time_now
(
NULL
),
col1
,
col1
,
col2
,
col2
,
data
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
if
(
switch_channel_direction
(
channel
)
==
SWITCH_CALL_DIRECTION_INBOUND
)
{
if
(
switch_channel_direction
(
channel
)
==
SWITCH_CALL_DIRECTION_INBOUND
)
{
cid_name
=
switch_channel_get_variable
(
channel
,
"destination_number"
);
cid_name
=
switch_channel_get_variable
(
channel
,
"destination_number"
);
cid_number
=
cid_name
;
cid_number
=
cid_name
;
...
@@ -2147,7 +2147,7 @@ SWITCH_STANDARD_APP(fifo_track_call_function)
...
@@ -2147,7 +2147,7 @@ SWITCH_STANDARD_APP(fifo_track_call_function)
cid_name
=
switch_channel_get_variable
(
channel
,
"caller_id_name"
);
cid_name
=
switch_channel_get_variable
(
channel
,
"caller_id_name"
);
cid_number
=
switch_channel_get_variable
(
channel
,
"caller_id_number"
);
cid_number
=
switch_channel_get_variable
(
channel
,
"caller_id_number"
);
}
}
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
FIFO_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_channel_event_set_data
(
channel
,
event
);
switch_channel_event_set_data
(
channel
,
event
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Name"
,
MANUAL_QUEUE_NAME
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"FIFO-Name"
,
MANUAL_QUEUE_NAME
);
...
@@ -2179,16 +2179,16 @@ static void fifo_caller_add(fifo_node_t *node, switch_core_session_t *session)
...
@@ -2179,16 +2179,16 @@ static void fifo_caller_add(fifo_node_t *node, switch_core_session_t *session)
static
void
fifo_caller_del
(
const
char
*
uuid
)
static
void
fifo_caller_del
(
const
char
*
uuid
)
{
{
char
*
sql
;
char
*
sql
;
if
(
uuid
)
{
if
(
uuid
)
{
sql
=
switch_mprintf
(
"delete from fifo_callers where uuid='%q'"
,
uuid
);
sql
=
switch_mprintf
(
"delete from fifo_callers where uuid='%q'"
,
uuid
);
}
else
{
}
else
{
sql
=
switch_mprintf
(
"delete from fifo_callers"
,
uuid
);
sql
=
switch_mprintf
(
"delete from fifo_callers"
,
uuid
);
}
}
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
}
}
...
@@ -2391,7 +2391,7 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2391,7 +2391,7 @@ SWITCH_STANDARD_APP(fifo_function)
switch_event_create
(
&
call_event
,
SWITCH_EVENT_CHANNEL_DATA
);
switch_event_create
(
&
call_event
,
SWITCH_EVENT_CHANNEL_DATA
);
switch_channel_event_set_data
(
channel
,
call_event
);
switch_channel_event_set_data
(
channel
,
call_event
);
fifo_queue_push
(
node
->
fifo_list
[
p
],
call_event
);
fifo_queue_push
(
node
->
fifo_list
[
p
],
call_event
);
fifo_caller_add
(
node
,
session
);
fifo_caller_add
(
node
,
session
);
...
@@ -2634,7 +2634,7 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2634,7 +2634,7 @@ SWITCH_STANDARD_APP(fifo_function)
int
x
=
0
,
winner
=
-
1
;
int
x
=
0
,
winner
=
-
1
;
switch_time_t
longest
=
(
0xFFFFFFFFFFFFFFFFULL
/
2
);
switch_time_t
longest
=
(
0xFFFFFFFFFFFFFFFFULL
/
2
);
uint32_t
importance
=
0
,
waiting
=
0
,
most_waiting
=
0
;
uint32_t
importance
=
0
,
waiting
=
0
,
most_waiting
=
0
;
pop
=
NULL
;
pop
=
NULL
;
if
(
moh
&&
do_wait
)
{
if
(
moh
&&
do_wait
)
{
...
@@ -2686,7 +2686,7 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2686,7 +2686,7 @@ SWITCH_STANDARD_APP(fifo_function)
const
char
*
varval
,
*
check
=
NULL
;
const
char
*
varval
,
*
check
=
NULL
;
check
=
switch_channel_get_variable
(
channel
,
"fifo_bridge_uuid_required"
);
check
=
switch_channel_get_variable
(
channel
,
"fifo_bridge_uuid_required"
);
if
((
varval
=
switch_channel_get_variable
(
channel
,
"fifo_bridge_uuid"
)))
{
if
((
varval
=
switch_channel_get_variable
(
channel
,
"fifo_bridge_uuid"
)))
{
if
(
check_bridge_call
(
varval
)
&&
switch_true
(
check
))
{
if
(
check_bridge_call
(
varval
)
&&
switch_true
(
check
))
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_WARNING
,
"%s Call has already been answered
\n
"
,
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_WARNING
,
"%s Call has already been answered
\n
"
,
...
@@ -2703,14 +2703,14 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2703,14 +2703,14 @@ SWITCH_STANDARD_APP(fifo_function)
if
(
!
pop
&&
switch_true
(
check
))
{
if
(
!
pop
&&
switch_true
(
check
))
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_WARNING
,
"%s Call has already been answered
\n
"
,
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_WARNING
,
"%s Call has already been answered
\n
"
,
switch_channel_get_name
(
channel
));
switch_channel_get_name
(
channel
));
goto
done
;
goto
done
;
}
}
}
}
if
(
!
pop
&&
(
varval
=
switch_channel_get_variable
(
channel
,
"fifo_target_skill"
)))
{
if
(
!
pop
&&
(
varval
=
switch_channel_get_variable
(
channel
,
"fifo_target_skill"
)))
{
for
(
x
=
0
;
x
<
MAX_PRI
;
x
++
)
{
for
(
x
=
0
;
x
<
MAX_PRI
;
x
++
)
{
if
(
fifo_queue_pop_nameval
(
node
->
fifo_list
[
pop_array
[
x
]],
"variable_fifo_skill"
,
if
(
fifo_queue_pop_nameval
(
node
->
fifo_list
[
pop_array
[
x
]],
"variable_fifo_skill"
,
varval
,
&
pop
,
SWITCH_TRUE
)
==
SWITCH_STATUS_SUCCESS
&&
pop
)
{
varval
,
&
pop
,
SWITCH_TRUE
)
==
SWITCH_STATUS_SUCCESS
&&
pop
)
{
break
;
break
;
}
}
...
@@ -2719,7 +2719,7 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2719,7 +2719,7 @@ SWITCH_STANDARD_APP(fifo_function)
if
(
!
pop
)
{
if
(
!
pop
)
{
for
(
x
=
0
;
x
<
MAX_PRI
;
x
++
)
{
for
(
x
=
0
;
x
<
MAX_PRI
;
x
++
)
{
if
(
fifo_queue_pop_nameval
(
node
->
fifo_list
[
pop_array
[
x
]],
"variable_fifo_vip"
,
"true"
,
if
(
fifo_queue_pop_nameval
(
node
->
fifo_list
[
pop_array
[
x
]],
"variable_fifo_vip"
,
"true"
,
&
pop
,
SWITCH_TRUE
)
==
SWITCH_STATUS_SUCCESS
&&
pop
)
{
&
pop
,
SWITCH_TRUE
)
==
SWITCH_STATUS_SUCCESS
&&
pop
)
{
break
;
break
;
}
}
...
@@ -2766,11 +2766,11 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2766,11 +2766,11 @@ SWITCH_STANDARD_APP(fifo_function)
url
=
switch_event_get_header
(
pop
,
"dial-url"
);
url
=
switch_event_get_header
(
pop
,
"dial-url"
);
caller_uuid
=
switch_core_session_strdup
(
session
,
switch_event_get_header
(
pop
,
"unique-id"
));
caller_uuid
=
switch_core_session_strdup
(
session
,
switch_event_get_header
(
pop
,
"unique-id"
));
switch_event_destroy
(
&
pop
);
switch_event_destroy
(
&
pop
);
if
(
url
)
{
if
(
url
)
{
switch_call_cause_t
cause
=
SWITCH_CAUSE_NONE
;
switch_call_cause_t
cause
=
SWITCH_CAUSE_NONE
;
const
char
*
o_announce
=
NULL
;
const
char
*
o_announce
=
NULL
;
if
((
o_announce
=
switch_channel_get_variable
(
channel
,
"fifo_outbound_announce"
)))
{
if
((
o_announce
=
switch_channel_get_variable
(
channel
,
"fifo_outbound_announce"
)))
{
switch_ivr_play_file
(
session
,
NULL
,
o_announce
,
NULL
);
switch_ivr_play_file
(
session
,
NULL
,
o_announce
,
NULL
);
}
}
...
@@ -2846,7 +2846,7 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2846,7 +2846,7 @@ SWITCH_STANDARD_APP(fifo_function)
switch_channel_set_flag
(
other_channel
,
CF_BREAK
);
switch_channel_set_flag
(
other_channel
,
CF_BREAK
);
while
(
switch_channel_ready
(
channel
)
&&
switch_channel_ready
(
other_channel
)
&&
while
(
switch_channel_ready
(
channel
)
&&
switch_channel_ready
(
other_channel
)
&&
switch_channel_test_app_flag_key
(
FIFO_APP_KEY
,
other_channel
,
FIFO_APP_BRIDGE_TAG
))
{
switch_channel_test_app_flag_key
(
FIFO_APP_KEY
,
other_channel
,
FIFO_APP_BRIDGE_TAG
))
{
status
=
switch_core_session_read_frame
(
session
,
&
read_frame
,
SWITCH_IO_FLAG_NONE
,
0
);
status
=
switch_core_session_read_frame
(
session
,
&
read_frame
,
SWITCH_IO_FLAG_NONE
,
0
);
if
(
!
SWITCH_READ_ACCEPTABLE
(
status
))
{
if
(
!
SWITCH_READ_ACCEPTABLE
(
status
))
{
...
@@ -2875,7 +2875,7 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2875,7 +2875,7 @@ SWITCH_STANDARD_APP(fifo_function)
switch_core_session_rwunlock
(
other_session
);
switch_core_session_rwunlock
(
other_session
);
break
;
break
;
}
}
switch_channel_answer
(
channel
);
switch_channel_answer
(
channel
);
cloned_profile
=
switch_caller_profile_clone
(
other_session
,
switch_channel_get_caller_profile
(
channel
));
cloned_profile
=
switch_caller_profile_clone
(
other_session
,
switch_channel_get_caller_profile
(
channel
));
switch_assert
(
cloned_profile
);
switch_assert
(
cloned_profile
);
...
@@ -2930,7 +2930,7 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2930,7 +2930,7 @@ SWITCH_STANDARD_APP(fifo_function)
cancel_consumer_outbound_call
(
outbound_id
,
SWITCH_CAUSE_ORIGINATOR_CANCEL
);
cancel_consumer_outbound_call
(
outbound_id
,
SWITCH_CAUSE_ORIGINATOR_CANCEL
);
add_bridge_call
(
outbound_id
);
add_bridge_call
(
outbound_id
);
sql
=
switch_mprintf
(
"update fifo_outbound set stop_time=0,start_time=%ld,use_count=use_count+1,outbound_fail_count=0 where uuid='%s'"
,
sql
=
switch_mprintf
(
"update fifo_outbound set stop_time=0,start_time=%ld,use_count=use_count+1,outbound_fail_count=0 where uuid='%s'"
,
switch_epoch_time_now
(
NULL
),
outbound_id
);
switch_epoch_time_now
(
NULL
),
outbound_id
);
...
@@ -2952,20 +2952,20 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -2952,20 +2952,20 @@ SWITCH_STANDARD_APP(fifo_function)
switch_str_nil
(
outbound_id
),
switch_str_nil
(
outbound_id
),
(
long
)
switch_epoch_time_now
(
NULL
)
(
long
)
switch_epoch_time_now
(
NULL
)
);
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
switch_ivr_multi_threaded_bridge
(
session
,
other_session
,
on_dtmf
,
other_session
,
session
);
switch_ivr_multi_threaded_bridge
(
session
,
other_session
,
on_dtmf
,
other_session
,
session
);
if
(
outbound_id
)
{
if
(
outbound_id
)
{
long
now
=
(
long
)
switch_epoch_time_now
(
NULL
);
long
now
=
(
long
)
switch_epoch_time_now
(
NULL
);
sql
=
switch_mprintf
(
"update fifo_outbound set stop_time=%ld, use_count=use_count-1, "
sql
=
switch_mprintf
(
"update fifo_outbound set stop_time=%ld, use_count=use_count-1, "
"outbound_call_total_count=outbound_call_total_count+1, "
"outbound_call_total_count=outbound_call_total_count+1, "
"outbound_call_count=outbound_call_count+1, next_avail=%ld + lag + 1 where uuid='%s' and use_count > 0"
,
"outbound_call_count=outbound_call_count+1, next_avail=%ld + lag + 1 where uuid='%s' and use_count > 0"
,
now
,
now
,
outbound_id
);
now
,
now
,
outbound_id
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
...
@@ -3004,7 +3004,7 @@ SWITCH_STANDARD_APP(fifo_function)
...
@@ -3004,7 +3004,7 @@ SWITCH_STANDARD_APP(fifo_function)
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
switch_core_media_bug_pause
(
session
);
switch_core_media_bug_pause
(
session
);
switch_core_media_bug_pause
(
other_session
);
switch_core_media_bug_pause
(
other_session
);
...
@@ -3227,7 +3227,7 @@ static int xml_callback(void *pArg, int argc, char **argv, char **columnNames)
...
@@ -3227,7 +3227,7 @@ static int xml_callback(void *pArg, int argc, char **argv, char **columnNames)
switch_xml_set_attr_d
(
x_out
,
"outbound-call-total-count"
,
argv
[
15
]);
switch_xml_set_attr_d
(
x_out
,
"outbound-call-total-count"
,
argv
[
15
]);
switch_xml_set_attr_d
(
x_out
,
"outbound-fail-total-count"
,
argv
[
16
]);
switch_xml_set_attr_d
(
x_out
,
"outbound-fail-total-count"
,
argv
[
16
]);
if
(
arg
==
17
)
{
if
(
arg
==
17
)
{
switch_xml_set_attr_d
(
x_out
,
"logged-on-since"
,
tb
);
switch_xml_set_attr_d
(
x_out
,
"logged-on-since"
,
tb
);
}
else
{
}
else
{
...
@@ -3238,7 +3238,7 @@ static int xml_callback(void *pArg, int argc, char **argv, char **columnNames)
...
@@ -3238,7 +3238,7 @@ static int xml_callback(void *pArg, int argc, char **argv, char **columnNames)
switch_xml_set_attr_d
(
x_out
,
"manual-calls-in-count"
,
argv
[
20
]);
switch_xml_set_attr_d
(
x_out
,
"manual-calls-in-count"
,
argv
[
20
]);
switch_xml_set_attr_d
(
x_out
,
"manual-calls-out-total-count"
,
argv
[
21
]);
switch_xml_set_attr_d
(
x_out
,
"manual-calls-out-total-count"
,
argv
[
21
]);
switch_xml_set_attr_d
(
x_out
,
"manual-calls-in-total-count"
,
argv
[
22
]);
switch_xml_set_attr_d
(
x_out
,
"manual-calls-in-total-count"
,
argv
[
22
]);
if
(
argc
>
23
)
{
if
(
argc
>
23
)
{
switch_xml_set_attr_d
(
x_out
,
"ring-count"
,
argv
[
23
]);
switch_xml_set_attr_d
(
x_out
,
"ring-count"
,
argv
[
23
]);
...
@@ -3331,7 +3331,7 @@ static int xml_bridge_callback(void *pArg, int argc, char **argv, char **columnN
...
@@ -3331,7 +3331,7 @@ static int xml_bridge_callback(void *pArg, int argc, char **argv, char **columnN
if
((
etime
=
atol
(
argv
[
6
])))
{
if
((
etime
=
atol
(
argv
[
6
])))
{
switch_size_t
retsize
;
switch_size_t
retsize
;
switch_time_exp_lt
(
&
tm
,
switch_time_from_sec
(
etime
));
switch_time_exp_lt
(
&
tm
,
switch_time_from_sec
(
etime
));
switch_strftime_nocheck
(
exp_buf
,
&
retsize
,
sizeof
(
exp_buf
),
"%Y-%m-%d %T"
,
&
tm
);
switch_strftime_nocheck
(
exp_buf
,
&
retsize
,
sizeof
(
exp_buf
),
"%Y-%m-%d %T"
,
&
tm
);
}
else
{
}
else
{
...
@@ -3346,9 +3346,9 @@ static int xml_bridge_callback(void *pArg, int argc, char **argv, char **columnN
...
@@ -3346,9 +3346,9 @@ static int xml_bridge_callback(void *pArg, int argc, char **argv, char **columnN
switch_xml_set_attr_d
(
x_bridge
,
"bridge_start_epoch"
,
argv
[
6
]);
switch_xml_set_attr_d
(
x_bridge
,
"bridge_start_epoch"
,
argv
[
6
]);
x_caller
=
switch_xml_add_child_d
(
x_bridge
,
"caller"
,
tag_off
++
);
x_caller
=
switch_xml_add_child_d
(
x_bridge
,
"caller"
,
tag_off
++
);
switch_xml_set_attr_d
(
x_caller
,
"uuid"
,
argv
[
1
]);
switch_xml_set_attr_d
(
x_caller
,
"uuid"
,
argv
[
1
]);
encoded
=
switch_url_encode
(
argv
[
2
],
url_buf
,
sizeof
(
url_buf
));
encoded
=
switch_url_encode
(
argv
[
2
],
url_buf
,
sizeof
(
url_buf
));
switch_xml_set_attr_d
(
x_caller
,
"caller_id_name"
,
encoded
);
switch_xml_set_attr_d
(
x_caller
,
"caller_id_name"
,
encoded
);
...
@@ -3363,7 +3363,7 @@ static int xml_bridge_callback(void *pArg, int argc, char **argv, char **columnN
...
@@ -3363,7 +3363,7 @@ static int xml_bridge_callback(void *pArg, int argc, char **argv, char **columnN
switch_ivr_generate_xml_cdr
(
session
,
&
x_cdr
);
switch_ivr_generate_xml_cdr
(
session
,
&
x_cdr
);
switch_core_session_rwunlock
(
session
);
switch_core_session_rwunlock
(
session
);
}
}
}
}
off
=
0
;
off
=
0
;
...
@@ -3417,7 +3417,7 @@ static int xml_hash(switch_xml_t xml, switch_hash_t *hash, char *container, char
...
@@ -3417,7 +3417,7 @@ static int xml_hash(switch_xml_t xml, switch_hash_t *hash, char *container, char
switch_channel_t
*
channel
;
switch_channel_t
*
channel
;
void
*
val
;
void
*
val
;
const
void
*
var
;
const
void
*
var
;
x_tmp
=
switch_xml_add_child_d
(
xml
,
container
,
cc_off
++
);
x_tmp
=
switch_xml_add_child_d
(
xml
,
container
,
cc_off
++
);
switch_assert
(
x_tmp
);
switch_assert
(
x_tmp
);
...
@@ -3439,7 +3439,7 @@ static int xml_hash(switch_xml_t xml, switch_hash_t *hash, char *container, char
...
@@ -3439,7 +3439,7 @@ static int xml_hash(switch_xml_t xml, switch_hash_t *hash, char *container, char
if
((
status
=
switch_channel_get_variable
(
channel
,
"fifo_status"
)))
{
if
((
status
=
switch_channel_get_variable
(
channel
,
"fifo_status"
)))
{
switch_xml_set_attr_d
(
x_caller
,
"status"
,
status
);
switch_xml_set_attr_d
(
x_caller
,
"status"
,
status
);
}
}
if
((
status
=
switch_channel_get_variable
(
channel
,
"caller_id_name"
)))
{
if
((
status
=
switch_channel_get_variable
(
channel
,
"caller_id_name"
)))
{
encoded
=
switch_url_encode
(
status
,
url_buf
,
sizeof
(
url_buf
));
encoded
=
switch_url_encode
(
status
,
url_buf
,
sizeof
(
url_buf
));
switch_xml_set_attr_d
(
x_caller
,
"caller_id_name"
,
encoded
);
switch_xml_set_attr_d
(
x_caller
,
"caller_id_name"
,
encoded
);
...
@@ -3487,7 +3487,7 @@ static int xml_caller(switch_xml_t xml, fifo_node_t *node, char *container, char
...
@@ -3487,7 +3487,7 @@ static int xml_caller(switch_xml_t xml, fifo_node_t *node, char *container, char
switch_mutex_lock
(
q
->
mutex
);
switch_mutex_lock
(
q
->
mutex
);
for
(
i
=
0
;
i
<
q
->
idx
;
i
++
)
{
for
(
i
=
0
;
i
<
q
->
idx
;
i
++
)
{
int
c_off
=
0
,
d_off
=
0
;
int
c_off
=
0
,
d_off
=
0
;
const
char
*
status
;
const
char
*
status
;
const
char
*
ts
;
const
char
*
ts
;
...
@@ -3495,7 +3495,7 @@ static int xml_caller(switch_xml_t xml, fifo_node_t *node, char *container, char
...
@@ -3495,7 +3495,7 @@ static int xml_caller(switch_xml_t xml, fifo_node_t *node, char *container, char
char
sl
[
30
]
=
""
;
char
sl
[
30
]
=
""
;
char
url_buf
[
512
]
=
""
;
char
url_buf
[
512
]
=
""
;
char
*
encoded
;
char
*
encoded
;
if
(
!
uuid
)
{
if
(
!
uuid
)
{
continue
;
continue
;
}
}
...
@@ -3518,7 +3518,7 @@ static int xml_caller(switch_xml_t xml, fifo_node_t *node, char *container, char
...
@@ -3518,7 +3518,7 @@ static int xml_caller(switch_xml_t xml, fifo_node_t *node, char *container, char
encoded
=
switch_url_encode
(
status
,
url_buf
,
sizeof
(
url_buf
));
encoded
=
switch_url_encode
(
status
,
url_buf
,
sizeof
(
url_buf
));
switch_xml_set_attr_d
(
x_caller
,
"caller_id_name"
,
encoded
);
switch_xml_set_attr_d
(
x_caller
,
"caller_id_name"
,
encoded
);
}
}
if
((
status
=
switch_channel_get_variable
(
channel
,
"caller_id_number"
)))
{
if
((
status
=
switch_channel_get_variable
(
channel
,
"caller_id_number"
)))
{
encoded
=
switch_url_encode
(
status
,
url_buf
,
sizeof
(
url_buf
));
encoded
=
switch_url_encode
(
status
,
url_buf
,
sizeof
(
url_buf
));
switch_xml_set_attr_d
(
x_caller
,
"caller_id_number"
,
encoded
);
switch_xml_set_attr_d
(
x_caller
,
"caller_id_number"
,
encoded
);
...
@@ -3544,7 +3544,7 @@ static int xml_caller(switch_xml_t xml, fifo_node_t *node, char *container, char
...
@@ -3544,7 +3544,7 @@ static int xml_caller(switch_xml_t xml, fifo_node_t *node, char *container, char
if
(
!
(
x_cp
=
switch_xml_add_child_d
(
x_caller
,
"cdr"
,
d_off
++
)))
{
if
(
!
(
x_cp
=
switch_xml_add_child_d
(
x_caller
,
"cdr"
,
d_off
++
)))
{
abort
();
abort
();
}
}
switch_ivr_generate_xml_cdr
(
session
,
&
x_cp
);
switch_ivr_generate_xml_cdr
(
session
,
&
x_cp
);
}
}
...
@@ -3634,7 +3634,7 @@ void node_dump(switch_stream_handle_t *stream)
...
@@ -3634,7 +3634,7 @@ void node_dump(switch_stream_handle_t *stream)
" busy: %d
\n
"
" busy: %d
\n
"
" ready: %d
\n
"
" ready: %d
\n
"
" waiting: %d
\n
"
" waiting: %d
\n
"
,
,
node
->
name
,
node
->
outbound_name
,
node
->
outbound_per_cycle
,
node
->
name
,
node
->
outbound_name
,
node
->
outbound_per_cycle
,
node
->
outbound_priority
,
strat_parse
(
node
->
outbound_strategy
),
node
->
outbound_priority
,
strat_parse
(
node
->
outbound_strategy
),
node
->
has_outbound
,
node
->
has_outbound
,
...
@@ -3642,7 +3642,7 @@ void node_dump(switch_stream_handle_t *stream)
...
@@ -3642,7 +3642,7 @@ void node_dump(switch_stream_handle_t *stream)
node
->
busy
,
node
->
busy
,
node
->
ready
,
node
->
ready
,
node_caller_count
(
node
)
node_caller_count
(
node
)
);
);
}
}
}
}
...
@@ -3653,10 +3653,10 @@ void node_dump(switch_stream_handle_t *stream)
...
@@ -3653,10 +3653,10 @@ void node_dump(switch_stream_handle_t *stream)
dump_hash
(
globals
.
consumer_orig_hash
,
stream
);
dump_hash
(
globals
.
consumer_orig_hash
,
stream
);
stream
->
write_function
(
stream
,
" bridge:
\n
"
);
stream
->
write_function
(
stream
,
" bridge:
\n
"
);
dump_hash
(
globals
.
bridge_hash
,
stream
);
dump_hash
(
globals
.
bridge_hash
,
stream
);
switch_mutex_unlock
(
globals
.
mutex
);
switch_mutex_unlock
(
globals
.
mutex
);
}
}
...
@@ -3693,7 +3693,7 @@ SWITCH_STANDARD_API(fifo_api_function)
...
@@ -3693,7 +3693,7 @@ SWITCH_STANDARD_API(fifo_api_function)
if
(
!
strcasecmp
(
argv
[
0
],
"status"
))
{
if
(
!
strcasecmp
(
argv
[
0
],
"status"
))
{
node_dump
(
stream
);
node_dump
(
stream
);
goto
done
;
goto
done
;
}
}
if
(
!
strcasecmp
(
argv
[
0
],
"debug"
))
{
if
(
!
strcasecmp
(
argv
[
0
],
"debug"
))
{
...
@@ -3703,7 +3703,7 @@ SWITCH_STANDARD_API(fifo_api_function)
...
@@ -3703,7 +3703,7 @@ SWITCH_STANDARD_API(fifo_api_function)
}
}
}
}
stream
->
write_function
(
stream
,
"debug %d
\n
"
,
globals
.
debug
);
stream
->
write_function
(
stream
,
"debug %d
\n
"
,
globals
.
debug
);
goto
done
;
goto
done
;
}
}
verbose
=
!
strcasecmp
(
argv
[
0
],
"list_verbose"
);
verbose
=
!
strcasecmp
(
argv
[
0
],
"list_verbose"
);
...
@@ -3874,11 +3874,11 @@ static void extract_fifo_outbound_uuid(char *string, char *uuid, switch_size_t l
...
@@ -3874,11 +3874,11 @@ static void extract_fifo_outbound_uuid(char *string, char *uuid, switch_size_t l
switch_event_t
*
ovars
;
switch_event_t
*
ovars
;
char
*
parsed
=
NULL
;
char
*
parsed
=
NULL
;
const
char
*
fifo_outbound_uuid
;
const
char
*
fifo_outbound_uuid
;
switch_event_create
(
&
ovars
,
SWITCH_EVENT_REQUEST_PARAMS
);
switch_event_create
(
&
ovars
,
SWITCH_EVENT_REQUEST_PARAMS
);
switch_event_create_brackets
(
string
,
'{'
,
'}'
,
','
,
&
ovars
,
&
parsed
,
SWITCH_TRUE
);
switch_event_create_brackets
(
string
,
'{'
,
'}'
,
','
,
&
ovars
,
&
parsed
,
SWITCH_TRUE
);
if
((
fifo_outbound_uuid
=
switch_event_get_header
(
ovars
,
"fifo_outbound_uuid"
)))
{
if
((
fifo_outbound_uuid
=
switch_event_get_header
(
ovars
,
"fifo_outbound_uuid"
)))
{
switch_snprintf
(
uuid
,
len
,
"%s"
,
fifo_outbound_uuid
);
switch_snprintf
(
uuid
,
len
,
"%s"
,
fifo_outbound_uuid
);
}
}
...
@@ -3946,7 +3946,7 @@ static switch_status_t load_config(int reload, int del_all)
...
@@ -3946,7 +3946,7 @@ static switch_status_t load_config(int reload, int del_all)
}
}
if
(
!
reload
)
{
if
(
!
reload
)
{
switch_cache_db_test_reactive
(
dbh
,
"delete from fifo_outbound where static = 1 or taking_calls < 0 or stop_time < 0"
,
switch_cache_db_test_reactive
(
dbh
,
"delete from fifo_outbound where static = 1 or taking_calls < 0 or stop_time < 0"
,
"drop table fifo_outbound"
,
outbound_sql
);
"drop table fifo_outbound"
,
outbound_sql
);
switch_cache_db_test_reactive
(
dbh
,
"delete from fifo_bridge"
,
"drop table fifo_bridge"
,
bridge_sql
);
switch_cache_db_test_reactive
(
dbh
,
"delete from fifo_bridge"
,
"drop table fifo_bridge"
,
bridge_sql
);
switch_cache_db_test_reactive
(
dbh
,
"delete from fifo_callers"
,
"drop table fifo_callers"
,
callers_sql
);
switch_cache_db_test_reactive
(
dbh
,
"delete from fifo_callers"
,
"drop table fifo_callers"
,
callers_sql
);
...
@@ -4032,9 +4032,9 @@ static switch_status_t load_config(int reload, int del_all)
...
@@ -4032,9 +4032,9 @@ static switch_status_t load_config(int reload, int del_all)
switch_assert
(
node
);
switch_assert
(
node
);
switch_mutex_lock
(
node
->
mutex
);
switch_mutex_lock
(
node
->
mutex
);
outbound_strategy
=
switch_xml_attr
(
fifo
,
"outbound_strategy"
);
outbound_strategy
=
switch_xml_attr
(
fifo
,
"outbound_strategy"
);
if
((
val
=
switch_xml_attr
(
fifo
,
"outbound_per_cycle"
)))
{
if
((
val
=
switch_xml_attr
(
fifo
,
"outbound_per_cycle"
)))
{
if
((
outbound_per_cycle
=
atoi
(
val
))
<
0
)
{
if
((
outbound_per_cycle
=
atoi
(
val
))
<
0
)
{
...
@@ -4051,7 +4051,7 @@ static switch_status_t load_config(int reload, int del_all)
...
@@ -4051,7 +4051,7 @@ static switch_status_t load_config(int reload, int del_all)
}
}
node
->
has_outbound
=
1
;
node
->
has_outbound
=
1
;
}
}
if
((
val
=
switch_xml_attr
(
fifo
,
"outbound_ring_timeout"
)))
{
if
((
val
=
switch_xml_attr
(
fifo
,
"outbound_ring_timeout"
)))
{
int
tmp
=
atoi
(
val
);
int
tmp
=
atoi
(
val
);
if
(
tmp
>
10
)
{
if
(
tmp
>
10
)
{
...
@@ -4074,7 +4074,7 @@ static switch_status_t load_config(int reload, int del_all)
...
@@ -4074,7 +4074,7 @@ static switch_status_t load_config(int reload, int del_all)
node
->
outbound_per_cycle
=
outbound_per_cycle
;
node
->
outbound_per_cycle
=
outbound_per_cycle
;
node
->
outbound_priority
=
outbound_priority
;
node
->
outbound_priority
=
outbound_priority
;
node
->
default_lag
=
default_lag
;
node
->
default_lag
=
default_lag
;
if
(
outbound_strategy
)
{
if
(
outbound_strategy
)
{
node
->
outbound_strategy
=
parse_strat
(
outbound_strategy
);
node
->
outbound_strategy
=
parse_strat
(
outbound_strategy
);
node
->
has_outbound
=
1
;
node
->
has_outbound
=
1
;
...
@@ -4093,7 +4093,7 @@ static switch_status_t load_config(int reload, int del_all)
...
@@ -4093,7 +4093,7 @@ static switch_status_t load_config(int reload, int del_all)
}
else
{
}
else
{
switch_md5_string
(
digest
,
(
void
*
)
member
->
txt
,
strlen
(
member
->
txt
));
switch_md5_string
(
digest
,
(
void
*
)
member
->
txt
,
strlen
(
member
->
txt
));
}
}
if
(
simo
)
{
if
(
simo
)
{
simo_i
=
atoi
(
simo
);
simo_i
=
atoi
(
simo
);
}
}
...
@@ -4130,7 +4130,7 @@ static switch_status_t load_config(int reload, int del_all)
...
@@ -4130,7 +4130,7 @@ static switch_status_t load_config(int reload, int del_all)
"values ('%q','%q','%q',%d,%d,%d,%d,0,0,1,0,0,'%q',%d,%ld,0)"
,
"values ('%q','%q','%q',%d,%d,%d,%d,0,0,1,0,0,'%q',%d,%ld,0)"
,
digest
,
node
->
name
,
member
->
txt
,
simo_i
,
0
,
timeout_i
,
lag_i
,
globals
.
hostname
,
taking_calls_i
,
digest
,
node
->
name
,
member
->
txt
,
simo_i
,
0
,
timeout_i
,
lag_i
,
globals
.
hostname
,
taking_calls_i
,
(
long
)
switch_epoch_time_now
(
NULL
));
(
long
)
switch_epoch_time_now
(
NULL
));
switch_assert
(
sql
);
switch_assert
(
sql
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
free
(
sql
);
free
(
sql
);
...
@@ -4205,7 +4205,7 @@ static void fifo_member_add(char *fifo_name, char *originate_string, int simo_co
...
@@ -4205,7 +4205,7 @@ static void fifo_member_add(char *fifo_name, char *originate_string, int simo_co
if
(
switch_stristr
(
"fifo_outbound_uuid="
,
originate_string
))
{
if
(
switch_stristr
(
"fifo_outbound_uuid="
,
originate_string
))
{
extract_fifo_outbound_uuid
(
originate_string
,
digest
,
sizeof
(
digest
));
extract_fifo_outbound_uuid
(
originate_string
,
digest
,
sizeof
(
digest
));
}
else
{
}
else
{
switch_md5_string
(
digest
,
(
void
*
)
originate_string
,
strlen
(
originate_string
));
switch_md5_string
(
digest
,
(
void
*
)
originate_string
,
strlen
(
originate_string
));
}
}
sql
=
switch_mprintf
(
"delete from fifo_outbound where fifo_name='%q' and uuid = '%q'"
,
fifo_name
,
digest
);
sql
=
switch_mprintf
(
"delete from fifo_outbound where fifo_name='%q' and uuid = '%q'"
,
fifo_name
,
digest
);
...
@@ -4255,7 +4255,7 @@ static void fifo_member_del(char *fifo_name, char *originate_string)
...
@@ -4255,7 +4255,7 @@ static void fifo_member_del(char *fifo_name, char *originate_string)
if
(
switch_stristr
(
"fifo_outbound_uuid="
,
originate_string
))
{
if
(
switch_stristr
(
"fifo_outbound_uuid="
,
originate_string
))
{
extract_fifo_outbound_uuid
(
originate_string
,
digest
,
sizeof
(
digest
));
extract_fifo_outbound_uuid
(
originate_string
,
digest
,
sizeof
(
digest
));
}
else
{
}
else
{
switch_md5_string
(
digest
,
(
void
*
)
originate_string
,
strlen
(
originate_string
));
switch_md5_string
(
digest
,
(
void
*
)
originate_string
,
strlen
(
originate_string
));
}
}
sql
=
switch_mprintf
(
"delete from fifo_outbound where fifo_name='%q' and uuid = '%q' and hostname='%q'"
,
fifo_name
,
digest
,
globals
.
hostname
);
sql
=
switch_mprintf
(
"delete from fifo_outbound where fifo_name='%q' and uuid = '%q' and hostname='%q'"
,
fifo_name
,
digest
,
globals
.
hostname
);
...
@@ -4275,11 +4275,11 @@ static void fifo_member_del(char *fifo_name, char *originate_string)
...
@@ -4275,11 +4275,11 @@ static void fifo_member_del(char *fifo_name, char *originate_string)
sql
=
switch_mprintf
(
"select count(*) from fifo_outbound where fifo_name = '%q'"
,
node
->
name
);
sql
=
switch_mprintf
(
"select count(*) from fifo_outbound where fifo_name = '%q'"
,
node
->
name
);
fifo_execute_sql_callback
(
globals
.
sql_mutex
,
sql
,
sql2str_callback
,
&
cbt
);
fifo_execute_sql_callback
(
globals
.
sql_mutex
,
sql
,
sql2str_callback
,
&
cbt
);
if
(
atoi
(
outbound_count
)
>
0
)
{
if
(
atoi
(
outbound_count
)
>
0
)
{
node
->
has_outbound
=
1
;
node
->
has_outbound
=
1
;
}
else
{
}
else
{
node
->
has_outbound
=
0
;
node
->
has_outbound
=
0
;
}
}
switch_safe_free
(
sql
);
switch_safe_free
(
sql
);
}
}
#define FIFO_MEMBER_API_SYNTAX "[add <fifo_name> <originate_string> [<simo_count>] [<timeout>] [<lag>] [<expires>] [<taking_calls>] | del <fifo_name> <originate_string>]"
#define FIFO_MEMBER_API_SYNTAX "[add <fifo_name> <originate_string> [<simo_count>] [<timeout>] [<lag>] [<expires>] [<taking_calls>] | del <fifo_name> <originate_string>]"
...
@@ -4410,7 +4410,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_fifo_load)
...
@@ -4410,7 +4410,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_fifo_load)
/* connect my internal structure to the blank pointer passed to me */
/* connect my internal structure to the blank pointer passed to me */
*
module_interface
=
switch_loadable_module_create_module_interface
(
pool
,
modname
);
*
module_interface
=
switch_loadable_module_create_module_interface
(
pool
,
modname
);
SWITCH_ADD_APP
(
app_interface
,
"fifo"
,
"Park with FIFO"
,
FIFO_DESC
,
fifo_function
,
FIFO_USAGE
,
SAF_NONE
);
SWITCH_ADD_APP
(
app_interface
,
"fifo"
,
"Park with FIFO"
,
FIFO_DESC
,
fifo_function
,
FIFO_USAGE
,
SAF_NONE
);
SWITCH_ADD_APP
(
app_interface
,
"fifo_track_call"
,
"Count a call as a fifo call in the manual_calls queue"
,
SWITCH_ADD_APP
(
app_interface
,
"fifo_track_call"
,
"Count a call as a fifo call in the manual_calls queue"
,
""
,
fifo_track_call_function
,
"<fifo_outbound_uuid>"
,
SAF_SUPPORT_NOMEDIA
);
""
,
fifo_track_call_function
,
"<fifo_outbound_uuid>"
,
SAF_SUPPORT_NOMEDIA
);
SWITCH_ADD_API
(
commands_api_interface
,
"fifo"
,
"Return data about a fifo"
,
fifo_api_function
,
FIFO_API_SYNTAX
);
SWITCH_ADD_API
(
commands_api_interface
,
"fifo"
,
"Return data about a fifo"
,
fifo_api_function
,
FIFO_API_SYNTAX
);
SWITCH_ADD_API
(
commands_api_interface
,
"fifo_member"
,
"Add members to a fifo"
,
fifo_member_api_function
,
FIFO_MEMBER_API_SYNTAX
);
SWITCH_ADD_API
(
commands_api_interface
,
"fifo_member"
,
"Add members to a fifo"
,
fifo_member_api_function
,
FIFO_MEMBER_API_SYNTAX
);
...
@@ -4429,7 +4429,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_fifo_load)
...
@@ -4429,7 +4429,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_fifo_load)
}
}
/*
/*
Called when the system shuts down
Called when the system shuts down
*/
*/
SWITCH_MODULE_SHUTDOWN_FUNCTION
(
mod_fifo_shutdown
)
SWITCH_MODULE_SHUTDOWN_FUNCTION
(
mod_fifo_shutdown
)
{
{
...
@@ -4448,7 +4448,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_fifo_shutdown)
...
@@ -4448,7 +4448,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_fifo_shutdown)
/* Cleanup */
/* Cleanup */
stop_node_thread
();
stop_node_thread
();
while
(
globals
.
threads
)
{
while
(
globals
.
threads
)
{
switch_cond_next
();
switch_cond_next
();
}
}
...
@@ -4476,7 +4476,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_fifo_shutdown)
...
@@ -4476,7 +4476,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_fifo_shutdown)
switch_core_hash_destroy
(
&
globals
.
fifo_hash
);
switch_core_hash_destroy
(
&
globals
.
fifo_hash
);
memset
(
&
globals
,
0
,
sizeof
(
globals
));
memset
(
&
globals
,
0
,
sizeof
(
globals
));
switch_mutex_unlock
(
mutex
);
switch_mutex_unlock
(
mutex
);
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论