Skip to content

Commit

Permalink
Check error condition in inproc receiver handler
Browse files Browse the repository at this point in the history
Without this, stopping a stream with an inproc reader could lead to a
spurious "discarding packet received after stream stopped" message.
  • Loading branch information
bmerry committed Mar 7, 2019
1 parent 46f9bbb commit 547de15
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions src/recv_inproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,33 @@ void inproc_reader::packet_handler(
std::size_t bytes_transferred)
{
stream_base::add_packet_state state(get_stream_base());
if (state.is_stopped())
if (!error)
{
log_info("inproc reader: discarding packet received after stream stopped");
}
else
{
try
if (state.is_stopped())
{
inproc_queue::packet packet = queue->buffer.try_pop();
process_one_packet(state, packet);
/* TODO: could grab a batch of packets to amortise costs */
log_info("inproc reader: discarding packet received after stream stopped");
}
catch (ringbuffer_stopped)
else
{
state.stop();
}
catch (ringbuffer_empty)
{
// spurious wakeup - no action needed
try
{
inproc_queue::packet packet = queue->buffer.try_pop();
process_one_packet(state, packet);
/* TODO: could grab a batch of packets to amortise costs */
}
catch (ringbuffer_stopped)
{
state.stop();
}
catch (ringbuffer_empty)
{
// spurious wakeup - no action needed
}
}
}
else if (error != boost::asio::error::operation_aborted)
log_warning("Error in inproc receiver: %1%", error.message());

if (!state.is_stopped())
enqueue();
else
Expand Down

0 comments on commit 547de15

Please sign in to comment.