@@ -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