From a32f1080b1c558677ef84f6e85b4b3543fa67e2e Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 16 Feb 2015 19:53:34 -0500 Subject: [PATCH] Fix needless retries due to misdirected packets When used in a threaded application, there was a chance for one wait iteration to slurp away packets from another instance. When this would happen, a wait may mistakenly act as if no packets were received and expire a session timeout. Fix this by having arbitrarily many instances feed and consume from the same queue. This way if any instance of the wait function pulls a packet, all consumers are made aware of the packet. This dramatically improves performance when dealing with very long conversations (SDR+sensors) with hundreds of nodes across hundreds of threads. Change-Id: I3f51097fb41197445a447cbdaddc8c1c29d4a873 --- pyghmi/ipmi/private/session.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pyghmi/ipmi/private/session.py b/pyghmi/ipmi/private/session.py index f3352544..3deb7ad8 100644 --- a/pyghmi/ipmi/private/session.py +++ b/pyghmi/ipmi/private/session.py @@ -261,6 +261,7 @@ class Session(object): keepalive_sessions = {} peeraddr_to_nodes = {} iterwaiters = [] + pktqueue = collections.deque([]) #NOTE(jbjohnso): #socketpool is a mapping of sockets to usage count socketpool = {} @@ -977,12 +978,11 @@ class Session(object): if timeout is None: return 0 if _poller(timeout=timeout): - pktqueue = collections.deque([]) - cls.pulltoqueue(iosockets, pktqueue) - while len(pktqueue): - (data, sockaddr, mysocket) = pktqueue.popleft() + cls.pulltoqueue(iosockets, cls.pktqueue) + while len(cls.pktqueue): + (data, sockaddr, mysocket) = cls.pktqueue.popleft() cls._route_ipmiresponse(sockaddr, data, mysocket) - cls.pulltoqueue(iosockets, pktqueue) + cls.pulltoqueue(iosockets, cls.pktqueue) sessionstodel = [] sessionstokeepalive = [] for session, parms in cls.keepalive_sessions.iteritems():