aboutsummaryrefslogtreecommitdiff
path: root/src/xmpp_stream_out.erl
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-04-04 09:52:42 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-04-04 09:52:42 +0300
commit408f9b515e6a400018297c6c85c907b039f868b7 (patch)
tree1039f2f1d23ad9f0271049c7980913d5961ac6d1 /src/xmpp_stream_out.erl
parentImprove redis related code (diff)
Fix c2s connection close on demand
Fixes #1652
Diffstat (limited to 'src/xmpp_stream_out.erl')
-rw-r--r--src/xmpp_stream_out.erl10
1 files changed, 10 insertions, 0 deletions
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