fix: PacketStreamFilter socket leak on abrupt disconnect
This fix prevents TCP sockets from accumulating in CLOSE_WAIT following a network interruption. StreamInputShutdown ignored events that occurred while waiting for parts of a partially received packet. This could prevent the higher-level state machine from receiving the disconnect signal and closing the socket. The filter now correctly treats a stream closure during mid-packet reception as a protocol error, ensuring the disconnect event is propagated, and proceeds with the shutdown.
This commit is contained in:
parent
f9fd0e86b0
commit
1890e7b297
1 changed files with 10 additions and 1 deletions
|
|
@ -164,8 +164,17 @@ void PacketStreamFilter::filterEvent(const Event &event)
|
|||
std::scoped_lock lock{m_mutex};
|
||||
m_inputShutdown = true;
|
||||
if (m_size != 0) {
|
||||
if (m_buffer.getSize() >= m_size) {
|
||||
// we have a complete packet, so we can process it before
|
||||
// shutting down.
|
||||
return;
|
||||
}
|
||||
// we have a partial packet, but the stream has shut down.
|
||||
// we'll never get the rest of the packet, so we should
|
||||
// signal an error and then shut down.
|
||||
m_events->addEvent(Event(EventTypes::StreamInputFormatError, getEventTarget()));
|
||||
m_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// pass event
|
||||
|
|
|
|||
Loading…
Reference in a new issue