summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2013-03-21 15:32:34 +0000
committerSimon MacMullen <simon@rabbitmq.com>2013-03-21 15:32:34 +0000
commit2b92d88ef576b8fb78bdef5ce6415595f3bd86c1 (patch)
tree383a7fe91e8fbbb19ebc6cb20a1e3a2ab9345be6
parentb2fda93a52018e50b46924e170c7482f9803eec3 (diff)
downloadrabbitmq-server-git-2b92d88ef576b8fb78bdef5ce6415595f3bd86c1.tar.gz
Do the pinging in a separate process so we don't block the node monitor.
-rw-r--r--src/rabbit_node_monitor.erl24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/rabbit_node_monitor.erl b/src/rabbit_node_monitor.erl
index 4aaf634ea5..16b52a4d9a 100644
--- a/src/rabbit_node_monitor.erl
+++ b/src/rabbit_node_monitor.erl
@@ -276,13 +276,25 @@ handle_info({mnesia_system_event,
handle_info(ping_nodes, State) ->
%% We ping nodes when some are down to ensure that we find out
%% about healed partitions quickly. We ping all nodes rather than
- %% just the ones we know are down for simplicity; it's not expensive.
+ %% just the ones we know are down for simplicity; it's not expensive
+ %% to ping the nodes that are up, after all.
State1 = State#state{down_ping_timer = undefined},
- %% ratio() both pings all the nodes and tells us if we need to again :-)
- {noreply, case ratio() of
- 1.0 -> State1;
- _ -> ensure_ping_timer(State1)
- end};
+ Self = self(),
+ %% ratio() both pings all the nodes and tells us if we need to again.
+ %%
+ %% We ping in a separate process since in a partition it might
+ %% take some noticeable length of time and we don't want to block
+ %% the node monitor for that long.
+ spawn_link(fun () ->
+ case ratio() of
+ 1.0 -> ok;
+ _ -> Self ! ping_again
+ end
+ end),
+ {noreply, State1};
+
+handle_info(ping_again, State) ->
+ {noreply, ensure_ping_timer(State)};
handle_info(_Info, State) ->
{noreply, State}.