25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

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, JID,
case ejabberd_sm:get_session_pid(User, Server, Resource) case ejabberd_sm:get_session_pid(User, Server, Resource)
of of
Pid when is_pid(Pid) -> ejabberd_c2s:close(Pid); Pid when is_pid(Pid) -> ejabberd_c2s:close(Pid, _SendTrailer = false);
_ -> ok _ -> ok
end; end;
_ -> ok _ -> ok

View File

@ -271,6 +271,16 @@ handle_cast({send, Pkt}, State) ->
noreply(send_pkt(State, Pkt)); noreply(send_pkt(State, Pkt));
handle_cast(stop, State) -> handle_cast(stop, State) ->
{stop, normal, 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) -> handle_cast(Cast, #{mod := Mod} = State) ->
noreply(try Mod:handle_cast(Cast, State) noreply(try Mod:handle_cast(Cast, State)
catch _:undef -> State catch _:undef -> State

View File

@ -302,6 +302,16 @@ handle_cast({send, Pkt}, State) ->
noreply(send_pkt(State, Pkt)); noreply(send_pkt(State, Pkt));
handle_cast(stop, State) -> handle_cast(stop, State) ->
{stop, normal, 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) -> handle_cast(Cast, #{mod := Mod} = State) ->
noreply(try Mod:handle_cast(Cast, State) noreply(try Mod:handle_cast(Cast, State)
catch _:undef -> State catch _:undef -> State