aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mod_ping.erl2
-rw-r--r--src/xmpp_stream_in.erl10
-rw-r--r--src/xmpp_stream_out.erl10
3 files changed, 21 insertions, 1 deletions
diff --git a/src/mod_ping.erl b/src/mod_ping.erl
index 2256b577c..1164bf44a 100644
--- a/src/mod_ping.erl
+++ b/src/mod_ping.erl
@@ -146,7 +146,7 @@ handle_cast({iq_pong, JID, timeout}, State) ->
JID,
case ejabberd_sm:get_session_pid(User, Server, Resource)
of
- Pid when is_pid(Pid) -> ejabberd_c2s:close(Pid);
+ Pid when is_pid(Pid) -> ejabberd_c2s:close(Pid, _SendTrailer = false);
_ -> ok
end;
_ -> ok
diff --git a/src/xmpp_stream_in.erl b/src/xmpp_stream_in.erl
index b781bdf14..7d5a7e0b4 100644
--- a/src/xmpp_stream_in.erl
+++ b/src/xmpp_stream_in.erl
@@ -271,6 +271,16 @@ handle_cast({send, Pkt}, State) ->
noreply(send_pkt(State, Pkt));
handle_cast(stop, State) ->
{stop, normal, State};
+handle_cast({close, SendTrailer}, #{mod := Mod} = State) ->
+ noreply(
+ case is_disconnected(State) of
+ true -> State;
+ false ->
+ State1 = close(State, SendTrailer),
+ try Mod:handle_stream_end({socket, closed}, State1)
+ catch _:undef -> stop(State1)
+ end
+ end);
handle_cast(Cast, #{mod := Mod} = State) ->
noreply(try Mod:handle_cast(Cast, State)
catch _:undef -> State
diff --git a/src/xmpp_stream_out.erl b/src/xmpp_stream_out.erl
index d0a39158d..7f6291a57 100644
--- a/src/xmpp_stream_out.erl
+++ b/src/xmpp_stream_out.erl
@@ -302,6 +302,16 @@ handle_cast({send, Pkt}, State) ->
noreply(send_pkt(State, Pkt));
handle_cast(stop, State) ->
{stop, normal, State};
+handle_cast({close, SendTrailer}, #{mod := Mod} = State) ->
+ noreply(
+ case is_disconnected(State) of
+ true -> State;
+ false ->
+ State1 = close(State, SendTrailer),
+ try Mod:handle_stream_end({socket, closed}, State1)
+ catch _:undef -> stop(State1)
+ end
+ end);
handle_cast(Cast, #{mod := Mod} = State) ->
noreply(try Mod:handle_cast(Cast, State)
catch _:undef -> State