mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Before binding tcp ports, checks the socket type and listener options
(EJAB-1334) If the callback module has a socket type of independent and needs to create the listener itself, do not pre-bind the port. The same holds if there are errors in the listener configuration.
This commit is contained in:
parent
1ab92d1159
commit
d8d20d5b88
@ -60,11 +60,18 @@ bind_tcp_ports() ->
|
|||||||
Ls ->
|
Ls ->
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun({Port, Module, Opts}) ->
|
fun({Port, Module, Opts}) ->
|
||||||
|
ModuleRaw = strip_frontend(Module),
|
||||||
|
case ModuleRaw:socket_type() of
|
||||||
|
independent -> ok;
|
||||||
|
_ ->
|
||||||
bind_tcp_port(Port, Module, Opts)
|
bind_tcp_port(Port, Module, Opts)
|
||||||
|
end
|
||||||
end, Ls)
|
end, Ls)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
bind_tcp_port(PortIP, Module, RawOpts) ->
|
bind_tcp_port(PortIP, Module, RawOpts) ->
|
||||||
|
try check_listener_options(RawOpts) of
|
||||||
|
ok ->
|
||||||
{Port, IPT, IPS, IPV, Proto, OptsClean} = parse_listener_portip(PortIP, RawOpts),
|
{Port, IPT, IPS, IPV, Proto, OptsClean} = parse_listener_portip(PortIP, RawOpts),
|
||||||
{_Opts, SockOpts} = prepare_opts(IPT, IPV, OptsClean),
|
{_Opts, SockOpts} = prepare_opts(IPT, IPV, OptsClean),
|
||||||
case Proto of
|
case Proto of
|
||||||
@ -72,6 +79,10 @@ bind_tcp_port(PortIP, Module, RawOpts) ->
|
|||||||
_ ->
|
_ ->
|
||||||
ListenSocket = listen_tcp(PortIP, Module, SockOpts, Port, IPS),
|
ListenSocket = listen_tcp(PortIP, Module, SockOpts, Port, IPS),
|
||||||
ets:insert(listen_sockets, {PortIP, ListenSocket})
|
ets:insert(listen_sockets, {PortIP, ListenSocket})
|
||||||
|
end
|
||||||
|
catch
|
||||||
|
throw:{error, Error} ->
|
||||||
|
?ERROR_MSG(Error, [])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
start_listeners() ->
|
start_listeners() ->
|
||||||
|
Loading…
Reference in New Issue
Block a user