diff options
author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-08-25 11:32:23 +0100 |
---|---|---|
committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-08-25 11:32:23 +0100 |
commit | de6542707b5f94157787b1563ce4ba6dcadc216b (patch) | |
tree | 84bd7e8f2d19031fc3da5693a72384d52f17f47e | |
parent | f9623dbc4ef6a920922a075ced476677b94cea3a (diff) | |
download | rabbitmq-server-de6542707b5f94157787b1563ce4ba6dcadc216b.tar.gz |
exclusive queues are deleted quickly on clean connection termination
-rw-r--r-- | src/rabbit_amqqueue.erl | 6 | ||||
-rw-r--r-- | src/rabbit_amqqueue_process.erl | 5 | ||||
-rw-r--r-- | src/rabbit_queue_collector.erl | 2 |
3 files changed, 11 insertions, 2 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index abcb87d7..a0e0744e 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -31,7 +31,7 @@ -module(rabbit_amqqueue). --export([start/0, stop/0, declare/5, delete/3, purge/1]). +-export([start/0, stop/0, declare/5, delete/1, delete/3, purge/1]). -export([internal_declare/2, internal_delete/1, maybe_run_queue_via_backing_queue/2, update_ram_duration/1, set_ram_duration_target/2, @@ -115,6 +115,7 @@ (rabbit_types:amqqueue()) -> {'ok', non_neg_integer(), non_neg_integer()}). -spec(emit_stats/1 :: (rabbit_types:amqqueue()) -> 'ok'). +-spec(delete/1 :: (rabbit_types:amqqueue()) -> qlen()). -spec(delete/3 :: (rabbit_types:amqqueue(), 'false', 'false') -> qlen(); @@ -358,6 +359,9 @@ stat(#amqqueue{pid = QPid}) -> delegate_call(QPid, stat, infinity). emit_stats(#amqqueue{pid = QPid}) -> delegate_cast(QPid, emit_stats). +delete(#amqqueue{ pid = QPid }) -> + gen_server2:call(QPid, delete_now, infinity). + delete(#amqqueue{ pid = QPid }, IfUnused, IfEmpty) -> delegate_call(QPid, {delete, IfUnused, IfEmpty}, infinity). diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 97a264d7..e0ededf1 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -598,6 +598,7 @@ prioritise_call(Msg, _From, _State) -> info -> 9; {info, _Items} -> 9; consumers -> 9; + delete_now -> 9; {maybe_run_queue_via_backing_queue, _Fun} -> 6; _ -> 0 end. @@ -785,6 +786,10 @@ handle_call(stat, _From, State = #q{backing_queue = BQ, active_consumers = ActiveConsumers}) -> reply({ok, BQ:len(BQS), queue:len(ActiveConsumers)}, State); +handle_call(delete_now, _From, State = #q{ backing_queue_state = BQS, + backing_queue = BQ }) -> + {stop, normal, {ok, BQ:len(BQS)}, State}; + handle_call({delete, IfUnused, IfEmpty}, _From, State = #q{backing_queue_state = BQS, backing_queue = BQ}) -> IsEmpty = BQ:is_empty(BQS), diff --git a/src/rabbit_queue_collector.erl b/src/rabbit_queue_collector.erl index b056d60b..226ce186 100644 --- a/src/rabbit_queue_collector.erl +++ b/src/rabbit_queue_collector.erl @@ -85,7 +85,7 @@ handle_call(delete_all, _From, State = #state{queues = Queues}) -> fun () -> ok end, fun () -> erlang:demonitor(MonitorRef), - rabbit_amqqueue:delete(Q, false, false) + rabbit_amqqueue:delete(Q) end) || {MonitorRef, Q} <- dict:to_list(Queues)], {reply, ok, State}. |