diff options
author | Michael Bridgen <mikeb@lshift.net> | 2009-11-04 17:11:23 +0000 |
---|---|---|
committer | Michael Bridgen <mikeb@lshift.net> | 2009-11-04 17:11:23 +0000 |
commit | 0f0233099f4bf64e1cab1b9a867be59526f24d18 (patch) | |
tree | bd7679b4146915d7fe1eab41df55fc23f6098463 | |
parent | 6b3177ff16b00c5800377080805a1fb7d5ce0b5a (diff) | |
download | rabbitmq-server-0f0233099f4bf64e1cab1b9a867be59526f24d18.tar.gz |
bug 20578: factor out the check-if-the-queue-has-changed pattern of the two branches
-rw-r--r-- | src/rabbit_amqqueue.erl | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index 77895c2a..9ebec399 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -129,31 +129,30 @@ recover_durable_queues() -> Node = node(), lists:foreach( fun (RecoveredQ = #amqqueue{ exclusive_owner = Owner }) -> + %% We need to catch the case where a client connected to + %% another node has deleted the queue (and possibly + %% re-created it). + DoIfSameQueue = + fun (Action) -> + rabbit_misc:execute_mnesia_transaction( + fun () -> case mnesia:match_object( + rabbit_durable_queue, RecoveredQ, read) of + [_] -> ok = Action(), + true; + [] -> false + end + end) + end, case shared_or_live_owner(Owner) of true -> - Q = start_queue_process(RecoveredQ), - %% We need to catch the case where a client connected to - %% another node has deleted the queue (and possibly - %% re-created it). - case rabbit_misc:execute_mnesia_transaction( - fun () -> case mnesia:match_object( - rabbit_durable_queue, RecoveredQ, read) of - [_] -> ok = store_queue(Q), - true; - [] -> false - end - end) of + Q = start_queue_process(RecoveredQ), + case DoIfSameQueue(fun () -> store_queue(Q) end) of true -> ok; false -> exit(Q#amqqueue.pid, shutdown) end; false -> - rabbit_misc:execute_mnesia_transaction( - fun () -> case mnesia:match_object( - rabbit_durable_queue, RecoveredQ, read) of - [_] -> internal_delete2(RecoveredQ#amqqueue.name); - [] -> ok - end - end) + DoIfSameQueue( + fun () -> internal_delete2(RecoveredQ#amqqueue.name) end) end end, %% TODO: use dirty ops instead |