From 411af6c1675330214b00baeef32614e366196621 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 4 Nov 2018 11:25:22 +0000 Subject: [PATCH] issue #406: unix: don't leak already-closed socket object if Side.close() closes the socket (which it does), and it gets reused, GC will cause socketobject.__del__ to later delete some random FD. --- mitogen/unix.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mitogen/unix.py b/mitogen/unix.py index 417842bc..cc2d92ff 100644 --- a/mitogen/unix.py +++ b/mitogen/unix.py @@ -78,6 +78,11 @@ class Listener(mitogen.core.BasicStream): self.receive_side = mitogen.core.Side(self, self._sock.fileno()) router.broker.start_receive(self) + def on_shutdown(self, broker): + self._sock.close() + self.receive_side.closed = True + broker.stop_receive(self) + def _accept_client(self, sock): sock.setblocking(True) try: