Ensure connections we consider dead are actually closed
authorAlexander van Gessel <ai0867@gmail.com>
Mon, 21 Jan 2013 03:04:51 +0000 (04:04 +0100)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 3 Feb 2013 18:58:04 +0000 (13:58 -0500)
Signed-off-by: Eric S. Raymond <esr@thyrsus.com>
irkerd

diff --git a/irkerd b/irkerd
index 36b34aba4746e8c71b2d54182bef94198876a8f7..71ab42b9f6ceb3b2ab0272721f569a92aae2c679 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -264,13 +264,21 @@ class Connection:
             (exc_type, _exc_value, exc_traceback) = sys.exc_info()
             self.irker.logerr("exception %s in thread for %s" % \
                               (exc_type, self.servername))
+
+            # Maybe this should have its own status?
+            self.status = "expired"
+
             # This is so we can see tracebacks for errors inside the thread
             # when we need to be able to for debugging purposes.
             if debuglvl > 0:
                 raise exc_type, _exc_value, exc_traceback
-            else:
-                # Maybe this should have its own status?
-                self.status = "expired"
+        finally:
+            try:
+                # Make sure we don't leave any zombies behind
+                self.connection.close()
+            except:
+                # Irclib has a habit of throwing fresh exceptions here. Ignore that
+                pass
     def live(self):
         "Should this connection not be scavenged?"
         return self.status != "expired"