Remove a mutex guard that is probably unecessary.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 19 Oct 2012 21:01:12 +0000 (17:01 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 19 Oct 2012 21:01:12 +0000 (17:01 -0400)
AI0867 reported this was causing a rare hang during disconnect.
Also, set the connection status to expired if the thread terminates
due to exception.

irkerd

diff --git a/irkerd b/irkerd
index 1bc56f2f02b5bd6de23b2c89079ed88561c555e8..ffd8f8fe297df882c01a2bec6fd60bdb1ce69e9a 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -238,17 +238,16 @@ class Connection:
                     self.status = "expired"
                     break
                 elif self.status == "ready":
-                    with self.irker.irc.mutex:
-                        (channel, message) = self.queue.get()
-                        if channel not in self.channels_joined:
-                            self.connection.join(channel)
-                            self.irker.debug(1, "joining %s on %s." % (channel, self.servername))
-                        for segment in message.split("\n"):
-                            self.connection.privmsg(channel, segment)
-                            time.sleep(ANTI_FLOOD_DELAY)
-                        self.last_xmit = self.channels_joined[channel] = time.time()
-                        self.irker.debug(1, "XMIT_TTL bump (%s transmission) at %s" % (self.servername, time.asctime()))
-                        self.queue.task_done()
+                    (channel, message) = self.queue.get()
+                    if channel not in self.channels_joined:
+                        self.connection.join(channel)
+                        self.irker.debug(1, "joining %s on %s." % (channel, self.servername))
+                    for segment in message.split("\n"):
+                        self.connection.privmsg(channel, segment)
+                        time.sleep(ANTI_FLOOD_DELAY)
+                    self.last_xmit = self.channels_joined[channel] = time.time()
+                    self.irker.debug(1, "XMIT_TTL bump (%s transmission) at %s" % (self.servername, time.asctime()))
+                    self.queue.task_done()
         except:
             (exc_type, _exc_value, exc_traceback) = sys.exc_info()
             self.irker.logerr("exception %s in thread for %s" % \
@@ -257,6 +256,9 @@ class Connection:
             # 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"
     def live(self):
         "Should this connection not be scavenged?"
         return self.status != "expired"