mirror of
https://opendev.org/x/pyghmi
synced 2025-03-19 09:57:43 +00:00
Fix init race condition
When two contexts call into make identical sessions to the same BMC, there is a period where it can rudely overwrite itself. Cover this interval with a more early stage set of waiting sessions. Change-Id: I94a81b19b2c522448f372b06990e1fdb801e0546
This commit is contained in:
parent
05b973dff0
commit
db696bf1fc
@ -291,6 +291,7 @@ class Session(object):
|
||||
"""
|
||||
bmc_handlers = {}
|
||||
waiting_sessions = {}
|
||||
initting_sessions = {}
|
||||
keepalive_sessions = {}
|
||||
peeraddr_to_nodes = {}
|
||||
iterwaiters = []
|
||||
@ -440,8 +441,15 @@ class Session(object):
|
||||
forbidsock.append(self.socket)
|
||||
if trueself:
|
||||
return trueself
|
||||
i = cls.initting_sessions.get(
|
||||
(bmc, userid, password, port, kg), False)
|
||||
if i:
|
||||
i.initialized = True
|
||||
i.logging = True
|
||||
return i
|
||||
self = object.__new__(cls)
|
||||
self.forbidsock = forbidsock
|
||||
cls.initting_sessions[(bmc, userid, password, port, kg)] = self
|
||||
return self
|
||||
|
||||
def __init__(self,
|
||||
@ -1709,6 +1717,12 @@ class Session(object):
|
||||
Session.bmc_handlers[sockaddr] = {}
|
||||
Session.bmc_handlers[sockaddr][myport] = self
|
||||
_io_sendto(self.socket, self.netpacket, sockaddr)
|
||||
try:
|
||||
del Session.initting_sessions[(self.bmc, self.userid,
|
||||
self.password, self.port,
|
||||
self.kgo)]
|
||||
except KeyError:
|
||||
pass
|
||||
except socket.gaierror:
|
||||
raise exc.IpmiException(
|
||||
"Unable to transmit to specified address")
|
||||
|
Loading…
x
Reference in New Issue
Block a user