Skip to content

Commit 2e14c59

Browse files
koalowllenyj
authored andcommitted
Check for closed unsolicited messages channel
The unsolicited messages channel is used to forward unsolicited messages like multicast messages to the user. However, if none are sent by the kernel, the connection stays active even if the rx side of the channel was already dropped. This finally leads to resource exhaustion (e.g. too many open file descriptors) if new connections are repeatedly opened. Therefore, explicitly check if the channel is already closed and if so, take the tx side to allow for shutdown of the connection. Signed-off-by: Florian Kauer <[email protected]>
1 parent 61b8676 commit 2e14c59

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/connection.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,12 @@ where
208208
}
209209
}
210210

211-
if ready {
211+
if ready
212+
|| self
213+
.unsolicited_messages_tx
214+
.as_ref()
215+
.map_or(true, |x| x.is_closed())
216+
{
212217
// The channel is closed so we can drop the sender.
213218
let _ = self.unsolicited_messages_tx.take();
214219
// purge `protocol.incoming_requests`

0 commit comments

Comments
 (0)