mirror of
https://opendev.org/x/pyghmi
synced 2025-02-20 12:30:48 +00:00
Avoid zombie sessions corrupting living sessions
A logged out session failed to deregister it's keepalive. As a result, the zombie keepalive executed and failed. The failure path then corrupts the bmc_handlers structure. Correct this by both deregistering the erroneous keepalive and having the mark_broken function be more careful about deleting a member of the class hash that it may have nothing to do with. Change-Id: I41251309dc27ffaca89cc7deef9bf16a61f1d07e
This commit is contained in:
parent
fd82b398df
commit
f17ebf03dd
@ -376,18 +376,19 @@ class Session(object):
|
||||
# since our connection has failed retries
|
||||
# deregister our keepalive facility
|
||||
Session.keepalive_sessions.pop(self, None)
|
||||
self.logged = 0 # mark session as busted
|
||||
if not self.broken:
|
||||
self.socketpool[self.socket] -= 1
|
||||
self.broken = True
|
||||
# since this session is broken, remove it from the handler list.
|
||||
# This allows constructor to create a new, functional object to
|
||||
# replace this one
|
||||
for sockaddr in self.allsockaddrs:
|
||||
if sockaddr in Session.bmc_handlers:
|
||||
del Session.bmc_handlers[sockaddr]
|
||||
if self.sol_handler:
|
||||
self.sol_handler({'error': 'Session Disconnected'})
|
||||
if self.logged:
|
||||
self.logged = 0 # mark session as busted
|
||||
if not self.broken:
|
||||
self.socketpool[self.socket] -= 1
|
||||
self.broken = True
|
||||
# since this session is broken, remove it from the handler list
|
||||
# This allows constructor to create a new, functional object to
|
||||
# replace this one
|
||||
for sockaddr in self.allsockaddrs:
|
||||
if sockaddr in Session.bmc_handlers:
|
||||
del Session.bmc_handlers[sockaddr]
|
||||
if self.sol_handler:
|
||||
self.sol_handler({'error': 'Session Disconnected'})
|
||||
|
||||
def onlogon(self, parameter):
|
||||
if 'error' in parameter:
|
||||
@ -1370,6 +1371,8 @@ class Session(object):
|
||||
data=struct.unpack("4B",
|
||||
struct.pack("I", self.sessionid)),
|
||||
retry=False)
|
||||
# stop trying for a keepalive,
|
||||
Session.keepalive_sessions.pop(self, None)
|
||||
self.logged = 0
|
||||
self.nowait = False
|
||||
self.socketpool[self.socket] -= 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user