summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@lshift.net>2010-04-06 14:00:34 +0100
committerMatthew Sackman <matthew@lshift.net>2010-04-06 14:00:34 +0100
commit70c11fb19bbc6970950b29ada906eb42171cbe02 (patch)
tree8ee12af46a1798c11508317b7954d9eeffdca55c /src
parent45a9ed69352fc4600f33f9e308dc57c97e368d82 (diff)
downloadrabbitmq-server-git-70c11fb19bbc6970950b29ada906eb42171cbe02.tar.gz
Removed code duplication
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_limiter.erl5
-rw-r--r--src/rabbit_misc.erl9
-rw-r--r--src/rabbit_msg_store.erl5
-rw-r--r--src/rabbit_queue_index.erl5
4 files changed, 11 insertions, 13 deletions
diff --git a/src/rabbit_limiter.erl b/src/rabbit_limiter.erl
index 7d84086108..878af02976 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 cd2e7fbc83..340f308f55 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([recursive_delete/1, dict_cons/3]).
+-export([recursive_delete/1, dict_cons/3, unlink_and_capture_exit/1]).
-import(mnesia).
-import(lists).
@@ -136,6 +136,7 @@
-spec(string_to_pid/1 :: (string()) -> pid()).
-spec(recursive_delete/1 :: (string()) -> 'ok' | {'error', any()}).
-spec(dict_cons/3 :: (any(), any(), dict()) -> dict()).
+-spec(unlink_and_capture_exit/1 :: (pid()) -> 'ok').
-endif.
@@ -629,3 +630,9 @@ recursive_delete(Path) ->
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.
diff --git a/src/rabbit_msg_store.erl b/src/rabbit_msg_store.erl
index 4f85b5667c..e5de24ce1c 100644
--- a/src/rabbit_msg_store.erl
+++ b/src/rabbit_msg_store.erl
@@ -1292,10 +1292,7 @@ build_index(Gatherer, Left, [],
sum_file_size = SumFileSize }) ->
case gatherer:fetch(Gatherer) of
finished ->
- unlink(Gatherer),
- receive {'EXIT', Gatherer, _} -> ok
- after 0 -> ok
- end,
+ ok = rabbit_misc:unlink_and_capture_exit(Gatherer),
ok = index_delete_by_file(undefined, State),
Offset = case ets:lookup(FileSummaryEts, Left) of
[] -> 0;
diff --git a/src/rabbit_queue_index.erl b/src/rabbit_queue_index.erl
index 6ab370b2ab..4887ec2160 100644
--- a/src/rabbit_queue_index.erl
+++ b/src/rabbit_queue_index.erl
@@ -460,10 +460,7 @@ queue_index_walker(DurableQueues) when is_list(DurableQueues) ->
queue_index_walker({[], Gatherer}) ->
case gatherer:fetch(Gatherer) of
- finished -> unlink(Gatherer),
- receive {'EXIT', Gatherer, _} -> ok
- after 0 -> ok
- end,
+ finished -> rabbit_misc:unlink_and_capture_exit(Gatherer),
finished;
{value, {MsgId, Count}} -> {MsgId, Count, {[], Gatherer}}
end;