summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Mazzoli <francesco@rabbitmq.com>2012-02-07 18:08:55 +0000
committerFrancesco Mazzoli <francesco@rabbitmq.com>2012-02-07 18:08:55 +0000
commit00b78cccf0536a50b9e0f9e32bf68a62edbd52a1 (patch)
tree2807fdf22e2755224392f6051de1bfe1e6062209
parent425557b29b2b11e07a399f75f6726cf07963cfc1 (diff)
downloadrabbitmq-server-00b78cccf0536a50b9e0f9e32bf68a62edbd52a1.tar.gz
Returning idle in needs_timeout/1 only when there is something to flush.
-rw-r--r--src/rabbit_queue_index.erl7
-rw-r--r--src/rabbit_variable_queue.erl9
2 files changed, 11 insertions, 5 deletions
diff --git a/src/rabbit_queue_index.erl b/src/rabbit_queue_index.erl
index f03c1d1c..a5620a88 100644
--- a/src/rabbit_queue_index.erl
+++ b/src/rabbit_queue_index.erl
@@ -18,8 +18,8 @@
-export([init/2, shutdown_terms/1, recover/5,
terminate/2, delete_and_terminate/1,
- publish/5, deliver/2, ack/2, sync/1, sync/2, flush/1, read/3,
- next_segment_boundary/1, bounds/1, recover/1]).
+ publish/5, deliver/2, ack/2, sync/1, sync/2, flush/1, needs_flush/1,
+ read/3, next_segment_boundary/1, bounds/1, recover/1]).
-export([add_queue_ttl/0]).
@@ -301,6 +301,9 @@ sync(SeqIds, State) ->
flush(State = #qistate { dirty_count = 0 }) -> State;
flush(State) -> flush_journal(State).
+needs_flush(State = #qistate { dirty_count = 0}) -> false;
+needs_flush(_State) -> true.
+
read(StartEnd, StartEnd, State) ->
{[], State};
read(Start, End, State = #qistate { segments = Segments,
diff --git a/src/rabbit_variable_queue.erl b/src/rabbit_variable_queue.erl
index 2491ac30..6f1c3847 100644
--- a/src/rabbit_variable_queue.erl
+++ b/src/rabbit_variable_queue.erl
@@ -731,10 +731,13 @@ ram_duration(State = #vqstate {
ram_msg_count_prev = RamMsgCount,
ram_ack_count_prev = RamAckCount }}.
-needs_timeout(State) ->
+needs_timeout(State = #vqstate { index_state = IndexState }) ->
case needs_index_sync(State) of
- false -> idle;
- true -> timed
+ true -> timed;
+ false -> case rabbit_queue_index:needs_flush(IndexState) of
+ true -> idle;
+ false -> false
+ end
end.
timeout(State = #vqstate { index_state = IndexState }) ->