2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-15 20:27:45 +00:00

Correct redundant timedout calls in recursion

When handling multiple sessions hiting a timeout expiry,
there was a chance that during recursion a session would
get redundantly scheduled for retry/timeout.  Address this
by clearing out the scheduled sessions prior to acting on
any of the sessions.  Additionally, only start the timeout
clock after successfully placing the payload on the wire,
rather than including local delays against timeout expiry.

Change-Id: I2f58f0afcb13943654489630f7e8164913633a49
This commit is contained in:
Jarrod Johnon 2015-01-22 15:46:21 -05:00
parent f4590dad58
commit 31c797c221

View File

@ -998,6 +998,9 @@ class Session(object):
# to avoid confusing the for loop
for session in sessionstodel:
cls.waiting_sessions.pop(session, None)
# one loop iteration to make sure recursion doesn't induce redundant
# timeouts
for session in sessionstodel:
session._timedout()
return len(cls.waiting_sessions)
@ -1474,11 +1477,6 @@ class Session(object):
if self.sequencenumber: # seq number of zero will be left alone, it is
# special, otherwise increment
self.sequencenumber += 1
if retry:
Session.waiting_sessions[self] = {}
Session.waiting_sessions[self]['ipmisession'] = self
Session.waiting_sessions[self]['timeout'] = self.timeout + \
_monotonic_time()
if delay_xmit is not None:
Session.waiting_sessions[self]['timeout'] = delay_xmit + \
_monotonic_time()
@ -1506,6 +1504,11 @@ class Session(object):
except socket.gaierror:
raise exc.IpmiException(
"Unable to transmit to specified address")
if retry:
Session.waiting_sessions[self] = {}
Session.waiting_sessions[self]['ipmisession'] = self
Session.waiting_sessions[self]['timeout'] = self.timeout + \
_monotonic_time()
def logout(self):
if not self.logged: