Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
e402c54c
提交
e402c54c
authored
5月 02, 2007
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
git-svn-id:
http://svn.freeswitch.org/svn/freeswitch/trunk@5072
d0543943-73ff-0310-b7d9-9358b9ac24b2
上级
f8409fe0
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
39 行增加
和
13 行删除
+39
-13
mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.c
+15
-7
mod_sofia.h
src/mod/endpoints/mod_sofia/mod_sofia.h
+1
-0
sofia.c
src/mod/endpoints/mod_sofia/sofia.c
+18
-5
sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_glue.c
+5
-1
没有找到文件。
src/mod/endpoints/mod_sofia/mod_sofia.c
浏览文件 @
e402c54c
...
@@ -950,7 +950,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
...
@@ -950,7 +950,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
const
void
*
vvar
;
const
void
*
vvar
;
int
c
=
0
;
int
c
=
0
;
int
ac
=
0
;
int
ac
=
0
;
const
char
*
line
=
"======================================================================================="
;
const
char
*
line
=
"=======================================================================================
==========
"
;
if
(
argc
>
0
)
{
if
(
argc
>
0
)
{
...
@@ -1045,14 +1045,16 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
...
@@ -1045,14 +1045,16 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
if
(
strcmp
(
vvar
,
profile
->
name
))
{
if
(
strcmp
(
vvar
,
profile
->
name
))
{
ac
++
;
ac
++
;
stream
->
write_function
(
stream
,
"%25s
\t
%s
\t
%32s
\t
%s
\n
"
,
vvar
,
" alias"
,
profile
->
name
,
"
LOAD
ED"
);
stream
->
write_function
(
stream
,
"%25s
\t
%s
\t
%32s
\t
%s
\n
"
,
vvar
,
" alias"
,
profile
->
name
,
"
ALIAS
ED"
);
}
else
{
}
else
{
stream
->
write_function
(
stream
,
"%25s
\t
%s
\t
%32s
\t
%s
\n
"
,
profile
->
name
,
"profile"
,
profile
->
url
,
"LOADED"
);
stream
->
write_function
(
stream
,
"%25s
\t
%s
\t
%32s
\t
%s
\n
"
,
profile
->
name
,
"profile"
,
profile
->
url
,
sofia_test_pflag
(
profile
,
PFLAG_RUNNING
)
?
"RUNNING"
:
"DOWN"
);
c
++
;
c
++
;
for
(
gp
=
profile
->
gateways
;
gp
;
gp
=
gp
->
next
)
{
for
(
gp
=
profile
->
gateways
;
gp
;
gp
=
gp
->
next
)
{
assert
(
gp
->
state
<
REG_STATE_LAST
);
assert
(
gp
->
state
<
REG_STATE_LAST
);
stream
->
write_function
(
stream
,
"%25s
\t
%s
\t
%32s
\t
%s
\n
"
,
gp
->
name
,
"gateway"
,
gp
->
register_to
,
sofia_state_names
[
gp
->
state
]);
stream
->
write_function
(
stream
,
"%25s
\t
%s
\t
%32s
\t
%s
\n
"
,
gp
->
name
,
"gateway"
,
gp
->
register_to
,
sofia_state_names
[
gp
->
state
]);
}
}
}
}
...
@@ -1061,7 +1063,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
...
@@ -1061,7 +1063,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
}
}
switch_mutex_unlock
(
mod_sofia_globals
.
hash_mutex
);
switch_mutex_unlock
(
mod_sofia_globals
.
hash_mutex
);
stream
->
write_function
(
stream
,
"%s
\n
"
,
line
);
stream
->
write_function
(
stream
,
"%s
\n
"
,
line
);
stream
->
write_function
(
stream
,
"%d profile
s %d aliases
\n
"
,
c
,
ac
);
stream
->
write_function
(
stream
,
"%d profile
%s %d alias%s
\n
"
,
c
,
c
==
1
?
""
:
"s"
,
ac
,
ac
==
1
?
""
:
"es"
);
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
...
@@ -1105,9 +1107,15 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
...
@@ -1105,9 +1107,15 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
sofia_clear_pflag_locked
(
profile
,
PFLAG_RUNNING
);
sofia_clear_pflag_locked
(
profile
,
PFLAG_RUNNING
);
stream
->
write_function
(
stream
,
"stopping: %s"
,
profile
->
name
);
stream
->
write_function
(
stream
,
"stopping: %s"
,
profile
->
name
);
}
else
if
(
!
strcasecmp
(
argv
[
1
],
"restart"
))
{
}
else
if
(
!
strcasecmp
(
argv
[
1
],
"restart"
))
{
sofia_set_pflag_locked
(
profile
,
PFLAG_RESPAWN
);
int
rsec
=
30
;
sofia_clear_pflag_locked
(
profile
,
PFLAG_RUNNING
);
stream
->
write_function
(
stream
,
"restarting: %s"
,
profile
->
name
);
if
(
time
(
NULL
)
-
profile
->
started
<
rsec
)
{
stream
->
write_function
(
stream
,
"Profile %s must be up for at least %d seconds to restart
\n
"
,
rsec
,
profile
->
name
);
}
else
{
sofia_set_pflag_locked
(
profile
,
PFLAG_RESPAWN
);
sofia_clear_pflag_locked
(
profile
,
PFLAG_RUNNING
);
stream
->
write_function
(
stream
,
"restarting: %s"
,
profile
->
name
);
}
}
}
if
(
profile
)
{
if
(
profile
)
{
...
...
src/mod/endpoints/mod_sofia/mod_sofia.h
浏览文件 @
e402c54c
...
@@ -240,6 +240,7 @@ struct sofia_profile {
...
@@ -240,6 +240,7 @@ struct sofia_profile {
switch_thread_rwlock_t
*
rwlock
;
switch_thread_rwlock_t
*
rwlock
;
switch_mutex_t
*
flag_mutex
;
switch_mutex_t
*
flag_mutex
;
uint32_t
inuse
;
uint32_t
inuse
;
time_t
started
;
#ifdef SWITCH_HAVE_ODBC
#ifdef SWITCH_HAVE_ODBC
char
*
odbc_dsn
;
char
*
odbc_dsn
;
char
*
odbc_user
;
char
*
odbc_user
;
...
...
src/mod/endpoints/mod_sofia/sofia.c
浏览文件 @
e402c54c
...
@@ -262,6 +262,13 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
...
@@ -262,6 +262,13 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Creating agent for %s
\n
"
,
profile
->
name
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Creating agent for %s
\n
"
,
profile
->
name
);
if
(
!
sofia_glue_init_sql
(
profile
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"Cannot Open SQL Database [%s]!
\n
"
,
profile
->
name
);
sofia_glue_del_profile
(
profile
);
goto
end
;
}
profile
->
nua
=
nua_create
(
profile
->
s_root
,
/* Event loop */
profile
->
nua
=
nua_create
(
profile
->
s_root
,
/* Event loop */
sofia_event_callback
,
/* Callback for processing events */
sofia_event_callback
,
/* Callback for processing events */
profile
,
/* Additional data to pass to callback */
profile
,
/* Additional data to pass to callback */
...
@@ -269,6 +276,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
...
@@ -269,6 +276,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
if
(
!
profile
->
nua
)
{
if
(
!
profile
->
nua
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Error Creating SIP UA for profile: %s
\n
"
,
profile
->
name
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Error Creating SIP UA for profile: %s
\n
"
,
profile
->
name
);
sofia_glue_del_profile
(
profile
);
goto
end
;
goto
end
;
}
}
...
@@ -313,10 +321,6 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
...
@@ -313,10 +321,6 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
}
}
if
(
!
sofia_glue_init_sql
(
profile
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"Cannot Open SQL Database!
\n
"
);
goto
end
;
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"activated db for %s
\n
"
,
profile
->
name
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"activated db for %s
\n
"
,
profile
->
name
);
...
@@ -343,8 +347,11 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
...
@@ -343,8 +347,11 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Starting thread for %s
\n
"
,
profile
->
name
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Starting thread for %s
\n
"
,
profile
->
name
);
profile
->
started
=
time
(
NULL
);
switch_yield
(
1000000
);
sofia_set_pflag_locked
(
profile
,
PFLAG_RUNNING
);
sofia_set_pflag_locked
(
profile
,
PFLAG_RUNNING
);
while
(
mod_sofia_globals
.
running
==
1
&&
sofia_test_pflag
(
profile
,
PFLAG_RUNNING
))
{
while
(
mod_sofia_globals
.
running
==
1
&&
sofia_test_pflag
(
profile
,
PFLAG_RUNNING
))
{
if
(
++
ireg_loops
>=
IREG_SECONDS
)
{
if
(
++
ireg_loops
>=
IREG_SECONDS
)
{
sofia_reg_check_expire
(
profile
,
time
(
NULL
));
sofia_reg_check_expire
(
profile
,
time
(
NULL
));
...
@@ -363,8 +370,12 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
...
@@ -363,8 +370,12 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
switch_yield
(
500000
);
switch_yield
(
500000
);
}
}
//sofia_reg_check_expire(profile, 0);
//sofia_reg_check_expire(profile, 0);
//sofia_reg_check_gateway(profile, 0);
//sofia_reg_check_gateway(profile, 0);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Write lock %s
\n
"
,
profile
->
name
);
switch_thread_rwlock_wrlock
(
profile
->
rwlock
);
switch_thread_rwlock_wrlock
(
profile
->
rwlock
);
sofia_reg_unregister
(
profile
);
sofia_reg_unregister
(
profile
);
nua_shutdown
(
profile
->
nua
);
nua_shutdown
(
profile
->
nua
);
...
@@ -393,6 +404,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
...
@@ -393,6 +404,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
sofia_glue_del_profile
(
profile
);
sofia_glue_del_profile
(
profile
);
switch_thread_rwlock_unlock
(
profile
->
rwlock
);
switch_thread_rwlock_unlock
(
profile
->
rwlock
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Write unlock %s
\n
"
,
profile
->
name
);
if
(
sofia_test_pflag
(
profile
,
PFLAG_RESPAWN
))
{
if
(
sofia_test_pflag
(
profile
,
PFLAG_RESPAWN
))
{
config_sofia
(
1
,
profile
->
name
);
config_sofia
(
1
,
profile
->
name
);
...
@@ -402,6 +414,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
...
@@ -402,6 +414,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
end:
end:
switch_mutex_lock
(
mod_sofia_globals
.
mutex
);
switch_mutex_lock
(
mod_sofia_globals
.
mutex
);
mod_sofia_globals
.
threads
--
;
mod_sofia_globals
.
threads
--
;
...
...
src/mod/endpoints/mod_sofia/sofia_glue.c
浏览文件 @
e402c54c
...
@@ -1426,10 +1426,14 @@ sofia_profile_t *sofia_glue_find_profile(char *key)
...
@@ -1426,10 +1426,14 @@ sofia_profile_t *sofia_glue_find_profile(char *key)
switch_mutex_lock
(
mod_sofia_globals
.
hash_mutex
);
switch_mutex_lock
(
mod_sofia_globals
.
hash_mutex
);
if
((
profile
=
(
sofia_profile_t
*
)
switch_core_hash_find
(
mod_sofia_globals
.
profile_hash
,
key
)))
{
if
((
profile
=
(
sofia_profile_t
*
)
switch_core_hash_find
(
mod_sofia_globals
.
profile_hash
,
key
)))
{
if
(
!
sofia_test_pflag
(
profile
,
PFLAG_RUNNING
))
{
if
(
!
sofia_test_pflag
(
profile
,
PFLAG_RUNNING
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Profile %s is not running
\n
"
,
profile
->
name
);
profile
=
NULL
;
profile
=
NULL
;
}
else
if
(
switch_thread_rwlock_tryrdlock
(
profile
->
rwlock
)
!=
SWITCH_STATUS_SUCCESS
)
{
}
else
if
(
switch_thread_rwlock_tryrdlock
(
profile
->
rwlock
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Profile %s is locked
\n
"
,
profile
->
name
);
profile
=
NULL
;
profile
=
NULL
;
}
}
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Profile %s is not in the hash
\n
"
,
profile
->
name
);
}
}
switch_mutex_unlock
(
mod_sofia_globals
.
hash_mutex
);
switch_mutex_unlock
(
mod_sofia_globals
.
hash_mutex
);
...
@@ -1545,7 +1549,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
...
@@ -1545,7 +1549,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
}
}
#endif
#endif
return
1
;
return
profile
->
master_odbc
?
1
:
0
;
}
}
void
sofia_glue_sql_close
(
sofia_profile_t
*
profile
)
void
sofia_glue_sql_close
(
sofia_profile_t
*
profile
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论