Skip to content

Commit 7407a6c

Browse files
author
Francesco Mazzoli
committed
Make rabbit_variable_queue:dropwhile tail recursive
1 parent 9b3d19f commit 7407a6c

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ start-background-node: all
207207
-rm -f $(RABBITMQ_MNESIA_DIR).pid
208208
mkdir -p $(RABBITMQ_MNESIA_DIR)
209209
setsid sh -c "$(MAKE) run-background-node > $(RABBITMQ_MNESIA_DIR)/startup_log 2> $(RABBITMQ_MNESIA_DIR)/startup_err" &
210-
sleep 1
210+
sleep 3
211211

212212
start-rabbit-on-node: all
213213
echo "rabbit:start()." | $(ERL_CALL)

src/rabbit_variable_queue.erl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,10 @@ drain_confirmed(State = #vqstate { confirmed = C }) ->
578578
confirmed = gb_sets:new() }}
579579
end.
580580

581-
dropwhile(Pred, AckRequired, State) ->
582-
End = fun(S) when AckRequired -> {[], S};
581+
dropwhile(Pred, AckRequired, State) -> dropwhile(Pred, AckRequired, State, []).
582+
583+
dropwhile(Pred, AckRequired, State, Msgs) ->
584+
End = fun(S) when AckRequired -> {lists:reverse(Msgs), S};
583585
(S) -> {undefined, S}
584586
end,
585587
case queue_out(State) of
@@ -591,11 +593,10 @@ dropwhile(Pred, AckRequired, State) ->
591593
{MsgStatus1, State2} = read_msg(MsgStatus, State1),
592594
{{Msg, _, AckTag, _}, State3} =
593595
internal_fetch(true, MsgStatus1, State2),
594-
{L, State4} = dropwhile(Pred, AckRequired, State3),
595-
{[{Msg, AckTag} | L], State4};
596+
dropwhile(Pred, AckRequired, State3, [{Msg, AckTag} | Msgs]);
596597
{true, false} ->
597598
{_, State2} = internal_fetch(false, MsgStatus, State1),
598-
dropwhile(Pred, AckRequired, State2);
599+
dropwhile(Pred, AckRequired, State2, undefined);
599600
{false, _} ->
600601
End(a(in_r(MsgStatus, State1)))
601602
end

0 commit comments

Comments
 (0)