Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

Commit

Permalink
It makes more sense to monitor the remote supervisor than the remote …
Browse files Browse the repository at this point in the history
…node, so lets do that.
  • Loading branch information
Simon MacMullen committed Oct 20, 2014
1 parent f21843d commit ba52b73
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/amqp_direct_connection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ handle_message({force_event_refresh, Ref}, State = #state{node = Node}) ->
{ok, State};
handle_message(closing_timeout, State = #state{closing_reason = Reason}) ->
{stop, {closing_timeout, Reason}, State};
handle_message({nodedown, Node}, State = #state{node = Node}) ->
{stop, {nodedown, Node}, State};
handle_message({'DOWN', _MRef, process, _ConnSup, Reason},
State = #state{node = Node}) ->
{stop, {remote_node_down, Reason}, State};
handle_message(Msg, State) ->
{stop, {unexpected_msg, Msg}, State}.

Expand Down Expand Up @@ -136,7 +137,13 @@ connect(Params = #amqp_params_direct{username = Username,
{ok, ChMgr, Collector} = SIF(i(name, State1)),
State2 = State1#state{user = User,
collector = Collector},
erlang:monitor_node(Node, true),
%% There's no real connection-level process on the remote
%% node for us to monitor or link to, but we want to
%% detect connection death if the remote node goes down
%% when there are no channels. So we monitor the
%% supervisor; that way we find out if the node goes down
%% or the rabbit app stops.
erlang:monitor(process, {rabbit_direct_client_sup, Node}),
{ok, {ServerProperties, 0, ChMgr, State2}};
{error, _} = E ->
E;
Expand Down

0 comments on commit ba52b73

Please sign in to comment.