Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
e008af0e
提交
e008af0e
authored
8月 22, 2012
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor some unneeded code and move artoo code into the core
上级
ebc2e8d0
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
98 行增加
和
99 行删除
+98
-99
sofia.c
src/mod/endpoints/mod_sofia/sofia.c
+70
-98
switch_core_session.c
src/switch_core_session.c
+28
-1
没有找到文件。
src/mod/endpoints/mod_sofia/sofia.c
浏览文件 @
e008af0e
...
...
@@ -8045,6 +8045,13 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
nua_handle_t
*
bnh
=
NULL
;
char
sip_acl_authed_by
[
512
]
=
""
;
char
sip_acl_token
[
512
]
=
""
;
const
char
*
dialog_from_user
=
""
,
*
dialog_from_host
=
""
,
*
to_user
=
""
,
*
to_host
=
""
,
*
contact_user
=
""
,
*
contact_host
=
""
;
const
char
*
user_agent
=
""
,
*
call_id
=
""
;
url_t
*
from
=
NULL
,
*
to
=
NULL
,
*
contact
=
NULL
;
const
char
*
to_tag
=
""
;
const
char
*
from_tag
=
""
;
char
*
sql
=
NULL
;
profile
->
ib_calls
++
;
...
...
@@ -9047,127 +9054,92 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
sofia_presence_set_chat_hash
(
tech_pvt
,
sip
);
}
if
(
sip
->
sip_to
)
{
to
=
sip
->
sip_to
->
a_url
;
}
if
(
sip
->
sip_from
)
{
from
=
sip
->
sip_from
->
a_url
;
}
if
(
sip
->
sip_contact
)
{
contact
=
sip
->
sip_contact
->
m_url
;
}
if
(
sip
&&
session
)
{
const
char
*
dialog_from_user
=
""
,
*
dialog_from_host
=
""
,
*
to_user
=
""
,
*
to_host
=
""
,
*
contact_user
=
""
,
*
contact_host
=
""
;
const
char
*
user_agent
=
""
,
*
call_id
=
""
;
url_t
*
from
=
NULL
,
*
to
=
NULL
,
*
contact
=
NULL
;
const
char
*
to_tag
=
""
;
const
char
*
from_tag
=
""
;
char
*
sql
=
NULL
;
if
(
sip
->
sip_user_agent
)
{
user_agent
=
switch_str_nil
(
sip
->
sip_user_agent
->
g_string
);
}
if
(
sip
->
sip_to
)
{
to
=
sip
->
sip_to
->
a_url
;
}
if
(
sip
->
sip_from
)
{
from
=
sip
->
sip_from
->
a_url
;
}
if
(
sip
->
sip_contact
)
{
contact
=
sip
->
sip_contact
->
m_url
;
}
if
(
sip
->
sip_call_id
)
{
call_id
=
switch_str_nil
(
sip
->
sip_call_id
->
i_id
);
}
if
(
sip
->
sip_user_agent
)
{
user_agent
=
switch_str_nil
(
sip
->
sip_user_agent
->
g_string
);
}
if
(
to
)
{
to_user
=
switch_str_nil
(
to
->
url_user
);
to_host
=
switch_str_nil
(
to
->
url_host
);
to_tag
=
switch_str_nil
(
sip
->
sip_to
->
a_tag
);
}
if
(
sip
->
sip_call_id
)
{
call_id
=
switch_str_nil
(
sip
->
sip_call_id
->
i_id
);
}
if
(
from
)
{
dialog_from_user
=
switch_str_nil
(
from
->
url_user
);
dialog_from_host
=
switch_str_nil
(
from
->
url_host
);
from_tag
=
switch_str_nil
(
sip
->
sip_from
->
a_tag
);
}
if
(
to
)
{
to_user
=
switch_str_nil
(
to
->
url_user
);
to_host
=
switch_str_nil
(
to
->
url_host
);
to_tag
=
switch_str_nil
(
sip
->
sip_to
->
a_tag
);
}
if
(
contact
)
{
contact_user
=
switch_str_nil
(
contact
->
url_user
);
contact_host
=
switch_str_nil
(
contact
->
url_host
);
}
if
(
from
)
{
dialog_from_user
=
switch_str_nil
(
from
->
url_user
);
dialog_from_host
=
switch_str_nil
(
from
->
url_host
);
from_tag
=
switch_str_nil
(
sip
->
sip_from
->
a_tag
);
}
if
(
profile
->
pres_type
)
{
const
char
*
presence_data
=
switch_channel_get_variable
(
channel
,
"presence_data"
);
const
char
*
presence_id
=
switch_channel_get_variable
(
channel
,
"presence_id"
);
char
*
full_contact
=
""
;
char
*
p
=
NULL
;
time_t
now
;
if
(
contact
)
{
contact_user
=
switch_str_nil
(
contact
->
url_user
);
contact_host
=
switch_str_nil
(
contact
->
url_host
);
if
(
sip
->
sip_contact
)
{
full_contact
=
sip_header_as_string
(
nua_handle_home
(
tech_pvt
->
nh
),
(
void
*
)
sip
->
sip_contact
);
}
if
(
profile
->
pres_type
)
{
const
char
*
presence_data
=
switch_channel_get_variable
(
channel
,
"presence_data"
);
const
char
*
presence_id
=
switch_channel_get_variable
(
channel
,
"presence_id"
);
char
*
full_contact
=
""
;
char
*
p
=
NULL
;
time_t
now
;
if
(
sip
->
sip_contact
)
{
full_contact
=
sip_header_as_string
(
nua_handle_home
(
tech_pvt
->
nh
),
(
void
*
)
sip
->
sip_contact
);
}
if
(
call_info_str
&&
switch_stristr
(
"appearance"
,
call_info_str
))
{
switch_channel_set_variable
(
channel
,
"presence_call_info_full"
,
call_info_str
);
if
((
p
=
strchr
(
call_info_str
,
';'
)))
{
p
++
;
switch_channel_set_variable
(
channel
,
"presence_call_info"
,
p
);
}
if
(
call_info_str
&&
switch_stristr
(
"appearance"
,
call_info_str
))
{
switch_channel_set_variable
(
channel
,
"presence_call_info_full"
,
call_info_str
);
if
((
p
=
strchr
(
call_info_str
,
';'
)))
{
p
++
;
switch_channel_set_variable
(
channel
,
"presence_call_info"
,
p
);
}
}
now
=
switch_epoch_time_now
(
NULL
);
sql
=
switch_mprintf
(
"insert into sip_dialogs "
"(call_id,uuid,sip_to_user,sip_to_host,sip_to_tag,sip_from_user,sip_from_host,sip_from_tag,contact_user,"
"contact_host,state,direction,user_agent,profile_name,hostname,contact,presence_id,presence_data,"
"call_info,rcd,call_info_state) "
"values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'')"
,
call_id
,
tech_pvt
->
sofia_private
->
uuid
,
to_user
,
to_host
,
to_tag
,
dialog_from_user
,
dialog_from_host
,
from_tag
,
contact_user
,
contact_host
,
"confirmed"
,
"inbound"
,
user_agent
,
profile
->
name
,
mod_sofia_globals
.
hostname
,
switch_str_nil
(
full_contact
),
switch_str_nil
(
presence_id
),
switch_str_nil
(
presence_data
),
switch_str_nil
(
p
),
now
);
switch_assert
(
sql
);
sofia_glue_actually_execute_sql
(
profile
,
sql
,
profile
->
ireg_mutex
);
switch_safe_free
(
sql
);
now
=
switch_epoch_time_now
(
NULL
);
}
sql
=
switch_mprintf
(
"insert into sip_dialogs "
"(call_id,uuid,sip_to_user,sip_to_host,sip_to_tag,sip_from_user,sip_from_host,sip_from_tag,contact_user,"
"contact_host,state,direction,user_agent,profile_name,hostname,contact,presence_id,presence_data,"
"call_info,rcd,call_info_state) "
"values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'')"
,
call_id
,
tech_pvt
->
sofia_private
->
uuid
,
to_user
,
to_host
,
to_tag
,
dialog_from_user
,
dialog_from_host
,
from_tag
,
contact_user
,
contact_host
,
"confirmed"
,
"inbound"
,
user_agent
,
profile
->
name
,
mod_sofia_globals
.
hostname
,
switch_str_nil
(
full_contact
),
switch_str_nil
(
presence_id
),
switch_str_nil
(
presence_data
),
switch_str_nil
(
p
),
now
);
if
(
is_nat
)
{
sofia_set_flag
(
tech_pvt
,
TFLAG_NAT
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Setting NAT mode based on %s
\n
"
,
is_nat
);
switch_channel_set_variable
(
channel
,
"sip_nat_detected"
,
"true"
);
}
switch_assert
(
sql
);
return
;
}
sofia_glue_actually_execute_sql
(
profile
,
sql
,
profile
->
ireg_mutex
)
;
switch_safe_free
(
sql
);
if
(
sess_count
>
110
)
{
switch_mutex_lock
(
profile
->
flag_mutex
);
switch_core_session_limit
(
sess_count
-
10
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_CRIT
,
"LUKE: I'm hit, but not bad.
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_CRIT
,
"LUKE'S VOICE: Artoo, see what you can do with it. Hang on back there....
\n
"
"Green laserfire moves past the beeping little robot as his head turns. "
"After a few beeps and a twist of his mechanical arm,
\n
"
"Artoo reduces the max sessions to %d thus, saving the switch from certain doom.
\n
"
,
sess_count
-
10
);
switch_mutex_unlock
(
profile
->
flag_mutex
);
}
if
(
tech_pvt
->
hash_key
)
{
s
witch_mutex_lock
(
tech_pvt
->
profile
->
flag_mutex
);
switch_
core_hash_delete
(
tech_pvt
->
profile
->
chat_hash
,
tech_pvt
->
hash_key
);
switch_
mutex_unlock
(
tech_pvt
->
profile
->
flag_mutex
);
if
(
is_nat
)
{
s
ofia_set_flag
(
tech_pvt
,
TFLAG_NAT
);
switch_
log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Setting NAT mode based on %s
\n
"
,
is_nat
);
switch_
channel_set_variable
(
channel
,
"sip_nat_detected"
,
"true"
);
}
if
(
!
switch_core_session_running
(
session
))
{
nua_handle_bind
(
nh
,
NULL
);
sofia_private_free
(
sofia_private
);
switch_core_session_destroy
(
&
session
);
nua_respond
(
nh
,
503
,
"Maximum Calls In Progress"
,
SIPTAG_RETRY_AFTER_STR
(
"300"
),
TAG_END
());
}
return
;
fail:
profile
->
ib_failed_calls
++
;
return
;
}
...
...
src/switch_core_session.c
浏览文件 @
e008af0e
...
...
@@ -1518,6 +1518,28 @@ static void *SWITCH_THREAD_FUNC switch_core_session_thread_pool_worker(switch_th
return
NULL
;
}
static
void
thread_launch_failure
(
void
)
{
uint32_t
sess_count
;
switch_mutex_lock
(
session_manager
.
mutex
);
sess_count
=
switch_core_session_count
();
if
(
sess_count
>
110
)
{
switch_core_session_limit
(
sess_count
-
10
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"LUKE: I'm hit, but not bad.
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"LUKE'S VOICE: Artoo, see what you can do with it. Hang on back there....
\n
"
"Green laserfire moves past the beeping little robot as his head turns. "
"After a few beeps and a twist of his mechanical arm,
\n
"
"Artoo reduces the max sessions to %d thus, saving the switch from certain doom.
\n
"
,
sess_count
-
10
);
}
switch_mutex_unlock
(
session_manager
.
mutex
);
}
static
switch_status_t
check_queue
(
void
)
{
...
...
@@ -1550,6 +1572,7 @@ static switch_status_t check_queue(void)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"Thread Failure!
\n
"
);
switch_core_destroy_memory_pool
(
&
pool
);
status
=
SWITCH_STATUS_GENERR
;
thread_launch_failure
();
}
else
{
status
=
SWITCH_STATUS_SUCCESS
;
}
...
...
@@ -1638,6 +1661,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_thread_launch(switch_core_se
switch_clear_flag
(
session
,
SSF_THREAD_RUNNING
);
switch_clear_flag
(
session
,
SSF_THREAD_STARTED
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_CRIT
,
"Cannot create thread!
\n
"
);
thread_launch_failure
();
}
}
...
...
@@ -1656,7 +1680,10 @@ SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session_t *se
switch_threadattr_detach_set
(
thd_attr
,
1
);
switch_threadattr_stacksize_set
(
thd_attr
,
SWITCH_THREAD_STACKSIZE
);
switch_thread_create
(
&
thread
,
thd_attr
,
func
,
obj
,
session
->
pool
);
if
(
switch_thread_create
(
&
thread
,
thd_attr
,
func
,
obj
,
session
->
pool
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_CRIT
,
"Cannot create thread!
\n
"
);
thread_launch_failure
();
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论