Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
97c25275
提交
97c25275
authored
6月 23, 2015
作者:
Sergey Safarov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7628: mod_erlang_event - added ipv6 support
上级
be3c8686
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
130 行增加
和
171 行删除
+130
-171
switch_apr.h
src/include/switch_apr.h
+1
-0
ei_helpers.c
src/mod/event_handlers/mod_erlang_event/ei_helpers.c
+12
-47
handle_msg.c
src/mod/event_handlers/mod_erlang_event/handle_msg.c
+4
-4
mod_erlang_event.c
src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c
+101
-110
mod_erlang_event.h
src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h
+7
-10
switch_apr.c
src/switch_apr.c
+5
-0
没有找到文件。
src/include/switch_apr.h
浏览文件 @
97c25275
...
...
@@ -1103,6 +1103,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_connect(switch_socket_t *sock, swi
SWITCH_DECLARE
(
uint16_t
)
switch_sockaddr_get_port
(
switch_sockaddr_t
*
sa
);
SWITCH_DECLARE
(
const
char
*
)
switch_get_addr
(
char
*
buf
,
switch_size_t
len
,
switch_sockaddr_t
*
in
);
SWITCH_DECLARE
(
switch_status_t
)
switch_getnameinfo
(
char
**
hostname
,
switch_sockaddr_t
*
sa
,
int32_t
flags
);
SWITCH_DECLARE
(
int32_t
)
switch_sockaddr_get_family
(
switch_sockaddr_t
*
sa
);
SWITCH_DECLARE
(
switch_status_t
)
switch_sockaddr_ip_get
(
char
**
addr
,
switch_sockaddr_t
*
sa
);
SWITCH_DECLARE
(
int
)
switch_sockaddr_equal
(
const
switch_sockaddr_t
*
sa1
,
const
switch_sockaddr_t
*
sa2
);
...
...
src/mod/event_handlers/mod_erlang_event/ei_helpers.c
浏览文件 @
97c25275
...
...
@@ -64,6 +64,8 @@ void ei_link(listener_t *listener, erlang_pid * from, erlang_pid * to)
char
msgbuf
[
2048
];
char
*
s
;
int
index
=
0
;
switch_socket_t
*
sock
=
NULL
;
switch_os_sock_put
(
&
sock
,
&
listener
->
sockdes
,
listener
->
pool
);
index
=
5
;
/* max sizes: */
ei_encode_version
(
msgbuf
,
&
index
);
/* 1 */
...
...
@@ -79,13 +81,9 @@ void ei_link(listener_t *listener, erlang_pid * from, erlang_pid * to)
/* sum: 542 */
switch_mutex_lock
(
listener
->
sock_mutex
);
#ifdef WIN32
send
(
listener
->
sockfd
,
msgbuf
,
index
,
0
);
#else
if
(
write
(
listener
->
sockfd
,
msgbuf
,
index
)
==
-
1
)
{
if
(
switch_socket_send
(
sock
,
msgbuf
,
(
switch_size_t
*
)
&
index
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"Failed to link to process on %s
\n
"
,
listener
->
peer_nodename
);
}
#endif
switch_mutex_unlock
(
listener
->
sock_mutex
);
}
...
...
@@ -329,30 +327,17 @@ int ei_decode_string_or_binary(char *buf, int *index, int maxlen, char *dst)
switch_status_t
initialise_ei
(
struct
ei_cnode_s
*
ec
)
{
int
rv
;
struct
sockaddr_in
server_addr
;
struct
hostent
*
nodehost
;
char
thishostname
[
EI_MAXHOSTNAMELEN
+
1
]
=
""
;
char
*
thishostname
=
NULL
;
char
thisnodename
[
MAXNODELEN
+
1
];
char
thisalivename
[
MAXNODELEN
+
1
];
char
*
atsign
;
/* zero out the struct before we use it */
memset
(
&
server_addr
,
0
,
sizeof
(
server_addr
));
/* convert the configured IP to network byte order, handing errors */
rv
=
switch_inet_pton
(
AF_INET
,
prefs
.
ip
,
&
server_addr
.
sin_addr
.
s_addr
);
if
(
rv
==
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Could not parse invalid ip address: %s
\n
"
,
prefs
.
ip
);
return
SWITCH_STATUS_FALSE
;
}
else
if
(
rv
==
-
1
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Error when parsing ip address %s : %s
\n
"
,
prefs
.
ip
,
strerror
(
errno
));
return
SWITCH_STATUS_FALSE
;
if
(
zstr
(
listen_list
.
hostname
)
||
!
strncasecmp
(
prefs
.
ip
,
"0.0.0.0"
,
7
)
||
!
strncasecmp
(
prefs
.
ip
,
"::"
,
2
))
{
listen_list
.
hostname
=
(
char
*
)
switch_core_get_hostname
();
}
if
(
strlen
(
listen_list
.
hostname
)
>
EI_MAXHOSTNAMELEN
)
{
*
(
listen_list
.
hostname
+
EI_MAXHOSTNAMELEN
)
=
'\0'
;
}
/* set the address family and port */
server_addr
.
sin_family
=
AF_INET
;
server_addr
.
sin_port
=
htons
(
prefs
.
port
);
/* copy the prefs.nodename into something we can modify */
strncpy
(
thisalivename
,
prefs
.
nodename
,
MAXNODELEN
);
...
...
@@ -363,39 +348,19 @@ switch_status_t initialise_ei(struct ei_cnode_s *ec)
/* truncate the alivename at the @ */
*
atsign
=
'\0'
;
}
else
{
#ifdef WIN32
if
((
nodehost
=
gethostbyaddr
((
const
char
*
)
&
server_addr
.
sin_addr
.
s_addr
,
sizeof
(
server_addr
.
sin_addr
.
s_addr
),
AF_INET
)))
#else
if
((
nodehost
=
gethostbyaddr
((
const
char
*
)
&
server_addr
.
sin_addr
.
s_addr
,
sizeof
(
server_addr
.
sin_addr
.
s_addr
),
AF_INET
)))
#endif
memcpy
(
thishostname
,
nodehost
->
h_name
,
EI_MAXHOSTNAMELEN
);
if
(
zstr_buf
(
thishostname
)
||
!
strncasecmp
(
prefs
.
ip
,
"0.0.0.0"
,
7
))
{
gethostname
(
thishostname
,
EI_MAXHOSTNAMELEN
);
}
if
(
prefs
.
shortname
)
{
char
*
off
;
if
((
off
=
strchr
(
this
hostname
,
'.'
)))
{
if
((
off
=
strchr
(
listen_list
.
hostname
,
'.'
)))
{
*
off
=
'\0'
;
}
}
else
{
if
(
!
(
_res
.
options
&
RES_INIT
))
{
// init the resolver
res_init
();
}
if
(
_res
.
dnsrch
[
0
]
&&
!
zstr_buf
(
_res
.
dnsrch
[
0
]))
{
strncat
(
thishostname
,
"."
,
1
);
strncat
(
thishostname
,
_res
.
dnsrch
[
0
],
EI_MAXHOSTNAMELEN
-
strlen
(
thishostname
));
}
}
snprintf
(
thisnodename
,
MAXNODELEN
+
1
,
"%s@%s"
,
prefs
.
nodename
,
this
hostname
);
snprintf
(
thisnodename
,
MAXNODELEN
+
1
,
"%s@%s"
,
prefs
.
nodename
,
listen_list
.
hostname
);
}
/* init the ei stuff */
if
(
ei_connect_xinit
(
ec
,
thishostname
,
thisalivename
,
thisnodename
,
(
Erl_IpAddr
)
(
&
server_addr
.
sin_addr
.
s_addr
)
,
prefs
.
cookie
,
0
)
<
0
)
{
if
(
ei_connect_xinit
(
ec
,
listen_list
.
hostname
,
thisalivename
,
thisnodename
,
(
Erl_IpAddr
)
listen_list
.
addr
,
prefs
.
cookie
,
0
)
<
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Failed to init ei connection
\n
"
);
return
SWITCH_STATUS_FALSE
;
}
...
...
src/mod/event_handlers/mod_erlang_event/handle_msg.c
浏览文件 @
97c25275
...
...
@@ -111,7 +111,7 @@ static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t *thread, void *obj)
_ei_x_encode_string
(
&
ebuf
,
reply
);
switch_mutex_lock
(
acs
->
listener
->
sock_mutex
);
ei_send
(
acs
->
listener
->
sock
fd
,
&
acs
->
pid
,
ebuf
.
buff
,
ebuf
.
index
);
ei_send
(
acs
->
listener
->
sock
des
,
&
acs
->
pid
,
ebuf
.
buff
,
ebuf
.
index
);
switch_mutex_unlock
(
acs
->
listener
->
sock_mutex
);
#ifdef EI_DEBUG
ei_x_print_msg
(
&
ebuf
,
&
acs
->
pid
,
1
);
...
...
@@ -139,7 +139,7 @@ static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t *thread, void *obj)
switch_mutex_lock
(
acs
->
listener
->
sock_mutex
);
ei_send
(
acs
->
listener
->
sock
fd
,
&
acs
->
pid
,
rbuf
.
buff
,
rbuf
.
index
);
ei_send
(
acs
->
listener
->
sock
des
,
&
acs
->
pid
,
rbuf
.
buff
,
rbuf
.
index
);
switch_mutex_unlock
(
acs
->
listener
->
sock_mutex
);
#ifdef EI_DEBUG
ei_x_print_msg
(
&
rbuf
,
&
acs
->
pid
,
1
);
...
...
@@ -1332,7 +1332,7 @@ static switch_status_t handle_net_kernel_msg(listener_t *listener, erlang_msg *
ei_x_encode_atom
(
rbuf
,
"yes"
);
switch_mutex_lock
(
listener
->
sock_mutex
);
ei_send
(
listener
->
sock
fd
,
&
pid
,
rbuf
->
buff
,
rbuf
->
index
);
ei_send
(
listener
->
sock
des
,
&
pid
,
rbuf
->
buff
,
rbuf
->
index
);
switch_mutex_unlock
(
listener
->
sock_mutex
);
#ifdef EI_DEBUG
ei_x_print_msg
(
rbuf
,
&
pid
,
1
);
...
...
@@ -1398,7 +1398,7 @@ int handle_msg(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buf
return
0
;
}
else
if
(
rbuf
->
index
>
1
)
{
switch_mutex_lock
(
listener
->
sock_mutex
);
ei_send
(
listener
->
sock
fd
,
&
msg
->
from
,
rbuf
->
buff
,
rbuf
->
index
);
ei_send
(
listener
->
sock
des
,
&
msg
->
from
,
rbuf
->
buff
,
rbuf
->
index
);
switch_mutex_unlock
(
listener
->
sock_mutex
);
#ifdef EI_DEBUG
ei_x_print_msg
(
rbuf
,
&
msg
->
from
,
1
);
...
...
src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c
浏览文件 @
97c25275
差异被折叠。
点击展开。
src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h
浏览文件 @
97c25275
...
...
@@ -112,11 +112,7 @@ typedef enum {
5 call sessions will be "attached" to the same listener.
*/
struct
listener
{
#ifdef WIN32
SOCKET
sockfd
;
#else
int
sockfd
;
#endif
switch_os_socket_t
sockdes
;
struct
ei_cnode_s
*
ec
;
struct
erlang_process
log_process
;
struct
erlang_process
event_process
;
...
...
@@ -170,6 +166,7 @@ struct api_command_struct {
};
struct
globals_struct
{
switch_mutex_t
*
listener_mutex
;
switch_thread_rwlock_t
*
listener_rwlock
;
switch_thread_rwlock_t
*
bindings_rwlock
;
switch_event_node_t
*
node
;
...
...
@@ -187,11 +184,10 @@ struct globals_struct {
typedef
struct
globals_struct
globals_t
;
struct
listen_list_struct
{
#ifdef WIN32
SOCKET
sockfd
;
#else
int
sockfd
;
#endif
char
*
hostname
;
char
addr
[
64
];
switch_socket_t
*
sock
;
switch_mutex_t
*
sock_mutex
;
listener_t
*
listeners
;
uint8_t
ready
;
};
...
...
@@ -220,6 +216,7 @@ struct prefs_struct {
int
compat_rel
;
int
max_event_bulk
;
int
max_log_bulk
;
int
stop_on_bind_error
;
};
typedef
struct
prefs_struct
prefs_t
;
...
...
src/switch_apr.c
浏览文件 @
97c25275
...
...
@@ -913,6 +913,11 @@ SWITCH_DECLARE(int32_t) switch_sockaddr_get_family(switch_sockaddr_t *sa)
return
sa
->
family
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_getnameinfo
(
char
**
hostname
,
switch_sockaddr_t
*
sa
,
int32_t
flags
)
{
return
apr_getnameinfo
(
hostname
,
sa
,
flags
);
}
SWITCH_DECLARE
(
switch_status_t
)
switch_socket_atmark
(
switch_socket_t
*
sock
,
int
*
atmark
)
{
return
apr_socket_atmark
(
sock
,
atmark
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论