Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
e75d7067
提交
e75d7067
authored
7月 15, 2014
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove select call from switch_nat.c
上级
41ea9c5a
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
36 行增加
和
7 行删除
+36
-7
switch_apr.h
src/include/switch_apr.h
+4
-1
switch_apr.c
src/switch_apr.c
+10
-0
switch_nat.c
src/switch_nat.c
+22
-6
没有找到文件。
src/include/switch_apr.h
浏览文件 @
e75d7067
...
@@ -1389,6 +1389,9 @@ SWITCH_DECLARE(switch_status_t) switch_pollset_poll(switch_pollset_t *pollset, s
...
@@ -1389,6 +1389,9 @@ SWITCH_DECLARE(switch_status_t) switch_pollset_poll(switch_pollset_t *pollset, s
*/
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_socket_create_pollset
(
switch_pollfd_t
**
poll
,
switch_socket_t
*
sock
,
int16_t
flags
,
switch_memory_pool_t
*
pool
);
SWITCH_DECLARE
(
switch_status_t
)
switch_socket_create_pollset
(
switch_pollfd_t
**
poll
,
switch_socket_t
*
sock
,
int16_t
flags
,
switch_memory_pool_t
*
pool
);
SWITCH_DECLARE
(
switch_interval_time_t
)
switch_interval_time_from_timeval
(
struct
timeval
*
tvp
);
/*!
/*!
\brief Create a pollfd out of a socket
\brief Create a pollfd out of a socket
\param pollfd the pollfd to create
\param pollfd the pollfd to create
...
@@ -1402,7 +1405,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **po
...
@@ -1402,7 +1405,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **po
SWITCH_DECLARE
(
switch_status_t
)
switch_match_glob
(
const
char
*
pattern
,
switch_array_header_t
**
result
,
switch_memory_pool_t
*
pool
);
SWITCH_DECLARE
(
switch_status_t
)
switch_match_glob
(
const
char
*
pattern
,
switch_array_header_t
**
result
,
switch_memory_pool_t
*
pool
);
SWITCH_DECLARE
(
switch_status_t
)
switch_os_sock_get
(
switch_os_socket_t
*
thesock
,
switch_socket_t
*
sock
);
SWITCH_DECLARE
(
switch_status_t
)
switch_os_sock_get
(
switch_os_socket_t
*
thesock
,
switch_socket_t
*
sock
);
SWITCH_DECLARE
(
switch_status_t
)
switch_socket_addr_get
(
switch_sockaddr_t
**
sa
,
switch_bool_t
remote
,
switch_socket_t
*
sock
);
SWITCH_DECLARE
(
switch_status_t
)
switch_socket_addr_get
(
switch_sockaddr_t
**
sa
,
switch_bool_t
remote
,
switch_socket_t
*
sock
);
SWITCH_DECLARE
(
switch_status_t
)
switch_os_sock_put
(
switch_socket_t
**
sock
,
switch_os_socket_t
*
thesock
,
switch_memory_pool_t
*
pool
);
/**
/**
* Create an anonymous pipe.
* Create an anonymous pipe.
* @param in The file descriptor to use as input to the pipe.
* @param in The file descriptor to use as input to the pipe.
...
...
src/switch_apr.c
浏览文件 @
e75d7067
...
@@ -646,8 +646,18 @@ SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t ** new_thre
...
@@ -646,8 +646,18 @@ SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t ** new_thre
return
apr_thread_create
(
new_thread
,
attr
,
func
,
data
,
cont
);
return
apr_thread_create
(
new_thread
,
attr
,
func
,
data
,
cont
);
}
}
SWITCH_DECLARE
(
switch_interval_time_t
)
switch_interval_time_from_timeval
(
struct
timeval
*
tvp
)
{
return
((
switch_interval_time_t
)
tvp
->
tv_sec
*
1000000
)
+
tvp
->
tv_usec
/
1000
;
}
/* socket stubs */
/* socket stubs */
SWITCH_DECLARE
(
switch_status_t
)
switch_os_sock_put
(
switch_socket_t
**
sock
,
switch_os_socket_t
*
thesock
,
switch_memory_pool_t
*
pool
)
{
return
apr_os_sock_put
(
sock
,
thesock
,
pool
);
}
SWITCH_DECLARE
(
switch_status_t
)
switch_os_sock_get
(
switch_os_socket_t
*
thesock
,
switch_socket_t
*
sock
)
SWITCH_DECLARE
(
switch_status_t
)
switch_os_sock_get
(
switch_os_socket_t
*
thesock
,
switch_socket_t
*
sock
)
{
{
return
apr_os_sock_get
(
thesock
,
sock
);
return
apr_os_sock_get
(
thesock
,
sock
);
...
...
src/switch_nat.c
浏览文件 @
e75d7067
...
@@ -149,9 +149,13 @@ static int get_pmp_pubaddr(char *pub_addr)
...
@@ -149,9 +149,13 @@ static int get_pmp_pubaddr(char *pub_addr)
int
r
=
0
,
i
=
0
,
max
=
5
;
int
r
=
0
,
i
=
0
,
max
=
5
;
natpmpresp_t
response
;
natpmpresp_t
response
;
char
*
pubaddr
=
NULL
;
char
*
pubaddr
=
NULL
;
fd_set
fds
;
natpmp_t
natpmp
;
natpmp_t
natpmp
;
const
char
*
err
=
NULL
;
const
char
*
err
=
NULL
;
switch_pollfd_t
*
pollfd
=
NULL
;
switch_socket_t
*
sock
=
NULL
;
switch_memory_pool_t
*
pool
;
int32_t
num
=
0
;
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
if
((
r
=
initnatpmp
(
&
natpmp
))
<
0
)
{
if
((
r
=
initnatpmp
(
&
natpmp
))
<
0
)
{
err
=
"init failed"
;
err
=
"init failed"
;
...
@@ -163,24 +167,34 @@ static int get_pmp_pubaddr(char *pub_addr)
...
@@ -163,24 +167,34 @@ static int get_pmp_pubaddr(char *pub_addr)
goto
end
;
goto
end
;
}
}
switch_core_new_memory_pool
(
&
pool
);
switch_os_sock_put
(
&
sock
,
&
natpmp
.
s
,
pool
);
if
(
switch_socket_create_pollset
(
&
pollfd
,
sock
,
SWITCH_POLLIN
|
SWITCH_POLLERR
,
pool
)
!=
SWITCH_STATUS_SUCCESS
)
{
err
=
"cannot create pollset"
;
goto
end
;
}
do
{
do
{
struct
timeval
timeout
=
{
1
,
0
};
struct
timeval
timeout
=
{
1
,
0
};
i
++
;
i
++
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Checking for PMP %d/%d
\n
"
,
i
,
max
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Checking for PMP %d/%d
\n
"
,
i
,
max
);
FD_ZERO
(
&
fds
);
FD_SET
(
natpmp
.
s
,
&
fds
);
if
((
r
=
getnatpmprequesttimeout
(
&
natpmp
,
&
timeout
))
<
0
)
{
if
((
r
=
getnatpmprequesttimeout
(
&
natpmp
,
&
timeout
))
<
0
)
{
err
=
"get timeout failed"
;
err
=
"get timeout failed"
;
goto
end
;
goto
end
;
}
}
status
=
switch_poll
(
pollfd
,
1
,
&
num
,
switch_interval_time_from_timeval
(
&
timeout
));
if
(
(
r
=
select
(
FD_SETSIZE
,
&
fds
,
NULL
,
NULL
,
&
timeout
))
<
0
)
{
if
(
!
(
status
==
SWITCH_STATUS_SUCCESS
||
status
==
SWITCH_STATUS_TIMEOUT
)
)
{
err
=
"
select
failed"
;
err
=
"
poll
failed"
;
goto
end
;
goto
end
;
}
}
r
=
readnatpmpresponseorretry
(
&
natpmp
,
&
response
);
r
=
readnatpmpresponseorretry
(
&
natpmp
,
&
response
);
}
while
(
r
==
NATPMP_TRYAGAIN
&&
i
<
max
);
}
while
(
r
==
NATPMP_TRYAGAIN
&&
i
<
max
);
if
(
r
<
0
)
{
if
(
r
<
0
)
{
...
@@ -196,6 +210,8 @@ static int get_pmp_pubaddr(char *pub_addr)
...
@@ -196,6 +210,8 @@ static int get_pmp_pubaddr(char *pub_addr)
end:
end:
switch_core_destroy_memory_pool
(
&
pool
);
if
(
err
)
{
if
(
err
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Error checking for PMP [%s]
\n
"
,
err
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Error checking for PMP [%s]
\n
"
,
err
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论