@@ -287,6 +287,20 @@ 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+ case send_close (State , Reason ) of
292+ ok ->
293+ % % "After writing this frame the peer SHOULD continue to read from the connection
294+ % % until it receives the partner's close frame (in order to guard against
295+ % % erroneously or maliciously implemented partners, a peer SHOULD implement a
296+ % % timeout to give its partner a reasonable time to receive and process the close
297+ % % before giving up and simply closing the underlying transport mechanism)." [§2.4.3]
298+ {next_state , close_sent , State , {state_timeout , ? TIMEOUT , received_no_close_frame }};
299+ {error , closed } ->
300+ {stop , normal , State };
301+ Error ->
302+ {stop , Error , State }
303+ end ;
290304open_sent (info , {'DOWN' , MRef , process , _ , _ },
291305 # state {reader_m_ref = MRef }) ->
292306 {stop , {shutdown , reader_down }}.
@@ -345,7 +359,10 @@ close_sent(_EvtType, #'v1_0.close'{} = Close, #state{config = Config}) ->
345359 ok = notify_closed (Config , Close ),
346360 {stop , normal };
347361close_sent (state_timeout , received_no_close_frame , _Data ) ->
348- {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 .
349366
350367set_other_procs0 (OtherProcs , State ) ->
351368 #{sessions_sup := SessionsSup ,
0 commit comments