From 10b039074f8aa164a0ecf7d1c8be17af39ba6a82 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Wed, 15 Feb 2017 19:31:38 +0100 Subject: [PATCH] Avoid a crash in some conditions when reading the serial console --- gns3server/utils/asyncio/serial.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gns3server/utils/asyncio/serial.py b/gns3server/utils/asyncio/serial.py index 48d12bc0..c118a87e 100644 --- a/gns3server/utils/asyncio/serial.py +++ b/gns3server/utils/asyncio/serial.py @@ -34,6 +34,7 @@ class SerialReaderWriterProtocol(asyncio.Protocol): def __init__(self): self._output = asyncio.StreamReader() + self._closed = False self.transport = None def read(self, n=-1): @@ -54,9 +55,11 @@ class SerialReaderWriterProtocol(asyncio.Protocol): self.transport = transport def data_received(self, data): - self._output.feed_data(data) + if not self._closed: + self._output.feed_data(data) def close(self): + self._closed = True self._output.feed_eof()