summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Mazzoli <francesco@rabbitmq.com>2012-07-12 15:35:03 +0100
committerFrancesco Mazzoli <francesco@rabbitmq.com>2012-07-12 15:35:03 +0100
commita9e03d18a47123231271b9eb909ddabdd853ffe2 (patch)
treeef9e2fa9edfef5d8a437077586da8e474a8e2c89
parentd8b79de606a90dc020d15d41fd6c6abb36ce0677 (diff)
downloadrabbitmq-server-git-a9e03d18a47123231271b9eb909ddabdd853ffe2.tar.gz
macro instead of duplicating the guards
-rw-r--r--src/rabbit_misc.erl25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index f0ea4e1382..804d587b0a 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -61,6 +61,11 @@
-export([os_cmd/1]).
-export([gb_sets_difference/2]).
+%% Horrible macro to use in guards
+-define(BENIGN_TERMINATION(R),
+ R =:= noproc; R =:= noconnection; R =:= nodedown; R =:= normal;
+ R =:= shutdown).
+
%%----------------------------------------------------------------------------
-ifdef(use_specs).
@@ -423,23 +428,13 @@ with_exit_handler(Handler, Thunk) ->
try
Thunk()
catch
- exit:{R, _} when R =:= noproc; R =:= noconnection; R =:= nodedown;
- R =:= normal; R =:= shutdown ->
- Handler();
- exit:{{R, _}, _} when R =:= nodedown; R =:= shutdown ->
- Handler()
+ exit:{R, _} when ?BENIGN_TERMINATION(R) -> Handler();
+ exit:{{R, _}, _} when ?BENIGN_TERMINATION(R) -> Handler()
end.
-%% Note the code duplication between this and `with_exit_handler/2' above - we
-%% can't use arbitrary functions in guards, and we can't re-throw runtime
-%% errors.
-is_abnormal_termination(R) when R =:= noproc; R =:= noconnection;
- R =:= nodedown; R =:= normal; R =:= shutdown ->
- false;
-is_abnormal_termination({R, _}) when R =:= nodedown; R =:= shutdown ->
- false;
-is_abnormal_termination(_) ->
- true.
+is_abnormal_termination(R) when ?BENIGN_TERMINATION(R) -> false;
+is_abnormal_termination({R, _}) when ?BENIGN_TERMINATION(R) -> false;
+is_abnormal_termination(_) -> true.
filter_exit_map(F, L) ->
Ref = make_ref(),