diff --git a/include/dwarfs/detail/multi_queue_block_merger_impl.h b/include/dwarfs/detail/multi_queue_block_merger_impl.h index 3affd2a6..ca0dcf54 100644 --- a/include/dwarfs/detail/multi_queue_block_merger_impl.h +++ b/include/dwarfs/detail/multi_queue_block_merger_impl.h @@ -161,7 +161,10 @@ class multi_queue_block_merger_impl : public block_merger_base, while (active_slots_[ix] && active_slots_[ix].value() != src) { ++distance; - ix = (ix + 1) % active_slots_.size(); + + do { + ix = (ix + 1) % active_slots_.size(); + } while (ix != active_slot_index_ && !active_slots_[ix]); if (ix == active_slot_index_) { auto it = std::find(begin(source_queue_), end(source_queue_), src);