From 21b3a3a292f5d72f0b42812e55309ddeb576605a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Thu, 4 May 2017 18:05:52 +0200 Subject: [PATCH 1/4] amqp_direct_connection.erl: Use rabbit_cert_info ... to query certificate informations, instead of rabbit_ssl. The former is provided by rabbitmq-common while the latter is in rabbitmq-server. It allows to remove a dependency of the Erlang client on the broker. [#118490793] --- deps/amqp_client/src/amqp_direct_connection.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deps/amqp_client/src/amqp_direct_connection.erl b/deps/amqp_client/src/amqp_direct_connection.erl index 429a7da8d4..54d69aed51 100644 --- a/deps/amqp_client/src/amqp_direct_connection.erl +++ b/deps/amqp_client/src/amqp_direct_connection.erl @@ -212,11 +212,11 @@ ssl_cert_info(Sock) -> case rabbit_net:peercert(Sock) of {ok, Cert} -> [{peer_cert_issuer, list_to_binary( - rabbit_ssl:peer_cert_issuer(Cert))}, + rabbit_cert_info:issuer(Cert))}, {peer_cert_subject, list_to_binary( - rabbit_ssl:peer_cert_subject(Cert))}, + rabbit_cert_info:subject(Cert))}, {peer_cert_validity, list_to_binary( - rabbit_ssl:peer_cert_validity(Cert))}]; + rabbit_cert_info:validity(Cert))}]; _ -> [] end. From 987c437106b8a71aac52e8dcd06d34e666b1eee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Thu, 4 May 2017 18:52:04 +0200 Subject: [PATCH 2/4] amqp_network_connection: Use the new rabbit_ssl_options module rabbit_networking will shortly be moved to rabbitmq-server to fix a dependency of this module on the broker. [#118490793] --- deps/amqp_client/src/amqp_network_connection.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/amqp_client/src/amqp_network_connection.erl b/deps/amqp_client/src/amqp_network_connection.erl index e4061466bb..cd3c7061ab 100644 --- a/deps/amqp_client/src/amqp_network_connection.erl +++ b/deps/amqp_client/src/amqp_network_connection.erl @@ -144,7 +144,7 @@ do_connect({Addr, Family}, [Family | ?RABBIT_TCP_OPTS] ++ ExtraOpts, Timeout) of {ok, Sock} -> - SslOpts = rabbit_networking:fix_ssl_options( + SslOpts = rabbit_ssl_options:fix( orddict:to_list( orddict:merge(fun (_, _A, B) -> B end, orddict:from_list(GlobalSslOpts), From 692163ee1e3484e7571cc8d41f0b3e23fcddcb84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Thu, 4 May 2017 19:29:03 +0200 Subject: [PATCH 3/4] amqp_channel: Use the new rabbit_amqqueue_common module rabbit_amqqueue will shortly be moved to rabbitmq-server to fix a dependency of this module on the broker. [#118490793] --- deps/amqp_client/src/amqp_channel.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deps/amqp_client/src/amqp_channel.erl b/deps/amqp_client/src/amqp_channel.erl index 8dab307389..507fd862c6 100644 --- a/deps/amqp_client/src/amqp_channel.erl +++ b/deps/amqp_client/src/amqp_channel.erl @@ -103,7 +103,7 @@ %% true | false, only relevant in the direct %% client case. %% when true, consumers will manually notify - %% queue pids using rabbit_amqqueue:notify_sent/2 + %% queue pids using rabbit_amqqueue_common:notify_sent/2 %% to prevent the queue from overwhelming slow %% consumers that use automatic acknowledgement %% mode. @@ -425,7 +425,7 @@ handle_cast(enable_delivery_flow_control, State) -> {noreply, State#state{delivery_flow_control = true}}; %% @private handle_cast({send_notify, {QPid, ChPid}}, State) -> - rabbit_amqqueue:notify_sent(QPid, ChPid), + rabbit_amqqueue_common:notify_sent(QPid, ChPid), {noreply, State}; %% @private handle_cast({cast, Method, AmqpMsg, Sender, noflow}, State) -> @@ -489,7 +489,7 @@ handle_info({send_command_and_notify, QPid, ChPid, State = #state{delivery_flow_control = MFC}) -> case MFC of false -> handle_method_from_server(Method, Content, State), - rabbit_amqqueue:notify_sent(QPid, ChPid); + rabbit_amqqueue_common:notify_sent(QPid, ChPid); true -> handle_method_from_server(Method, Content, {self(), QPid, ChPid}, State) end, @@ -530,7 +530,7 @@ handle_info({'DOWN', _, process, FlowHandler, Reason}, "Reason: ~p~n", [self(), FlowHandler, Reason]), {noreply, State#state{flow_handler = none}}; handle_info({'DOWN', _, process, QPid, _Reason}, State) -> - rabbit_amqqueue:notify_sent_queue_down(QPid), + rabbit_amqqueue_common:notify_sent_queue_down(QPid), {noreply, State}; handle_info({confirm_timeout, From}, State = #state{waiting_set = WSet}) -> case gb_trees:lookup(From, WSet) of From 1feb5c857b388d200366a7e4a6a144b5f4f3a076 Mon Sep 17 00:00:00 2001 From: Paul Schoenfelder Date: Tue, 9 May 2017 12:42:42 -0500 Subject: [PATCH 4/4] Properly handle trapped exits in amqp_gen_connection - Trapped exits were being forwarded to the connection module when it has no knowledge of what to do with them - These unhandled exit messages were causing errors to occur unnecessarily - This changeset ensures trapped exits are handled by the trapping process --- deps/amqp_client/src/amqp_gen_connection.erl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/deps/amqp_client/src/amqp_gen_connection.erl b/deps/amqp_client/src/amqp_gen_connection.erl index f810626f7b..dfcd359a1e 100644 --- a/deps/amqp_client/src/amqp_gen_connection.erl +++ b/deps/amqp_client/src/amqp_gen_connection.erl @@ -224,6 +224,14 @@ handle_info({'DOWN', _, process, BlockHandler, Reason}, ?LOG_WARN("Connection (~p): Unregistering block handler ~p because it died. " "Reason: ~p~n", [self(), BlockHandler, Reason]), {noreply, State#state{block_handler = none}}; +handle_info({'EXIT', BlockHandler, Reason}, + State = #state{block_handler = {BlockHandler, Ref}}) -> + ?LOG_WARN("Connection (~p): Unregistering block handler ~p because it died. " + "Reason: ~p~n", [self(), BlockHandler, Reason]), + erlang:demonitor(Ref, [flush]), + {noreply, State#state{block_handler = none}}; +handle_info({'EXIT', _Pid, _Reason}, State) -> + {noreply, State}; handle_info(Info, State) -> callback(handle_message, [Info], State).