From ebf50359f0a670f8b37b0776c43207ca2421fc8a Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 13 Jan 2021 16:50:17 -0500 Subject: [PATCH] Fix file descriptor leak by web forwarder It failed to close the two sockets when a socket was done. --- confluent_server/confluent/forwarder.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/confluent_server/confluent/forwarder.py b/confluent_server/confluent/forwarder.py index a6b5b80b..5b7d5ee8 100644 --- a/confluent_server/confluent/forwarder.py +++ b/confluent_server/confluent/forwarder.py @@ -34,6 +34,8 @@ def handle_connection(incoming, outgoing): for mysock in r: data = mysock.recv(32768) if not data: + incoming.close() + outgoing.close() return if mysock == incoming: outgoing.sendall(data) @@ -72,6 +74,7 @@ def forward_video(): vidclient.setsockopt(socket.IPPROTO_TCP, socket.TCP_MAXSEG, 1456) except Exception: conn.close() + vidclient.close() continue eventlet.spawn_n(handle_connection, conn, vidclient)