From 3342eebd99fb35d606b9c1a1874956535f35ebd3 Mon Sep 17 00:00:00 2001 From: Bruce Merry Date: Tue, 20 Jul 2021 16:52:35 +0200 Subject: [PATCH] Fix mem_reader to stop gracefully 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. --- src/recv_mem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/recv_mem.cpp b/src/recv_mem.cpp index 964c38148..ccc90c1e0 100644 --- a/src/recv_mem.cpp +++ b/src/recv_mem.cpp @@ -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(); }); }