From: Eric S. Raymond <esr@thyrsus.com>
Date: Mon, 1 Oct 2012 09:25:28 +0000 (-0400)
Subject: Queue-clearing on kick.
X-Git-Tag: 1.4~16
X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=56773baf96963d5a1fd76df38761a912bab3a592;p=irker.git

Queue-clearing on kick.
---

diff --git a/irkerd b/irkerd
index 638c1cc..1b85e00 100755
--- 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))