1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-03 01:39:35 +02:00

Compare commits

...

3 commits

Author SHA1 Message Date
Badlop
3183e2f733 Fix dialyzer warnings in recent commit 2025-08-15 16:33:05 +02:00
Badlop
e1dc686ae7 mod_conversejs: Ensure assets_path ends in / as required by Converse (#4414) 2025-08-15 15:20:35 +02:00
Badlop
38b203feb1 ejabberd_listener: Use init_fail for errors as recommended by init_ack
That is recommended since OTP 26, see
 https://www.erlang.org/doc/apps/stdlib/proc_lib.html#init_ack/2
 Warning
 Do not use this function to return an error indicating that the process
 start failed. When doing so the start function can return before the
 failing process has exited, which may block VM resources required for a
 new start attempt to succeed. Use init_fail/2,3 for that purpose.
2025-08-15 15:20:33 +02:00
2 changed files with 26 additions and 22 deletions

View file

@ -139,16 +139,13 @@ init({Port, _, udp} = EndPoint, Module, Opts, SockOpts) ->
{error, _} ->
ok
end;
{error, Reason} = Err ->
report_socket_error(Reason, EndPoint, Module),
proc_lib:init_ack(Err)
{error, Reason} ->
return_socket_error(Reason, EndPoint, Module)
end;
{{error, Reason} = Err, _} ->
report_socket_error(Reason, EndPoint, Module),
proc_lib:init_ack(Err);
{_, {error, Reason} = Err} ->
report_socket_error(Reason, EndPoint, Module),
proc_lib:init_ack(Err)
{{error, Reason}, _} ->
return_socket_error(Reason, EndPoint, Module);
{_, {error, Reason} } ->
return_socket_error(Reason, EndPoint, Module)
end;
init({Port, _, tcp} = EndPoint, Module, Opts, SockOpts) ->
case {listen_tcp(Port, SockOpts),
@ -177,16 +174,13 @@ init({Port, _, tcp} = EndPoint, Module, Opts, SockOpts) ->
{error, _} ->
ok
end;
{error, Reason} = Err ->
report_socket_error(Reason, EndPoint, Module),
proc_lib:init_ack(Err)
{error, Reason} ->
return_socket_error(Reason, EndPoint, Module)
end;
{{error, Reason}, _} = Err ->
report_socket_error(Reason, EndPoint, Module),
proc_lib:init_ack(Err);
{_, {error, Reason}} = Err ->
report_socket_error(Reason, EndPoint, Module),
proc_lib:init_ack(Err)
{{error, Reason}, _} ->
return_socket_error(Reason, EndPoint, Module);
{_, {error, Reason}} ->
return_socket_error(Reason, EndPoint, Module)
end.
-spec listen_tcp(inet:port_number(), [gen_tcp:option()]) ->
@ -608,10 +602,20 @@ config_reloaded() ->
end
end, New).
-spec report_socket_error(inet:posix(), endpoint(), module()) -> ok.
report_socket_error(Reason, EndPoint, Module) ->
-spec return_socket_error(inet:posix(), endpoint(), module()) -> no_return().
return_socket_error(Reason, EndPoint, Module) ->
?ERROR_MSG("Failed to open socket at ~ts for ~ts: ~ts",
[format_endpoint(EndPoint), Module, format_error(Reason)]).
[format_endpoint(EndPoint), Module, format_error(Reason)]),
return_init_error(Reason).
-ifdef(OTP_BELOW_26).
return_init_error(Reason) ->
proc_lib:init_ack({error, Reason}).
-else.
-spec return_init_error(inet:posix()) -> no_return().
return_init_error(Reason) ->
proc_lib:init_fail({error, Reason}, {exit, normal}).
-endif.
-spec format_error(inet:posix() | atom()) -> string().
format_error(Reason) ->

View file

@ -69,7 +69,7 @@ process([], #request{method = 'GET', host = Host, q = Query, raw_path = RawPath1
{<<"default_domain">>, Domain},
{<<"domain_placeholder">>, Domain},
{<<"registration_domain">>, Domain},
{<<"assets_path">>, RawPath},
{<<"assets_path">>, <<RawPath/binary, "/">>},
{<<"view_mode">>, <<"fullscreen">>}
| ExtraOptions],
Init2 =