Skip to content

Commit 6557686

Browse files
ansddumbbell
authored andcommitted
amqp10_client: Fix crash in close_sent
Fix crash in close_sent since the client might receive the open frame if it previously sent the close frame in state open_sent. We explicitly ignore the open frame. The alternative is to add another gen_statem state CLOSE_PIPE which might be an overkill however. This commit also fixes a wrong comment: No sessions have begun if the app requests the connection to be closed in state open_sent.
1 parent 77e3636 commit 6557686

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

deps/amqp10_client/src/amqp10_client_connection.erl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@ open_sent({call, From}, begin_session,
288288
State1 = State#state{pending_session_reqs = [From | PendingSessionReqs]},
289289
{keep_state, State1};
290290
open_sent(_EvtType, {close, Reason}, State) ->
291-
%% TODO: stop all sessions writing
292-
%% We could still accept incoming frames (See: 2.4.6)
293291
case send_close(State, Reason) of
294292
ok ->
295293
%% "After writing this frame the peer SHOULD continue to read from the connection
@@ -361,7 +359,10 @@ close_sent(_EvtType, #'v1_0.close'{} = Close, #state{config = Config}) ->
361359
ok = notify_closed(Config, Close),
362360
{stop, normal};
363361
close_sent(state_timeout, received_no_close_frame, _Data) ->
364-
{stop, normal}.
362+
{stop, normal};
363+
close_sent(_EvtType, #'v1_0.open'{}, _Data) ->
364+
%% Transition from CLOSE_PIPE to CLOSE_SENT in figure 2.23.
365+
keep_state_and_data.
365366

366367
set_other_procs0(OtherProcs, State) ->
367368
#{sessions_sup := SessionsSup,

0 commit comments

Comments
 (0)