From 4337179d7e9ce25f0da3ba8d6812147507c2bff7 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 1 Feb 2019 09:17:04 -0500 Subject: [PATCH] Fix break handling in SOL When the retry logic was moved to console, it exposed a problem with the sol handler being called in the midst of transmitting without clearing the pending payload, resulting in an infinite recursion of sending the same break. Resolve by using the common call to sendoutput to have it occur only after the current head of pending output has been removed. Change-Id: Iaae86a3bd870c1841530e200ef0f5780a5cc6993 --- pyghmi/ipmi/console.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pyghmi/ipmi/console.py b/pyghmi/ipmi/console.py index a15a835a..7c8e5572 100644 --- a/pyghmi/ipmi/console.py +++ b/pyghmi/ipmi/console.py @@ -1,6 +1,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2014 IBM Corporation +# Copyright 2015-2019 Lenovo # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -237,23 +238,25 @@ class Console(object): def _sendpendingoutput(self): with self.outputlock: + dobreak = False + chunk = '' if len(self.pendingoutput) == 0: return if isinstance(self.pendingoutput[0], dict): if 'break' in self.pendingoutput[0]: - self._sendoutput("", sendbreak=True) + dobreak = True else: + del self.pendingoutput[0] raise ValueError del self.pendingoutput[0] - return - if len(self.pendingoutput[0]) > self.maxoutcount: + elif len(self.pendingoutput[0]) > self.maxoutcount: chunk = self.pendingoutput[0][:self.maxoutcount] self.pendingoutput[0] = self.pendingoutput[0][ self.maxoutcount:] else: chunk = self.pendingoutput[0] del self.pendingoutput[0] - self._sendoutput(chunk) + self._sendoutput(chunk, sendbreak=dobreak) def _sendoutput(self, output, sendbreak=False): self.myseq += 1