From cf4adce3e92fbce6927ebfc7aefc453c3109154e Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 11 Jun 2018 14:41:28 -0400 Subject: [PATCH] Move SOL payload retries to console.py SOL packets are treated differently and as such should interleave with non-console data. Particularly if SOL payload gets deactivated by something else, do not presume the whole session to be broken (leave that to the command based keepalive). Change-Id: Ic70b57cd6834e6936f1d5a6b855dbe835200ad41 --- pyghmi/ipmi/console.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pyghmi/ipmi/console.py b/pyghmi/ipmi/console.py index 368ac52e..c05de4ae 100644 --- a/pyghmi/ipmi/console.py +++ b/pyghmi/ipmi/console.py @@ -22,6 +22,7 @@ import threading from pyghmi.ipmi.private import constants from pyghmi.ipmi.private import session +from pyghmi.ipmi.private.util import _monotonic_time class Console(object): @@ -266,7 +267,18 @@ class Console(object): self.awaitingack = True payload = struct.unpack("%dB" % len(payload), payload) self.lastpayload = payload - self.send_payload(payload, needskeepalive=needskeepalive) + self.send_payload(payload, retry=False, needskeepalive=needskeepalive) + retries = 5 + while retries and self.awaitingack: + expiry = _monotonic_time() + 5.5 - retries + while self.awaitingack and _monotonic_time() < expiry: + self.wait_for_rsp(0.5) + if self.awaitingack: + self.send_payload(payload, retry=False, + needskeepalive=needskeepalive) + retries -= 1 + if not retries: + self._print_error('Connection lost') def send_payload(self, payload, payload_type=1, retry=True, needskeepalive=False): @@ -382,7 +394,7 @@ class Console(object): # try to mitigate by avoiding overeager retries # occasional retry of a packet # sooner than timeout suggests is evidently a big deal - self.send_payload(payload=self.lastpayload) + self.send_payload(payload=self.lastpayload, retry=False) def main_loop(self): """Process all events until no more sessions exist.