Queue-clearing on kick.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 1 Oct 2012 09:25:28 +0000 (05:25 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 1 Oct 2012 09:25:28 +0000 (05:25 -0400)
irkerd

diff --git a/irkerd b/irkerd
index 638c1ccc817c160e77c18ddf8f7ad6d8a61b3512..1b85e006ffb3c69011e77076e88e765fbf1a2daa 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -137,10 +137,18 @@ class Connection:
     def handle_disconnect(self):
         "Server disconnected us for flooding or some other reason."
         self.connection = None
-    def handle_kick(self, channel):
+    def handle_kick(self, outof):
         "We've been kicked."
-        self.channels_joined.remove(channel)
-        # FIXME: Clear messages for this channel from the queue. 
+        self.status = "handshaking"
+        self.channels_joined.remove(outof)
+        qcopy = []
+        while not self.queue.empty():
+            (channel, message) = self.queue.get()
+            if channel != outof:
+                qcopy.append((channel, message))
+        for (channel, message) in qcopy:
+            self.queue.put((channel, message))
+        self.status = "ready"
     def enqueue(self, channel, message):
         "Enque a message for transmission."
         self.queue.put((channel, message))