diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2011-04-06 15:36:58 +0100 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2011-04-06 15:36:58 +0100 |
| commit | d6d333829e5a087e58f927ee8bd0a71d78a5349b (patch) | |
| tree | 7e55169919aebc12efe64b506aae7fa6b67c4def /src | |
| parent | ae65bc19d4e11e5d7f61ab6d8660ab26592f11d7 (diff) | |
| download | rabbitmq-server-git-d6d333829e5a087e58f927ee8bd0a71d78a5349b.tar.gz | |
Refactor a bit, and only check rabbit_durable_route if the binding might be durable.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_binding.erl | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/rabbit_binding.erl b/src/rabbit_binding.erl index 7131ab21e6..2ae7c973c4 100644 --- a/src/rabbit_binding.erl +++ b/src/rabbit_binding.erl @@ -143,26 +143,30 @@ add(Binding, InnerFun) -> %% in general, we want to fail on that in preference to %% anything else case InnerFun(Src, Dst) of - ok -> - case mnesia:read({rabbit_route, B}) of - [] -> case mnesia:read({rabbit_durable_route, B}) of - [] -> add_internal(Src, Dst, B); - %% Binding exists, to queue on node which - %% is in the middle of starting - [_] -> rabbit_misc:const(not_found) - end; - [_] -> fun rabbit_misc:const_ok/1 - end; - {error, _} = Err -> - rabbit_misc:const(Err) + ok -> add(Src, Dst, B); + {error, _} = Err -> rabbit_misc:const(Err) end end). -add_internal(Src, Dst, B) -> - ok = sync_binding(B, all_durable([Src, Dst]), fun mnesia:write/3), - fun (Tx) -> - ok = rabbit_exchange:callback(Src, add_bindings, [Tx, Src, [B]]), - rabbit_event:notify_if(not Tx, binding_created, info(B)) +add(Src, Dst, B) -> + case mnesia:read({rabbit_route, B}) of + [] -> Durable = all_durable([Src, Dst]), + case (not Durable orelse + mnesia:read({rabbit_durable_route, B}) =:= []) of + true -> + ok = sync_binding(B, Durable, fun mnesia:write/3), + fun (Tx) -> + ok = rabbit_exchange:callback(Src, add_bindings, + [Tx, Src, [B]]), + rabbit_event:notify_if(not Tx, binding_created, + info(B)) + end; + %% Binding exists, to queue on node which + %% is in the middle of starting + false -> + rabbit_misc:const(not_found) + end; + [_] -> fun rabbit_misc:const_ok/1 end. remove(Binding, InnerFun) -> |
