24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-09-27 14:30:55 +02:00

Before binding tcp ports, checks the socket type and listener options

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:
Andreas Köhler 2010-11-08 13:46:56 +01:00 committed by Badlop
parent 1f1d2bd5f5
commit 18ef908759

View File

@ -59,18 +59,29 @@ bind_tcp_ports() ->
Ls -> Ls ->
lists:foreach( lists:foreach(
fun({Port, Module, Opts}) -> fun({Port, Module, Opts}) ->
bind_tcp_port(Port, Module, Opts) ModuleRaw = strip_frontend(Module),
case ModuleRaw:socket_type() of
independent -> ok;
_ ->
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) ->
{Port, IPT, IPS, IPV, Proto, OptsClean} = parse_listener_portip(PortIP, RawOpts), try check_listener_options(RawOpts) of
{_Opts, SockOpts} = prepare_opts(IPT, IPV, OptsClean), ok ->
case Proto of {Port, IPT, IPS, IPV, Proto, OptsClean} = parse_listener_portip(PortIP, RawOpts),
udp -> ok; {_Opts, SockOpts} = prepare_opts(IPT, IPV, OptsClean),
_ -> case Proto of
ListenSocket = listen_tcp(PortIP, Module, SockOpts, Port, IPS), udp -> ok;
ets:insert(listen_sockets, {PortIP, ListenSocket}) _ ->
ListenSocket = listen_tcp(PortIP, Module, SockOpts, Port, IPS),
ets:insert(listen_sockets, {PortIP, ListenSocket})
end
catch
throw:{error, Error} ->
?ERROR_MSG(Error, [])
end. end.
start_listeners() -> start_listeners() ->