Fix c2s connection close on demand

Fixes #1652
This commit is contained in:
Evgeniy Khramtsov 2017-04-04 09:52:42 +03:00
parent 9d9037856c
commit 408f9b515e
3 changed files with 21 additions and 1 deletions

View 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

View 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

View 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