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
commitcc8ab871619c093d27823ace64488e73ca6a1f87 (patch)
tree2807fdf22e2755224392f6051de1bfe1e6062209
parent9b62f842cdbbf26a4e929ff1d8761c6819d7c19a (diff)
downloadrabbitmq-server-git-cc8ab871619c093d27823ace64488e73ca6a1f87.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 f03c1d1c76..a5620a8862 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 2491ac301b..6f1c3847bb 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 }) ->