]> granicus.if.org Git - ejabberd/commitdiff
Fix c2s connection close on demand
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Tue, 4 Apr 2017 06:52:42 +0000 (09:52 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Tue, 4 Apr 2017 06:52:42 +0000 (09:52 +0300)
Fixes #1652

src/mod_ping.erl
src/xmpp_stream_in.erl
src/xmpp_stream_out.erl

index 2256b577c47dc641072f918e1f2b0a7f7fb1defd..1164bf44a23947f50c23d38e3302f51157f1897a 100644 (file)
@@ -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
index b781bdf146cbc206133acd99bce541b900556e2d..7d5a7e0b447c919023bfe16d3aac7e0002636fc1 100644 (file)
@@ -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
index d0a39158d1b3eecaea268e881889ad7276a62a31..7f6291a57b0bcc5237d5b1fd80903625c37d7560 100644 (file)
@@ -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