2
0
mirror of https://opendev.org/x/pyghmi synced 2025-08-24 12:00:21 +00:00

Handle concurrent session requests

A caller may end up making requests that would get gathered
into a single session object.  However due to being aggressive,
a second session object supersedes the original without the
original getting a chance to complete login and satisfy the
second caller.  Address this by reusing a 'logging' session
and then having __init__ follow the state of the other session
object already in progress.  Without this a caller can end
up provoking a fight and having the BMC refuse to continue
to entertain the shenanigans in short order.

Change-Id: I47acbc0c974900ff50c02d470b5a79a3fed9bb73
This commit is contained in:
Jarrod Johnson
2015-02-16 13:41:42 -05:00
parent fe31004d5e
commit 871984bde0

View File

@@ -336,7 +336,7 @@ class Session(object):
self = cls.bmc_handlers[sockaddr]
if (self.bmc == bmc and self.userid == userid and
self.password == password and self.kgo == kg and
self.logged):
(self.logged or self.logging)):
trueself = self
else:
del cls.bmc_handlers[sockaddr]
@@ -404,7 +404,7 @@ class Session(object):
self.socket = self._assignsocket()
self.login()
if not self.async:
while not self.logged:
while self.logging and not self.logged:
Session.wait_for_rsp()
def _mark_broken(self):
@@ -412,6 +412,7 @@ class Session(object):
# deregister our keepalive facility
Session.keepalive_sessions.pop(self, None)
Session.waiting_sessions.pop(self, None)
self.logging = False
if self.logged:
self.logged = 0 # mark session as busted
self._customkeepalives = None
@@ -460,6 +461,7 @@ class Session(object):
# do not forsee a reason to adjust
self.rqaddr = 0x81
self.logging = True
self.logged = 0
# NOTE(jbjohnso): when we confirm a working sockaddr, put it here to
# skip getaddrinfo
@@ -850,6 +852,7 @@ class Session(object):
self.onlogon({'error': errstr})
return
self.logged = 1
self.logging = False
Session.keepalive_sessions[self] = {}
Session.keepalive_sessions[self]['ipmisession'] = self
Session.keepalive_sessions[self]['timeout'] = _monotonic_time() + \
@@ -1528,6 +1531,7 @@ class Session(object):
# stop trying for a keepalive,
Session.keepalive_sessions.pop(self, None)
self.logged = 0
self.logging = False
self._customkeepalives = None
self.nowait = False
self.socketpool[self.socket] -= 1