Properly close dead connections
authorJack Miller <jack@codezen.org>
Wed, 1 Jun 2016 02:47:03 +0000 (21:47 -0500)
committerJack Miller <jack@codezen.org>
Wed, 1 Jun 2016 02:47:03 +0000 (21:47 -0500)
I'm a bit surprised I haven't caught this before, I guess I was relying
on garbage collection to destroy dead connections for me, but when you
do something like

$ while /bin/true; do canto-remote status; done

and create nonstop connection thrashing that's not good enough (if it
works at all), so explicitly call close().

canto_next/server.py

index a572d4c..de87f6f 100644 (file)
@@ -83,6 +83,7 @@ class CantoServer(CantoSocket):
             if not t.isAlive():
                 call_hook("server_kill_socket", [c])
                 t.join()
+                c.close()
                 self.connections.remove((c, t))
                 if self.connections == []:
                     call_hook("server_no_connections", [])