Meatball-surgery fix for invalid-name bug.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 16 Nov 2013 10:11:32 +0000 (05:11 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 16 Nov 2013 10:11:32 +0000 (05:11 -0500)
00:07:27   AI0867 | esr: it reproduces on git head                   │
00:07:42   AI0867 | ./irk irc://chat.freendoe.net/foo                │
00:07:45   AI0867 | that's sufficient                                │
00:08:01      esr | OK, please email me a description of how to      │
                  | reproduce, I'll fix it.                          │
00:08:39      esr | Oh.  Is therec anything special about that       │
                  | channel?                                         │
00:08:42   AI0867 | no                                               │
00:08:48   AI0867 | any incorrect servername will do                 │
00:08:56   AI0867 | it then attempts to quit the server              │
00:09:01   AI0867 | and tries to send a QUIT                         │
00:09:06   AI0867 | which throws an exception                        │
00:09:10   AI0867 | so it tries to quit the server                   │

irkerd

diff --git a/irkerd b/irkerd
index 4e0e24c8d9a9a60561117b7784f9262fdc3d877d..2343637aac85d00fab11cb2ea250896224286f49 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -310,7 +310,7 @@ class IRCServerConnection():
     def disconnect(self, message=""):
         if self.socket is None:
             return
-        self.quit(message)
+        # Don't send a QUIT here - causes infinite loop!
         try:
             self.socket.shutdown(socket.SHUT_WR)
             self.socket.close()
@@ -412,7 +412,8 @@ class Connection:
     def handle_disconnect(self):
         "Server disconnected us for flooding or some other reason."
         self.connection = None
-        self.status = "disconnected"
+        if self.status != "connectfail":
+            self.status = "disconnected"
     def handle_kick(self, outof):
         "We've been kicked."
         self.status = "handshaking"
@@ -479,7 +480,7 @@ class Connection:
                     # space forever would be a memory leak.
                     self.status = "expired"
                     break
-                elif not self.connection:
+                elif not self.connection and self.status != "connectfail":
                     # Queue is nonempty but server isn't connected.
                     with self.irker.irc.mutex:
                         self.connection = self.irker.irc.newserver()
@@ -500,7 +501,7 @@ class Connection:
                             self.last_xmit = time.time()
                             self.last_ping = time.time()
                         except IRCServerConnectionError:
-                            self.status = "disconnected"
+                            self.status = "connectfail"
                 elif self.status == "handshaking":
                     if time.time() > self.last_xmit + HANDSHAKE_TTL:
                         self.status = "expired"