summaryrefslogtreecommitdiff
path: root/src/rabbit_variable_queue.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rabbit_variable_queue.erl')
-rw-r--r--src/rabbit_variable_queue.erl50
1 files changed, 37 insertions, 13 deletions
diff --git a/src/rabbit_variable_queue.erl b/src/rabbit_variable_queue.erl
index 9b45b558..3494d4a3 100644
--- a/src/rabbit_variable_queue.erl
+++ b/src/rabbit_variable_queue.erl
@@ -731,21 +731,45 @@ ram_duration(State = #vqstate {
ram_msg_count_prev = RamMsgCount,
ram_ack_count_prev = RamAckCount }}.
-needs_timeout(State) ->
- case needs_index_sync(State) of
- false -> case reduce_memory_use(
- fun (_Quota, State1) -> {0, State1} end,
- fun (_Quota, State1) -> State1 end,
- fun (_Quota, State1) -> {0, State1} end,
- State) of
- {true, _State} -> idle;
- {false, _State} -> false
- end;
- true -> timed
+needs_timeout(State = #vqstate { index_state = IndexState }) ->
+ case rabbit_queue_index:needs_flush(IndexState) of
+ true ->
+ timed;
+ false ->
+ case needs_index_sync(State) of
+ false -> case reduce_memory_use(
+ fun (_Quota, State1) -> {0, State1} end,
+ fun (_Quota, State1) -> State1 end,
+ fun (_Quota, State1) -> {0, State1} end,
+ State) of
+ {true, _State} -> idle;
+ {false, _State} -> false
+ end;
+ true -> timed
+ end
end.
-timeout(State) ->
- a(reduce_memory_use(confirm_commit_index(State))).
+%% needs_timeout(State = #vqstate { index_state = IndexState }) ->
+%% case needs_index_sync(State) of
+%% false -> case reduce_memory_use(
+%% fun (_Quota, State1) -> {0, State1} end,
+%% fun (_Quota, State1) -> State1 end,
+%% fun (_Quota, State1) -> {0, State1} end,
+%% State) of
+%% {true, _State} -> idle;
+%% {false, _State} -> false
+%% end;
+%% true -> timed
+%% end.
+
+timeout(State = #vqstate { index_state = IndexState }) ->
+ IndexState1 =
+ case needs_index_sync(State) of
+ true -> rabbit_queue_index:sync(IndexState);
+ false -> rabbit_queue_index:flush(IndexState)
+ end,
+ State1 = State #vqstate { index_state = IndexState1 },
+ a(reduce_memory_use(State1)).
handle_pre_hibernate(State = #vqstate { index_state = IndexState }) ->
State #vqstate { index_state = rabbit_queue_index:flush(IndexState) }.