From cbd457b464538b3b8015d26ccf94a10188494c0f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 21 Aug 2024 09:12:18 -0400 Subject: [PATCH] Cancel the recvr task on close This avoids stail recvr from sending duplicate data. --- confluent_server/confluent/plugins/console/openbmc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/plugins/console/openbmc.py b/confluent_server/confluent/plugins/console/openbmc.py index 519ca2d4..3ff08e5a 100644 --- a/confluent_server/confluent/plugins/console/openbmc.py +++ b/confluent_server/confluent/plugins/console/openbmc.py @@ -119,6 +119,7 @@ class TsmConsole(conapi.Console): self.datacallback = None self.nodeconfig = config self.connected = False + self.recvr = None def recvdata(self): @@ -148,13 +149,16 @@ class TsmConsole(conapi.Console): self.ws.set_verify_callback(kv) self.ws.connect('wss://{0}/console0'.format(self.bmc), host=bmc, cookie='XSRF-TOKEN={0}; SESSION={1}'.format(wc.cookies['XSRF-TOKEN'], wc.cookies['SESSION']), subprotocols=[wc.cookies['XSRF-TOKEN']]) self.connected = True - eventlet.spawn_n(self.recvdata) + self.recvr = eventlet.spawn(self.recvdata) return def write(self, data): self.ws.send(data) def close(self): + if self.recvr: + self.recvr.kill() + self.recvr = None if self.ws: self.ws.close() self.connected = False