summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2013-09-09 11:53:12 +0100
committerSimon MacMullen <simon@rabbitmq.com>2013-09-09 11:53:12 +0100
commit40957a2c628f633c8432375ca00c5ff27e0bde3c (patch)
tree541d3b9bd13cb61cc6a3eae77ed7c589dfbab7ea
parent263a1e5c3a4c24787baa3e006462aa225fbdf5d9 (diff)
downloadrabbitmq-server-40957a2c628f633c8432375ca00c5ff27e0bde3c.tar.gz
Introduce a new return code for this case, since {new, Q} is going to mess up recovery by claiming we recovered something we didn't. Also {existing, Q} would make the channel enter an infinite loop, and {absent, Q} would return an AMQP NOT_FOUND which might be bewildering to the client if it managed to receive it. So we need a fourth possibility.
-rw-r--r--src/rabbit_amqqueue.erl4
-rw-r--r--src/rabbit_amqqueue_process.erl6
-rw-r--r--src/rabbit_channel.erl7
3 files changed, 9 insertions, 8 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index a1efaf65..32feac30 100644
--- a/src/rabbit_amqqueue.erl
+++ b/src/rabbit_amqqueue.erl
@@ -72,8 +72,8 @@
-spec(declare/5 ::
(name(), boolean(), boolean(),
rabbit_framing:amqp_table(), rabbit_types:maybe(pid()))
- -> {'new' | 'existing' | 'absent', rabbit_types:amqqueue()} |
- rabbit_types:channel_exit()).
+ -> {'new' | 'existing' | 'absent' | 'owner_died',
+ rabbit_types:amqqueue()} | rabbit_types:channel_exit()).
-spec(internal_declare/2 ::
(rabbit_types:amqqueue(), boolean())
-> queue_or_absent() | rabbit_misc:thunk(queue_or_absent())).
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index cd56f098..ac19461c 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -1070,11 +1070,7 @@ handle_call({init, Recover}, From,
false -> #q{backing_queue = undefined,
backing_queue_state = undefined,
q = #amqqueue{name = QName} = Q} = State,
- %% If the connection has died then what we reply is somewhat
- %% moot. But it seems reasonable to act as though the queue
- %% was declared and then the connection died - we're only a
- %% small timing difference away from that case anyway.
- gen_server2:reply(From, {new, Q}),
+ gen_server2:reply(From, {owner_died, Q}),
case Recover of
new -> rabbit_log:warning(
"exclusive owner for ~s went away~n",
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index d6c1e8c0..4a194047 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -1021,7 +1021,12 @@ handle_method(#'queue.declare'{queue = QueueNameBin,
%% declare. Loop around again.
handle_method(Declare, none, State);
{absent, Q} ->
- rabbit_misc:absent(Q)
+ rabbit_misc:absent(Q);
+ {owner_died, Q} ->
+ %% Presumably our own days are numbered since the
+ %% connection has died. Pretend the queue exists though,
+ %% just so nothing fails.
+ return_queue_declare_ok(QueueName, NoWait, 0, 0, State)
end;
{error, {absent, Q}} ->
rabbit_misc:absent(Q)