aboutsummaryrefslogtreecommitdiff
path: root/src/ejabberd_service.erl
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2020-04-01 14:35:49 +0200
committerPaweł Chmielowski <pchmielowski@process-one.net>2020-04-01 14:36:01 +0200
commit1bd560f3f25d0a644bac3d06904ca97e20a6f7d9 (patch)
tree3d74c9bc22f95409ebda8cc230169283096e9188 /src/ejabberd_service.erl
parentUse 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 '')
-rw-r--r--src/ejabberd_service.erl11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/ejabberd_service.erl b/src/ejabberd_service.erl
index 92350956d..a5270b54d 100644
--- a/src/ejabberd_service.erl
+++ b/src/ejabberd_service.erl
@@ -33,7 +33,7 @@
-export([handle_stream_start/2, handle_auth_success/4, handle_auth_failure/4,
handle_authenticated_packet/2, get_password_fun/1, tls_options/1]).
%% API
--export([send/2, close/1, close/2, stop/1]).
+-export([send/2, close/1, close/2, stop_async/1]).
-include("xmpp.hrl").
-include("logger.hrl").
@@ -59,7 +59,7 @@ stop() ->
lists:foreach(
fun({_Id, Pid, _Type, _Module}) ->
send(Pid, Err),
- stop(Pid),
+ stop_async(Pid),
supervisor:terminate_child(ejabberd_service_sup, Pid)
end, supervisor:which_children(ejabberd_service_sup)),
_ = supervisor:terminate_child(ejabberd_sup, ejabberd_service_sup),
@@ -83,10 +83,9 @@ close(Ref) ->
close(Ref, Reason) ->
xmpp_stream_in:close(Ref, Reason).
--spec stop(pid()) -> ok;
- (state()) -> no_return().
-stop(Ref) ->
- xmpp_stream_in:stop(Ref).
+-spec stop_async(pid()) -> ok.
+stop_async(Pid) ->
+ xmpp_stream_in:stop_async(Pid).
%%%===================================================================
%%% xmpp_stream_in callbacks