Fix issues with idle behavior

Some BMCs appear to expire a session within 30
seconds, unfortunately.

Also, be careful to always fire events, even if the remote has gone away.

Change-Id: I1b57fa8841ca19c77d36abe3ccc5bf877e09945a
This commit is contained in:
Jarrod Johnson 2017-02-08 10:56:53 -05:00
parent d1318616c6
commit 957c6c971e
1 changed files with 8 additions and 5 deletions

View File

@ -65,6 +65,9 @@ MAX_BMCS_PER_SOCKET = 64 # no more than this many BMCs will share a socket
# this could be adjusted based on rmem_max
# value, leading to fewer filehandles
MAX_IDLE = 29 # maximum time to allow idle, more than this and BMC may assume
# incorrect idle
def define_worker():
class _IOWorker(threading.Thread):
@ -737,10 +740,10 @@ class Session(object):
self.awaitresponse(retry, waitall)
lastresponse = self.lastresponse
self.incommand = False
if retry and lastresponse is None:
raise exc.IpmiException('Session no longer connected')
while self.evq:
self.evq.popleft().set()
if retry and lastresponse is None:
raise exc.IpmiException('Session no longer connected')
return lastresponse
def _send_ipmi_net_payload(self, netfn=None, command=None, data=(), code=0,
@ -867,7 +870,7 @@ class Session(object):
if (self in Session.keepalive_sessions and not needskeepalive and
not self._customkeepalives):
Session.keepalive_sessions[self]['timeout'] = _monotonic_time() + \
50 + (random.random() * 4.9)
MAX_IDLE - (random.random() * 4.9)
self._xmit_packet(retry, delay_xmit=delay_xmit, timeout=timeout)
def _ipmi15authcode(self, payload, checkremotecode=False):
@ -979,7 +982,7 @@ class Session(object):
Session.keepalive_sessions[self] = {}
Session.keepalive_sessions[self]['ipmisession'] = self
Session.keepalive_sessions[self]['timeout'] = _monotonic_time() + \
50 + (random.random() * 4.9)
MAX_IDLE - (random.random() * 4.9)
self.onlogon({'success': True})
def _get_session_challenge(self):
@ -1106,7 +1109,7 @@ class Session(object):
# until incommand is no longer the case
if parms['timeout'] < curtime and not session._isincommand():
cls.keepalive_sessions[session]['timeout'] = \
_monotonic_time() + 50 + (random.random() * 4.9)
_monotonic_time() + MAX_IDLE - (random.random() * 4.9)
sessionstokeepalive.append(session)
for session in sessionstokeepalive:
session._keepalive()