diff options
author | Paweł Chmielowski <pchmielowski@process-one.net> | 2020-04-01 14:35:49 +0200 |
---|---|---|
committer | Paweł Chmielowski <pchmielowski@process-one.net> | 2020-04-01 14:36:01 +0200 |
commit | 1bd560f3f25d0a644bac3d06904ca97e20a6f7d9 (patch) | |
tree | 3d74c9bc22f95409ebda8cc230169283096e9188 /src/ejabberd_s2s_in.erl | |
parent | Use different username than other tests, but still include the test chars (diff) |
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
</stream:stream>, messages that mod_offline would send process would not
be bounced back by stream_mgmt.
Diffstat (limited to 'src/ejabberd_s2s_in.erl')
-rw-r--r-- | src/ejabberd_s2s_in.erl | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/ejabberd_s2s_in.erl b/src/ejabberd_s2s_in.erl index 2c838f76e..187869cfb 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 |