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

Avoid recursing between keepalive and raw_command

On June 10 2014 one condition was addressed that caused infinite
recursion.  Then it was an invalid timer that could fire in the midst of
a command.  The case where this could validly occur was overlooked.
Address this by deferring invocation of keepalives until after command
exits.  If incommand indicated activity advances timeout in non
custom keepalive case, then the keepalive timer will actually be correctly advanced.

Change-Id: Iebe0241c1f928c4187f167f3ffa407f8c6f7fa84
This commit is contained in:
Jarrod Johnon 2014-09-15 10:03:08 -04:00
parent 737643c33c
commit e4827408f3

View File

@ -944,7 +944,9 @@ class Session(object):
sessionstodel = []
sessionstokeepalive = []
for session, parms in cls.keepalive_sessions.iteritems():
if parms['timeout'] < curtime:
# if the session is busy inside a command, defer invoking keepalive
# until incommand is no longer the case
if parms['timeout'] < curtime and not session.incommand:
cls.keepalive_sessions[session]['timeout'] = \
_monotonic_time() + 25 + (random.random() * 4.9)
sessionstokeepalive.append(session)