Skip to content

Commit 77e3636

Browse files
committed
amqp10_client: Handle close message in the open_sent state
[Why] Without this, the connection process crashes. We see this happenning in CI frequently.
1 parent 2c66191 commit 77e3636

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

deps/amqp10_client/src/amqp10_client_connection.erl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,22 @@ open_sent({call, From}, begin_session,
287287
#state{pending_session_reqs = PendingSessionReqs} = State) ->
288288
State1 = State#state{pending_session_reqs = [From | PendingSessionReqs]},
289289
{keep_state, State1};
290+
open_sent(_EvtType, {close, Reason}, State) ->
291+
%% TODO: stop all sessions writing
292+
%% We could still accept incoming frames (See: 2.4.6)
293+
case send_close(State, Reason) of
294+
ok ->
295+
%% "After writing this frame the peer SHOULD continue to read from the connection
296+
%% until it receives the partner's close frame (in order to guard against
297+
%% erroneously or maliciously implemented partners, a peer SHOULD implement a
298+
%% timeout to give its partner a reasonable time to receive and process the close
299+
%% before giving up and simply closing the underlying transport mechanism)." [§2.4.3]
300+
{next_state, close_sent, State, {state_timeout, ?TIMEOUT, received_no_close_frame}};
301+
{error, closed} ->
302+
{stop, normal, State};
303+
Error ->
304+
{stop, Error, State}
305+
end;
290306
open_sent(info, {'DOWN', MRef, process, _, _},
291307
#state{reader_m_ref = MRef}) ->
292308
{stop, {shutdown, reader_down}}.

0 commit comments

Comments
 (0)