ejabberd_listener: Let module take over socket

For some use cases, it may be necessary to allow a module to take over
socket ownership during initialization.
This commit is contained in:
Holger Weiss 2022-08-10 18:28:35 +02:00
parent c2cd592eff
commit e858738736
1 changed files with 3 additions and 0 deletions

View File

@ -318,6 +318,9 @@ start_connection(Module, Arity, Socket, State, Sup) ->
supervisor:start_child(Sup, [{gen_tcp, Socket}, State])
end,
case Res of
{ok, Pid, preowned_socket} ->
Module:accept(Pid),
{ok, Pid};
{ok, Pid} ->
case gen_tcp:controlling_process(Socket, Pid) of
ok ->