mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-06 21:37:17 +02:00
Fix closing of outbound S2S connections
This commit is contained in:
parent
fcb978248f
commit
c290b4284f
|
@ -233,7 +233,8 @@ c2s_handle_info(#{mgmt_ack_timer := TRef, jid := JID, mod := Mod} = State,
|
||||||
{timeout, TRef, ack_timeout}) ->
|
{timeout, TRef, ack_timeout}) ->
|
||||||
?DEBUG("Timed out waiting for stream management acknowledgement of ~s",
|
?DEBUG("Timed out waiting for stream management acknowledgement of ~s",
|
||||||
[jid:encode(JID)]),
|
[jid:encode(JID)]),
|
||||||
{stop, Mod:close(State, ack_timeout)};
|
State1 = Mod:close(State),
|
||||||
|
{stop, transition_to_pending(State1)};
|
||||||
c2s_handle_info(#{mgmt_state := pending, jid := JID, mod := Mod} = State,
|
c2s_handle_info(#{mgmt_state := pending, jid := JID, mod := Mod} = State,
|
||||||
{timeout, _, pending_timeout}) ->
|
{timeout, _, pending_timeout}) ->
|
||||||
?DEBUG("Timed out waiting for resumption of stream for ~s",
|
?DEBUG("Timed out waiting for resumption of stream for ~s",
|
||||||
|
|
|
@ -151,23 +151,17 @@ send(_, _) ->
|
||||||
|
|
||||||
-spec close(pid()) -> ok;
|
-spec close(pid()) -> ok;
|
||||||
(state()) -> state().
|
(state()) -> state().
|
||||||
close(Ref) ->
|
close(Pid) when is_pid(Pid) ->
|
||||||
close(Ref, closed).
|
close(Pid, closed);
|
||||||
|
close(#{owner := Owner} = State) when Owner == self() ->
|
||||||
-spec close(pid(), atom()) -> ok;
|
close_socket(State);
|
||||||
(state(), atom()) -> state().
|
close(_) ->
|
||||||
close(Pid, Reason) when is_pid(Pid) ->
|
|
||||||
cast(Pid, {close, Reason});
|
|
||||||
close(#{owner := Owner} = State, Reason) when Owner == self() ->
|
|
||||||
case is_disconnected(State) of
|
|
||||||
true -> State;
|
|
||||||
false ->
|
|
||||||
_IgnoreState = close_socket(State),
|
|
||||||
process_stream_end({socket, Reason}, State)
|
|
||||||
end;
|
|
||||||
close(_, _) ->
|
|
||||||
erlang:error(badarg).
|
erlang:error(badarg).
|
||||||
|
|
||||||
|
-spec close(pid(), atom()) -> ok.
|
||||||
|
close(Pid, Reason) ->
|
||||||
|
cast(Pid, {close, Reason}).
|
||||||
|
|
||||||
-spec establish(state()) -> state().
|
-spec establish(state()) -> state().
|
||||||
establish(State) ->
|
establish(State) ->
|
||||||
process_stream_established(State).
|
process_stream_established(State).
|
||||||
|
@ -275,7 +269,12 @@ handle_cast({send, Pkt}, State) ->
|
||||||
handle_cast(stop, State) ->
|
handle_cast(stop, State) ->
|
||||||
{stop, normal, State};
|
{stop, normal, State};
|
||||||
handle_cast({close, Reason}, State) ->
|
handle_cast({close, Reason}, State) ->
|
||||||
noreply(close(State, Reason));
|
State1 = close_socket(State),
|
||||||
|
noreply(
|
||||||
|
case is_disconnected(State) of
|
||||||
|
true -> State1;
|
||||||
|
false -> process_stream_end({socket, Reason}, State)
|
||||||
|
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
|
||||||
|
|
|
@ -161,23 +161,17 @@ send(_, _) ->
|
||||||
|
|
||||||
-spec close(pid()) -> ok;
|
-spec close(pid()) -> ok;
|
||||||
(state()) -> state().
|
(state()) -> state().
|
||||||
close(Ref) ->
|
close(Pid) when is_pid(Pid) ->
|
||||||
close(Ref, closed).
|
close(Pid, closed);
|
||||||
|
close(#{owner := Owner} = State) when Owner == self() ->
|
||||||
-spec close(pid(), atom()) -> ok;
|
close_socket(State);
|
||||||
(state(), atom()) -> state().
|
close(_) ->
|
||||||
close(Pid, Reason) when is_pid(Pid) ->
|
|
||||||
cast(Pid, {close, Reason});
|
|
||||||
close(#{owner := Owner} = State, Reason) when Owner == self() ->
|
|
||||||
case is_disconnected(State) of
|
|
||||||
true -> State;
|
|
||||||
false ->
|
|
||||||
_IgnoreState = close_socket(State),
|
|
||||||
process_stream_end({socket, Reason}, State)
|
|
||||||
end;
|
|
||||||
close(_, _) ->
|
|
||||||
erlang:error(badarg).
|
erlang:error(badarg).
|
||||||
|
|
||||||
|
-spec close(pid(), atom()) -> ok.
|
||||||
|
close(Pid, Reason) ->
|
||||||
|
cast(Pid, {close, Reason}).
|
||||||
|
|
||||||
-spec establish(state()) -> state().
|
-spec establish(state()) -> state().
|
||||||
establish(State) ->
|
establish(State) ->
|
||||||
process_stream_established(State).
|
process_stream_established(State).
|
||||||
|
@ -306,7 +300,12 @@ handle_cast({send, Pkt}, State) ->
|
||||||
handle_cast(stop, State) ->
|
handle_cast(stop, State) ->
|
||||||
{stop, normal, State};
|
{stop, normal, State};
|
||||||
handle_cast({close, Reason}, State) ->
|
handle_cast({close, Reason}, State) ->
|
||||||
noreply(close(State, Reason));
|
State1 = close_socket(State),
|
||||||
|
noreply(
|
||||||
|
case is_disconnected(State) of
|
||||||
|
true -> State1;
|
||||||
|
false -> process_stream_end({socket, Reason}, State)
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user