You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/01/17 23:00:45 UTC
[26/50] git commit: Keep the DOWN notifications DRY
Keep the DOWN notifications DRY
Project: http://git-wip-us.apache.org/repos/asf/couchdb-rexi/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-rexi/commit/eadec1f1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-rexi/tree/eadec1f1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-rexi/diff/eadec1f1
Branch: refs/heads/import
Commit: eadec1f1215f893479952a4b4e8563d56153752c
Parents: 97b6516
Author: Adam Kocoloski <ad...@cloudant.com>
Authored: Fri Oct 7 20:39:13 2011 -0400
Committer: Adam Kocoloski <ad...@cloudant.com>
Committed: Fri Oct 7 20:39:13 2011 -0400
----------------------------------------------------------------------
src/rexi_monitor.erl | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-rexi/blob/eadec1f1/src/rexi_monitor.erl
----------------------------------------------------------------------
diff --git a/src/rexi_monitor.erl b/src/rexi_monitor.erl
index 4d0d36e..ab33fb8 100644
--- a/src/rexi_monitor.erl
+++ b/src/rexi_monitor.erl
@@ -27,7 +27,7 @@ start(Procs) ->
{Mon, Skip} = lists:partition(fun(P) -> should_monitor(P, Nodes) end,
Procs),
spawn_link(fun() ->
- [erlang:send(Parent, {rexi_DOWN, self(), P, noconnect}) || P <- Skip],
+ [notify_parent(Parent, P, noconnect) || P <- Skip],
[erlang:monitor(process, P) || P <- Mon],
wait_monitors(Parent)
end).
@@ -41,6 +41,9 @@ stop(MonitoringPid) ->
%% internal functions %%
+notify_parent(Parent, Pid, Reason) ->
+ erlang:send(Parent, {rexi_DOWN, self(), Pid, Reason}).
+
should_monitor(Pid, Nodes) when is_pid(Pid) ->
lists:member(node(Pid), Nodes);
should_monitor({_, Node}, Nodes) ->
@@ -49,7 +52,7 @@ should_monitor({_, Node}, Nodes) ->
wait_monitors(Parent) ->
receive
{'DOWN', _, process, Pid, Reason} ->
- Parent ! {rexi_DOWN, self(), Pid, Reason},
+ notify_parent(Parent, Pid, Reason),
wait_monitors(Parent);
{Parent, shutdown} ->
ok