25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Set process flags when Erlang/OTP 27 to help debugging

https://www.erlang.org/blog/highlights-otp-27/#process-labels
This commit is contained in:
Badlop 2024-05-23 19:34:21 +02:00
parent 5d2a111b9c
commit 034af6aefd
4 changed files with 15 additions and 0 deletions

View File

@ -290,6 +290,7 @@ reject_unauthenticated_packet(State, _Pkt) ->
process_auth_result(#{sasl_mech := Mech, auth_module := AuthModule,
socket := Socket, ip := IP, lserver := LServer} = State,
true, User) ->
misc:set_proc_label({?MODULE, User, LServer}),
?INFO_MSG("(~ts) Accepted c2s ~ts authentication for ~ts@~ts by ~ts backend from ~ts",
[xmpp_socket:pp(Socket), Mech, User, LServer,
ejabberd_auth:backend_type(AuthModule),
@ -617,6 +618,7 @@ init([State, Opts]) ->
access => Access,
shaper => Shaper},
State2 = xmpp_stream_in:set_timeout(State1, Timeout),
misc:set_proc_label({?MODULE, init_state}),
ejabberd_hooks:run_fold(c2s_init, {ok, State2}, [Opts]).
handle_call(get_presence, From, #{jid := JID} = State) ->

View File

@ -121,6 +121,7 @@ init({Port, _, udp} = EndPoint, Module, Opts, SockOpts) ->
ExtraOpts2]) of
{ok, Socket} ->
set_definitive_udsocket(Port, Opts),
misc:set_proc_label({?MODULE, udp, Port}),
case inet:sockname(Socket) of
{ok, {Addr, Port1}} ->
proc_lib:init_ack({ok, self()}),
@ -155,6 +156,7 @@ init({Port, _, tcp} = EndPoint, Module, Opts, SockOpts) ->
case inet:sockname(ListenSocket) of
{ok, {Addr, Port1}} ->
proc_lib:init_ack({ok, self()}),
misc:set_proc_label({?MODULE, tcp, Port}),
case application:ensure_started(ejabberd) of
ok ->
Sup = start_module_sup(Module, Opts),

View File

@ -43,6 +43,7 @@
get_my_ipv4_address/0, get_my_ipv6_address/0, parse_ip_mask/1,
crypto_hmac/3, crypto_hmac/4, uri_parse/1, uri_parse/2, uri_quote/1,
json_encode/1, json_decode/1,
set_proc_label/1,
match_ip_mask/3, format_hosts_list/1, format_cycle/1, delete_dir/1,
semver_to_xxyy/1, logical_processors/0, get_mucsub_event_type/1]).
@ -780,3 +781,11 @@ to_string(B) when is_binary(B) ->
binary_to_list(B);
to_string(S) ->
S.
-ifdef(OTP_BELOW_27).
set_proc_label(_Label) ->
ok.
-else.
set_proc_label(Label) ->
proc_lib:set_label(Label).
-endif.

View File

@ -292,6 +292,7 @@ get_disco_item(Pid, Filter, JID, Lang) ->
init([Host, ServerHost, Access, Room, HistorySize,
RoomShaper, Creator, _Nick, DefRoomOpts, QueueType]) ->
process_flag(trap_exit, true),
misc:set_proc_label({?MODULE, Room, Host}),
Shaper = ejabberd_shaper:new(RoomShaper),
RoomQueue = room_queue_new(ServerHost, Shaper, QueueType),
State = set_opts(DefRoomOpts,
@ -314,6 +315,7 @@ init([Host, ServerHost, Access, Room, HistorySize,
{ok, normal_state, reset_hibernate_timer(State1)};
init([Host, ServerHost, Access, Room, HistorySize, RoomShaper, Opts, QueueType]) ->
process_flag(trap_exit, true),
misc:set_proc_label({?MODULE, Room, Host}),
Shaper = ejabberd_shaper:new(RoomShaper),
RoomQueue = room_queue_new(ServerHost, Shaper, QueueType),
Jid = jid:make(Room, Host),