From c35781d4cf32f7c7974070384e7bd323b1edbd7c Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 14 Sep 2016 13:02:26 -0400 Subject: [PATCH] Fix error behavior when target has no SOL session When a system did not have any custom keep alive, the code to mark the esssion broken erroneously tries to dereference. Change-Id: Ic4efe3c65ee4c09c97ef9f08dc30603c4c15d872 --- pyghmi/ipmi/private/session.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyghmi/ipmi/private/session.py b/pyghmi/ipmi/private/session.py index caba4a8e..cfa34944 100644 --- a/pyghmi/ipmi/private/session.py +++ b/pyghmi/ipmi/private/session.py @@ -496,14 +496,15 @@ class Session(object): if self.logged: self.logged = 0 # mark session as busted self.logging = False - for ka in list(self._customkeepalives): + if self._customkeepalives: + for ka in list(self._customkeepalives): # Be thorough and notify parties through their custom # keepalives. In practice, this *should* be the same, but # if a code somehow makes duplicate SOL handlers, # this would notify all the handlers rather than just the # last one to take ownership - self._customkeepalives[ka][1]( - {'error': 'Session Disconnected'}) + self._customkeepalives[ka][1]( + {'error': 'Session Disconnected'}) self._customkeepalives = None if not self.broken: self.socketpool[self.socket] -= 1