2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-28 20:07:42 +00:00

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
This commit is contained in:
Jarrod Johnson 2015-02-16 19:53:34 -05:00
parent 871984bde0
commit a32f1080b1

View File

@ -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():