summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@lshift.net>2010-04-09 16:07:12 +0100
committerMatthias Radestock <matthias@lshift.net>2010-04-09 16:07:12 +0100
commit180234087c7ad3e32b5439479fdd9603fa955bc6 (patch)
treedf214ae40fd70a1fa20e9e44de0a3e0460c9df71
parente15fb7a2d85813ca573761cc1bff30eb076a44df (diff)
downloadrabbitmq-server-180234087c7ad3e32b5439479fdd9603fa955bc6.tar.gz
refactor: add rabbit_misc:unlink_and_capture_exit/1
This was cherry-picked from the bug21673 branch
-rw-r--r--src/rabbit_limiter.erl5
-rw-r--r--src/rabbit_misc.erl9
2 files changed, 9 insertions, 5 deletions
diff --git a/src/rabbit_limiter.erl b/src/rabbit_limiter.erl
index 7d840861..878af029 100644
--- a/src/rabbit_limiter.erl
+++ b/src/rabbit_limiter.erl
@@ -249,10 +249,7 @@ notify_queues(State = #lim{ch_pid = ChPid, queues = Queues}) ->
State#lim{queues = NewQueues}.
unlink_on_stopped(LimiterPid, stopped) ->
- true = unlink(LimiterPid),
- ok = receive {'EXIT', LimiterPid, _Reason} -> ok
- after 0 -> ok
- end,
+ ok = rabbit_misc:unlink_and_capture_exit(LimiterPid),
stopped;
unlink_on_stopped(_LimiterPid, Result) ->
Result.
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index 610f0d9c..6d50fb32 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -59,7 +59,7 @@
-export([sort_field_table/1]).
-export([pid_to_string/1, string_to_pid/1]).
-export([version_compare/2, version_compare/3]).
--export([dict_cons/3]).
+-export([dict_cons/3, unlink_and_capture_exit/1]).
-import(mnesia).
-import(lists).
@@ -138,6 +138,7 @@
-spec(version_compare/3 :: (string(), string(), ('lt' | 'lte' | 'eq' | 'gte' | 'gt')) ->
boolean()).
-spec(dict_cons/3 :: (any(), any(), dict()) -> dict()).
+-spec(unlink_and_capture_exit/1 :: (pid()) -> 'ok').
-endif.
@@ -609,3 +610,9 @@ version_compare(A, B) ->
dict_cons(Key, Value, Dict) ->
dict:update(Key, fun (List) -> [Value | List] end, [Value], Dict).
+
+unlink_and_capture_exit(Pid) ->
+ unlink(Pid),
+ receive {'EXIT', Pid, _} -> ok
+ after 0 -> ok
+ end.