49
49
50
50
-type bind_ok_or_error () :: 'ok' | bind_errors () |
51
51
rabbit_types :error (
52
- 'binding_not_found' |
53
52
{'binding_invalid' , string (), [any ()]}).
54
53
-type bind_res () :: bind_ok_or_error () | rabbit_misc :thunk (bind_ok_or_error ()).
55
54
-type inner_fun () ::
@@ -178,19 +177,15 @@ add(Src, Dst, B, ActingUser) ->
178
177
lock_resource (Src ),
179
178
lock_resource (Dst ),
180
179
[SrcDurable , DstDurable ] = [durable (E ) || E <- [Src , Dst ]],
181
- case (SrcDurable andalso DstDurable andalso
182
- mnesia :read ({rabbit_durable_route , B }) =/= []) of
183
- false -> ok = sync_route (# route {binding = B }, SrcDurable , DstDurable ,
184
- fun mnesia :write /3 ),
185
- x_callback (transaction , Src , add_binding , B ),
186
- Serial = rabbit_exchange :serial (Src ),
187
- fun () ->
188
- x_callback (Serial , Src , add_binding , B ),
189
- ok = rabbit_event :notify (
190
- binding_created ,
191
- info (B ) ++ [{user_who_performed_action , ActingUser }])
192
- end ;
193
- true -> rabbit_misc :const ({error , binding_not_found })
180
+ ok = sync_route (# route {binding = B }, SrcDurable , DstDurable ,
181
+ fun mnesia :write /3 ),
182
+ x_callback (transaction , Src , add_binding , B ),
183
+ Serial = rabbit_exchange :serial (Src ),
184
+ fun () ->
185
+ x_callback (Serial , Src , add_binding , B ),
186
+ ok = rabbit_event :notify (
187
+ binding_created ,
188
+ info (B ) ++ [{user_who_performed_action , ActingUser }])
194
189
end .
195
190
196
191
-spec remove (rabbit_types :binding ()) -> bind_res ().
@@ -208,7 +203,10 @@ remove(Binding, InnerFun, ActingUser) ->
208
203
case mnesia :read (rabbit_route , B , write ) of
209
204
[] -> case mnesia :read (rabbit_durable_route , B , write ) of
210
205
[] -> rabbit_misc :const (ok );
211
- _ -> rabbit_misc :const ({error , binding_not_found })
206
+ % % We still delete the binding and run
207
+ % % all post-delete functions if there is only
208
+ % % a durable route in the database
209
+ _ -> remove (Src , Dst , B , ActingUser )
212
210
end ;
213
211
_ -> case InnerFun (Src , Dst ) of
214
212
ok -> remove (Src , Dst , B , ActingUser );
0 commit comments