Skip to content

Commit

Permalink
Fix mem_reader to stop gracefully
Browse files Browse the repository at this point in the history
Previously it was directly calling `stop` on the stream. This is
equivalent to the user calling it, which is normally a hard stop e.g. if
it is a ring_stream, it will stop the ringbuffer without pushing any
incomplete heaps into it, or whatever flushing a subclass has
implemented in its `stop_received` overload.

Instead, use `add_packet_state.stop`, which is what's normally called
for a stop triggered by the stream itself (for example, a stop heap or
end-of-file in a pcap file), which indirectly calls `stop_received` on
the stream.
  • Loading branch information
bmerry committed Jul 20, 2021
1 parent bfd2d12 commit 3342eeb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/recv_mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ mem_reader::mem_reader(
get_io_service().post([this] {
mem_to_stream(get_stream_base(), this->ptr, this->length);
// There will be no more data, so we can stop the stream immediately.
get_stream_base().stop();
stream_base::add_packet_state state(get_stream_base());
state.stop();
stopped();
});
}
Expand Down

0 comments on commit 3342eeb

Please sign in to comment.