From 3f667a3cb83103b2de54d20bbf059606e629523e Mon Sep 17 00:00:00 2001 From: Karl Nilsson Date: Mon, 11 Oct 2021 13:30:27 +0100 Subject: amqp10_client: make shutdown scenarios a bit less noisy by handling specific EXIT and DOWN messages that may occur during certain connection closure cases. --- deps/amqp10_client/src/amqp10_client_connection.erl | 11 ++++++++--- deps/amqp10_client/src/amqp10_client_session.erl | 3 ++- deps/rabbitmq_codegen/.DS_Store | Bin 6148 -> 0 bytes 3 files changed, 10 insertions(+), 4 deletions(-) delete mode 100644 deps/rabbitmq_codegen/.DS_Store diff --git a/deps/amqp10_client/src/amqp10_client_connection.erl b/deps/amqp10_client/src/amqp10_client_connection.erl index c56cde2c6e..3a168e3f9b 100644 --- a/deps/amqp10_client/src/amqp10_client_connection.erl +++ b/deps/amqp10_client/src/amqp10_client_connection.erl @@ -92,8 +92,6 @@ -export_type([connection_config/0, amqp10_socket/0]). --define(DEFAULT_TIMEOUT, 5000). - %% ------------------------------------------------------------------- %% Public API. %% ------------------------------------------------------------------- @@ -257,7 +255,7 @@ open_sent(_EvtType, #'v1_0.open'{max_frame_size = MFSz, S2 end, State1, PendingSessionReqs), ok = notify_opened(Config), - {next_state, opened, State2}; + {next_state, opened, State2#state{pending_session_reqs = []}}; open_sent({call, From}, begin_session, #state{pending_session_reqs = PendingSessionReqs} = State) -> State1 = State#state{pending_session_reqs = [From | PendingSessionReqs]}, @@ -297,6 +295,13 @@ opened(_EvtType, Frame, State) -> close_sent(_EvtType, heartbeat, State) -> {next_state, close_sent, State}; +close_sent(_EvtType, {'EXIT', _Pid, shutdown}, State) -> + %% monitored processes may exit during closure + {next_state, close_sent, State}; +close_sent(_EvtType, {'DOWN', _Ref, process, ReaderPid, _}, + #state{reader = ReaderPid} = State) -> + %% if the reader exits we probably wont receive a close frame + {stop, normal, State}; close_sent(_EvtType, #'v1_0.close'{}, State) -> %% TODO: we should probably set up a timer before this to ensure %% we close down event if no reply is received diff --git a/deps/amqp10_client/src/amqp10_client_session.erl b/deps/amqp10_client/src/amqp10_client_session.erl index 09a06fb3a6..83567b74d6 100644 --- a/deps/amqp10_client/src/amqp10_client_session.erl +++ b/deps/amqp10_client/src/amqp10_client_session.erl @@ -957,7 +957,8 @@ amqp10_session_event(Evt) -> socket_send(Sock, Data) -> case socket_send0(Sock, Data) of ok -> ok; - {error, Reason} -> exit({socket_closed, Reason}) + {error, _Reason} -> + throw({stop, normal}) end. -dialyzer({no_fail_call, socket_send0/2}). diff --git a/deps/rabbitmq_codegen/.DS_Store b/deps/rabbitmq_codegen/.DS_Store deleted file mode 100644 index 8fa6166683..0000000000 Binary files a/deps/rabbitmq_codegen/.DS_Store and /dev/null differ -- cgit v1.2.1