From 1bd560f3f25d0a644bac3d06904ca97e20a6f7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Wed, 1 Apr 2020 14:35:49 +0200 Subject: Fix potential message loss in terminating c2s sessions Calling sync version of xmpp_stream_in/out:stop could lead to messages never being processed by c2s process if they were queued in p1_server. This could be reproduced by when having messages in offline storage, starting sessions, enabling stream_mgmt, sending initial presence, and then immediately , messages that mod_offline would send process would not be bounced back by stream_mgmt. --- src/ejabberd_s2s_in.erl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/ejabberd_s2s_in.erl') diff --git a/src/ejabberd_s2s_in.erl b/src/ejabberd_s2s_in.erl index 2c838f76..187869cf 100644 --- a/src/ejabberd_s2s_in.erl +++ b/src/ejabberd_s2s_in.erl @@ -38,7 +38,7 @@ -export([handle_unexpected_info/2, handle_unexpected_cast/2, reject_unauthenticated_packet/2, process_closed/2]). %% API --export([stop/1, close/1, close/2, send/2, update_state/2, establish/1, +-export([stop_async/1, close/1, close/2, send/2, update_state/2, establish/1, host_up/1, host_down/1]). -include("xmpp.hrl"). @@ -64,8 +64,9 @@ close(Ref) -> close(Ref, Reason) -> xmpp_stream_in:close(Ref, Reason). -stop(Ref) -> - xmpp_stream_in:stop(Ref). +-spec stop_async(pid()) -> ok. +stop_async(Pid) -> + xmpp_stream_in:stop_async(Pid). accept(Ref) -> xmpp_stream_in:accept(Ref). @@ -130,7 +131,8 @@ process_closed(#{server := LServer} = State, Reason) -> end, ?INFO_MSG("Closing inbound s2s connection ~ts -> ~ts: ~ts", [RServer, LServer, xmpp_stream_out:format_error(Reason)]), - stop(State). + stop_async(self()), + State. %%%=================================================================== %%% xmpp_stream_in callbacks -- cgit v1.2.3