From 2b3dfc7414743871ed7e50a13b90347358e1ed4b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 20 Oct 2013 17:50:28 -0400 Subject: [PATCH] Fix the spin loop not to be O(n**2). --- irkerd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/irkerd b/irkerd index 33e480d..fd97424 100755 --- a/irkerd +++ b/irkerd @@ -46,7 +46,7 @@ CONNECTION_MAX = 200 # To avoid hitting a thread limit version = "1.20" import sys, getopt, urlparse, time, random, socket, signal, re -import threading, Queue, SocketServer, select, itertools +import threading, Queue, SocketServer, select import logging try: import simplejson as json # Faster, also makes us Python-2.4-compatible @@ -132,10 +132,10 @@ class IRCClient(): if x is not None and x.socket is not None] sockets = [x.socket for x in connected] if sockets: + connmap = dict([(c.socket.fileno(), c) for c in connected]) (insocks, _o, _e) = select.select(sockets, [], [], timeout) - for s, c in itertools.product(insocks, self.server_connections): - if s == c.socket: - c.consume() + for s in insocks: + connmap[s.fileno()].consume() else: time.sleep(timeout) -- 2.26.2