25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +01:00

Improve logging of idle s2s connections

This commit is contained in:
Evgeniy Khramtsov 2018-01-28 11:10:22 +03:00
parent 6e5439db5c
commit 795efb2ee1
3 changed files with 10 additions and 6 deletions

View File

@ -254,10 +254,12 @@ handle_recv(El, Pkt, #{server_host := ServerHost} = State) ->
handle_send(El, Pkt, #{server_host := ServerHost} = State) ->
ejabberd_hooks:run_fold(s2s_out_handle_send, ServerHost, State, [El, Pkt]).
handle_timeout(#{on_route := Action} = State) ->
handle_timeout(#{on_route := Action, lang := Lang} = State) ->
case Action of
bounce -> stop(State);
_ -> send(State, xmpp:serr_connection_timeout())
_ ->
Txt = <<"Idle connection">>,
send(State, xmpp:serr_connection_timeout(Txt, Lang))
end.
init([#{server := LServer, remote_server := RServer} = State, Opts]) ->

View File

@ -367,11 +367,12 @@ handle_info({'$gen_all_state_event', {xmlstreamcdata, Data}},
noreply(try Mod:handle_cdata(Data, State)
catch _:undef -> State
end);
handle_info(timeout, #{mod := Mod} = State) ->
handle_info(timeout, #{mod := Mod, lang := Lang} = State) ->
Disconnected = is_disconnected(State),
noreply(try Mod:handle_timeout(State)
catch _:undef when not Disconnected ->
send_pkt(State, xmpp:serr_connection_timeout());
Txt = <<"Idle connection">>,
send_pkt(State, xmpp:serr_connection_timeout(Txt, Lang));
_:undef ->
stop(State)
end);

View File

@ -376,11 +376,12 @@ handle_info({'$gen_event', {xmlstreamend, _}}, State) ->
noreply(process_stream_end({stream, reset}, State));
handle_info({'$gen_event', closed}, State) ->
noreply(process_stream_end({socket, closed}, State));
handle_info(timeout, #{mod := Mod} = State) ->
handle_info(timeout, #{mod := Mod, lang := Lang} = State) ->
Disconnected = is_disconnected(State),
noreply(try Mod:handle_timeout(State)
catch _:undef when not Disconnected ->
send_pkt(State, xmpp:serr_connection_timeout());
Txt = <<"Idle connection">>,
send_pkt(State, xmpp:serr_connection_timeout(Txt, Lang));
_:undef ->
stop(State)
end);