summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Bridgen <mikeb@lshift.net>2009-10-19 17:11:50 +0100
committerMichael Bridgen <mikeb@lshift.net>2009-10-19 17:11:50 +0100
commit1a08d50313ac1020df73030e6da9206fdf5847de (patch)
tree0c8bb7786245bdd1ec4d8a5fb5b93781f04d4e67
parent5612bffc489e3246771e2c170899bd4f4d0f4f30 (diff)
downloadrabbitmq-server-1a08d50313ac1020df73030e6da9206fdf5847de.tar.gz
Do the queue deletion synchronously. Instead of replying immediately
using gen_server2:call, then doing the work, we include the reply in the return value for gen_server2 to pass on. It happens that gen_server2 will terminate the process, on getting stop, before it sends the reply on -- just what we want here. NB: here we translate between the return value of handle_ch_down/2, which was intended to be the return value for handle_call, and an actual return value. Slightly nicer would be for handle_ch_down to return the state and (say) 'ok' or 'stop', to make its contract more explicit.
-rw-r--r--src/rabbit_amqqueue_process.erl14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index fe2e8509..477484c1 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -577,9 +577,17 @@ handle_call({commit, Txn}, From, State) ->
noreply(NewState);
handle_call({notify_down, ChPid}, From, State) ->
- %% optimisation: we reply straight away so the sender can continue
- gen_server2:reply(From, ok),
- handle_ch_down(ChPid, State);
+ %% we want to do this synchronously, so that auto_deleted queues
+ %% are no longer visible by the time we send a response to the
+ %% client. The queue is ultimately deleted in terminate/2; if we
+ %% return stop with a reply, terminate/2 will be called by
+ %% gen_server/2 *before* the reply is sent.
+ case handle_ch_down(ChPid, State) of
+ {noreply, NewState, Timeout} ->
+ {reply, ok, NewState, Timeout};
+ {stop, normal, NewState2} ->
+ {stop, normal, ok, NewState2}
+ end;
handle_call({basic_get, ChPid, NoAck}, _From,
State = #q{q = #amqqueue{name = QName},