Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
e5ddafff
提交
e5ddafff
authored
10月 08, 2012
作者:
Eliot Gable
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
ssh://git.freeswitch.org:222/freeswitch
上级
7d7eaee9
93f4c0f6
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
51 行增加
和
63 行删除
+51
-63
sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_glue.c
+27
-33
sofia_reg.c
src/mod/endpoints/mod_sofia/sofia_reg.c
+24
-30
没有找到文件。
src/mod/endpoints/mod_sofia/sofia_glue.c
浏览文件 @
e5ddafff
...
...
@@ -6394,18 +6394,16 @@ void sofia_glue_actually_execute_sql_trans(sofia_profile_t *profile, char *sql,
{
switch_cache_db_handle_t
*
dbh
=
NULL
;
if
(
mutex
)
{
switch_mutex_lock
(
mutex
);
}
if
(
!
(
dbh
=
sofia_glue_get_db_handle
(
profile
)))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Error Opening DB
\n
"
);
goto
end
;
return
;
}
switch_cache_db_persistant_execute_trans
(
dbh
,
sql
,
1
);
if
(
mutex
)
{
switch_mutex_lock
(
mutex
);
}
end
:
switch_cache_db_persistant_execute_trans
(
dbh
,
sql
,
1
);
switch_cache_db_release_db_handle
(
&
dbh
);
...
...
@@ -6419,29 +6417,27 @@ void sofia_glue_actually_execute_sql(sofia_profile_t *profile, char *sql, switch
switch_cache_db_handle_t
*
dbh
=
NULL
;
char
*
err
=
NULL
;
if
(
mutex
)
{
switch_mutex_lock
(
mutex
);
}
if
(
!
(
dbh
=
sofia_glue_get_db_handle
(
profile
)))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Error Opening DB
\n
"
);
goto
end
;
return
;
}
if
(
mutex
)
{
switch_mutex_lock
(
mutex
);
}
switch_cache_db_execute_sql
(
dbh
,
sql
,
&
err
);
if
(
mutex
)
{
switch_mutex_unlock
(
mutex
);
}
if
(
err
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"SQL ERR: [%s]
\n
%s
\n
"
,
err
,
sql
);
free
(
err
);
}
end
:
switch_cache_db_release_db_handle
(
&
dbh
);
if
(
mutex
)
{
switch_mutex_unlock
(
mutex
);
}
}
switch_bool_t
sofia_glue_execute_sql_callback
(
sofia_profile_t
*
profile
,
...
...
@@ -6451,30 +6447,28 @@ switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile,
char
*
errmsg
=
NULL
;
switch_cache_db_handle_t
*
dbh
=
NULL
;
if
(
mutex
)
{
switch_mutex_lock
(
mutex
);
}
if
(
!
(
dbh
=
sofia_glue_get_db_handle
(
profile
)))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Error Opening DB
\n
"
);
goto
end
;
return
ret
;
}
if
(
mutex
)
{
switch_mutex_lock
(
mutex
);
}
switch_cache_db_execute_sql_callback
(
dbh
,
sql
,
callback
,
pdata
,
&
errmsg
);
if
(
mutex
)
{
switch_mutex_unlock
(
mutex
);
}
if
(
errmsg
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"SQL ERR: [%s] %s
\n
"
,
sql
,
errmsg
);
free
(
errmsg
);
}
end
:
switch_cache_db_release_db_handle
(
&
dbh
);
if
(
mutex
)
{
switch_mutex_unlock
(
mutex
);
}
return
ret
;
}
...
...
@@ -6495,15 +6489,15 @@ char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex
ret
=
switch_cache_db_execute_sql2str
(
dbh
,
sql
,
resbuf
,
len
,
&
err
);
if
(
mutex
)
{
switch_mutex_unlock
(
mutex
);
}
if
(
err
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"SQL ERR: [%s]
\n
%s
\n
"
,
err
,
sql
);
free
(
err
);
}
if
(
mutex
)
{
switch_mutex_unlock
(
mutex
);
}
switch_cache_db_release_db_handle
(
&
dbh
);
return
ret
;
...
...
src/mod/endpoints/mod_sofia/sofia_reg.c
浏览文件 @
e5ddafff
...
...
@@ -690,9 +690,8 @@ void sofia_reg_expire_call_id(sofia_profile_t *profile, const char *call_id, int
",user_agent,server_user,server_host,profile_name,network_ip"
",%d from sip_registrations where call_id='%q' %s"
,
reboot
,
call_id
,
sqlextra
);
switch_mutex_lock
(
profile
->
ireg_mutex
);
sofia_glue_execute_sql_callback
(
profile
,
NULL
,
sql
,
sofia_reg_del_callback
,
profile
);
switch_mutex_unlock
(
profile
->
ireg_mutex
);
sofia_glue_execute_sql_callback
(
profile
,
profile
->
ireg_mutex
,
sql
,
sofia_reg_del_callback
,
profile
);
switch_safe_free
(
sql
);
sql
=
switch_mprintf
(
"delete from sip_registrations where call_id='%q' %s"
,
call_id
,
sqlextra
);
...
...
@@ -708,7 +707,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
{
char
sql
[
1024
];
switch_mutex_lock
(
profile
->
ireg_mutex
);
if
(
now
)
{
switch_snprintf
(
sql
,
sizeof
(
sql
),
"select call_id,sip_user,sip_host,contact,status,rpid,expires"
...
...
@@ -719,7 +718,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
",user_agent,server_user,server_host,profile_name,network_ip"
",%d from sip_registrations where expires > 0"
,
reboot
);
}
sofia_glue_execute_sql_callback
(
profile
,
NULL
,
sql
,
sofia_reg_del_callback
,
profile
);
sofia_glue_execute_sql_callback
(
profile
,
profile
->
ireg_mutex
,
sql
,
sofia_reg_del_callback
,
profile
);
if
(
now
)
{
switch_snprintfv
(
sql
,
sizeof
(
sql
),
"delete from sip_registrations where expires > 0 and expires <= %ld and hostname='%q'"
,
(
long
)
now
,
mod_sofia_globals
.
hostname
);
...
...
@@ -727,7 +726,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
switch_snprintfv
(
sql
,
sizeof
(
sql
),
"delete from sip_registrations where expires > 0 and hostname='%q'"
,
mod_sofia_globals
.
hostname
);
}
sofia_glue_actually_execute_sql
(
profile
,
sql
,
NULL
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
profile
->
ireg_mutex
);
...
...
@@ -735,12 +734,12 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
switch_snprintfv
(
sql
,
sizeof
(
sql
),
"select call_id from sip_shared_appearance_dialogs where hostname='%q' "
"and profile_name='%s' and expires <= %ld"
,
mod_sofia_globals
.
hostname
,
profile
->
name
,
(
long
)
now
);
sofia_glue_execute_sql_callback
(
profile
,
NULL
,
sql
,
sofia_sla_dialog_del_callback
,
profile
);
sofia_glue_execute_sql_callback
(
profile
,
profile
->
ireg_mutex
,
sql
,
sofia_sla_dialog_del_callback
,
profile
);
switch_snprintfv
(
sql
,
sizeof
(
sql
),
"delete from sip_shared_appearance_dialogs where expires > 0 and hostname='%q' and expires <= %ld"
,
mod_sofia_globals
.
hostname
,
(
long
)
now
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
NULL
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
profile
->
ireg_mutex
);
}
...
...
@@ -751,7 +750,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
switch_snprintfv
(
sql
,
sizeof
(
sql
),
"delete from sip_presence where expires > 0 and hostname='%q'"
,
mod_sofia_globals
.
hostname
);
}
sofia_glue_actually_execute_sql
(
profile
,
sql
,
NULL
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
profile
->
ireg_mutex
);
if
(
now
)
{
switch_snprintfv
(
sql
,
sizeof
(
sql
),
"delete from sip_authentication where expires > 0 and expires <= %ld and hostname='%q'"
,
...
...
@@ -760,7 +759,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
switch_snprintfv
(
sql
,
sizeof
(
sql
),
"delete from sip_authentication where expires > 0 and hostname='%q'"
,
mod_sofia_globals
.
hostname
);
}
sofia_glue_actually_execute_sql
(
profile
,
sql
,
NULL
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
profile
->
ireg_mutex
);
sofia_presence_check_subscriptions
(
profile
,
now
);
...
...
@@ -771,7 +770,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
switch_snprintfv
(
sql
,
sizeof
(
sql
),
"delete from sip_dialogs where expires >= -1 and hostname='%q'"
,
mod_sofia_globals
.
hostname
);
}
sofia_glue_actually_execute_sql
(
profile
,
sql
,
NULL
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
profile
->
ireg_mutex
);
if
(
now
)
{
...
...
@@ -781,7 +780,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
" from sip_registrations where hostname='%s' and "
"profile_name='%s'"
,
mod_sofia_globals
.
hostname
,
profile
->
name
);
sofia_glue_execute_sql_callback
(
profile
,
NULL
,
sql
,
sofia_reg_nat_callback
,
profile
);
sofia_glue_execute_sql_callback
(
profile
,
profile
->
ireg_mutex
,
sql
,
sofia_reg_nat_callback
,
profile
);
}
else
if
(
sofia_test_pflag
(
profile
,
PFLAG_NAT_OPTIONS_PING
))
{
switch_snprintf
(
sql
,
sizeof
(
sql
),
"select call_id,sip_user,sip_host,contact,status,rpid,"
"expires,user_agent,server_user,server_host,profile_name"
...
...
@@ -789,12 +788,10 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot)
"or contact like '%%fs_nat=yes%%') and hostname='%s' "
"and profile_name='%s'"
,
mod_sofia_globals
.
hostname
,
profile
->
name
);
sofia_glue_execute_sql_callback
(
profile
,
NULL
,
sql
,
sofia_reg_nat_callback
,
profile
);
sofia_glue_execute_sql_callback
(
profile
,
profile
->
ireg_mutex
,
sql
,
sofia_reg_nat_callback
,
profile
);
}
}
switch_mutex_unlock
(
profile
->
ireg_mutex
);
}
...
...
@@ -837,9 +834,9 @@ void sofia_reg_check_call_id(sofia_profile_t *profile, const char *call_id)
",user_agent,server_user,server_host,profile_name,network_ip"
" from sip_registrations where call_id='%q' %s"
,
call_id
,
sqlextra
);
switch_mutex_lock
(
profile
->
ireg_mutex
);
sofia_glue_execute_sql_callback
(
profile
,
NULL
,
sql
,
sofia_reg_check_callback
,
profile
);
switch_mutex_unlock
(
profile
->
ireg_mutex
);
sofia_glue_execute_sql_callback
(
profile
,
profile
->
ireg_mutex
,
sql
,
sofia_reg_check_callback
,
profile
);
switch_safe_free
(
sql
);
switch_safe_free
(
sqlextra
);
...
...
@@ -851,31 +848,28 @@ void sofia_reg_check_sync(sofia_profile_t *profile)
{
char
sql
[
1024
];
switch_mutex_lock
(
profile
->
ireg_mutex
);
switch_snprintf
(
sql
,
sizeof
(
sql
),
"select call_id,sip_user,sip_host,contact,status,rpid,expires"
",user_agent,server_user,server_host,profile_name,network_ip"
" from sip_registrations where expires > 0"
);
sofia_glue_execute_sql_callback
(
profile
,
NULL
,
sql
,
sofia_reg_del_callback
,
profile
);
sofia_glue_execute_sql_callback
(
profile
,
profile
->
ireg_mutex
,
sql
,
sofia_reg_del_callback
,
profile
);
switch_snprintfv
(
sql
,
sizeof
(
sql
),
"delete from sip_registrations where expires > 0 and hostname='%q'"
,
mod_sofia_globals
.
hostname
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
NULL
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
profile
->
ireg_mutex
);
switch_snprintfv
(
sql
,
sizeof
(
sql
),
"delete from sip_presence where expires > 0 and hostname='%q'"
,
mod_sofia_globals
.
hostname
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
NULL
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
profile
->
ireg_mutex
);
switch_snprintfv
(
sql
,
sizeof
(
sql
),
"delete from sip_authentication where expires > 0 and hostname='%q'"
,
mod_sofia_globals
.
hostname
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
NULL
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
profile
->
ireg_mutex
);
switch_snprintfv
(
sql
,
sizeof
(
sql
),
"delete from sip_subscriptions where expires >= -1 and hostname='%q'"
,
mod_sofia_globals
.
hostname
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
NULL
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
profile
->
ireg_mutex
);
switch_snprintfv
(
sql
,
sizeof
(
sql
),
"delete from sip_dialogs where expires >= -1 and hostname='%q'"
,
mod_sofia_globals
.
hostname
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
NULL
);
switch_mutex_unlock
(
profile
->
ireg_mutex
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
profile
->
ireg_mutex
);
}
...
...
@@ -1558,13 +1552,13 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
}
else
{
sql
=
switch_mprintf
(
"delete from sip_registrations where sip_user='%q' and sip_host='%q'"
,
to_user
,
reg_host
);
}
switch_mutex_lock
(
profile
->
ireg_mutex
);
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
}
else
{
char
buf
[
32
]
=
""
;
sql
=
switch_mprintf
(
"select count(*) from sip_registrations where sip_user='%q' and sip_host='%q' and contact='%q'"
,
to_user
,
reg_host
,
contact_str
);
switch_mutex_lock
(
profile
->
ireg_mutex
);
sofia_glue_execute_sql2str
(
profile
,
profile
->
ireg_mutex
,
sql
,
buf
,
sizeof
(
buf
));
switch_safe_free
(
sql
);
...
...
@@ -1616,7 +1610,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
}
switch_mutex_unlock
(
profile
->
ireg_mutex
);
if
(
switch_event_create_subclass
(
&
s_event
,
SWITCH_EVENT_CUSTOM
,
MY_EVENT_REGISTER
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"profile-name"
,
profile
->
name
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论