diff options
| author | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-07-11 15:28:25 +0100 |
|---|---|---|
| committer | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-07-11 15:28:25 +0100 |
| commit | f9f1e48cdd5398737f5b6d5d21fdb5baebb89a98 (patch) | |
| tree | 042e13d37446114b18daf01c467c4f616a63ddbb | |
| parent | 63477af925d226c937aee6984c6380699ede0a11 (diff) | |
| download | rabbitmq-server-git-f9f1e48cdd5398737f5b6d5d21fdb5baebb89a98.tar.gz | |
filter benign messages in `rabbit_amqqueue:safe_delegate_call_ok/2'
Sadly I can't use `rabbit_misc:is_benign_exit/1' in the guards in
`with_exit_handler/2'.
| -rw-r--r-- | src/rabbit_amqqueue.erl | 18 | ||||
| -rw-r--r-- | src/rabbit_misc.erl | 12 |
2 files changed, 22 insertions, 8 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index afbaea651b..c51acbdf4b 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -672,13 +672,17 @@ qpids(Qs) -> lists:append([[QPid | SPids] || #amqqueue{pid = QPid, slave_pids = SPids} <- Qs]). safe_delegate_call_ok(F, Pids) -> - case delegate:invoke(Pids, fun (Pid) -> - rabbit_misc:with_exit_handler( - fun () -> ok end, - fun () -> F(Pid) end) - end) of - {_, []} -> ok; - {_, Bad} -> {error, Bad} + {_, Bads} = delegate:invoke(Pids, fun (Pid) -> + rabbit_misc:with_exit_handler( + fun () -> ok end, + fun () -> F(Pid) end) + end), + case lists:filter( + fun ({_Pid, {exit, R, _}}) -> not rabbit_misc:is_benign_exit(R); + (_) -> false + end, Bads) of + [] -> ok; + Bads1 -> {error, Bads1} end. delegate_call(Pid, Msg) -> diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index d41aa09b15..49b467166b 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -29,7 +29,8 @@ -export([enable_cover/1, report_cover/1]). -export([start_cover/1]). -export([confirm_to_sender/2]). --export([throw_on_error/2, with_exit_handler/2, filter_exit_map/2]). +-export([throw_on_error/2, is_benign_exit/1, with_exit_handler/2, + filter_exit_map/2]). -export([is_abnormal_termination/1]). -export([with_user/2, with_user_and_vhost/3]). -export([execute_mnesia_transaction/1]). @@ -136,6 +137,7 @@ -spec(report_cover/1 :: ([file:filename() | atom()]) -> 'ok'). -spec(throw_on_error/2 :: (atom(), thunk(rabbit_types:error(any()) | {ok, A} | A)) -> A). +-spec(is_benign_exit/1 :: (any()) -> boolean()). -spec(with_exit_handler/2 :: (thunk(A), thunk(A)) -> A). -spec(filter_exit_map/2 :: (fun ((A) -> B), [A]) -> [B]). -spec(is_abnormal_termination/1 :: (any()) -> boolean()). @@ -419,6 +421,14 @@ throw_on_error(E, Thunk) -> Res -> Res end. +is_benign_exit({R, _}) when R =:= noproc; R =:= nodedown; R =:= normal; + R =:= shutdown -> + true; +is_benign_exit({{R, _}, _}) when R =:= nodedown; R =:= shutdown -> + true; +is_benign_exit(_) -> + false. + with_exit_handler(Handler, Thunk) -> try Thunk() |
