From 52aaeef506f35814f458be5c45be1abf888bb726 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 21 Oct 2015 10:30:41 -0400 Subject: [PATCH] Have server avoid sending empty data While the client can handle it now, have the server avoid needless processing of '' data from a console provider. Address it at the deepest level (the tlvdata implementation) and a place higher up the stack to avoid hits to log and such. --- confluent_client/confluent/tlvdata.py | 3 +++ confluent_server/confluent/consoleserver.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/confluent_client/confluent/tlvdata.py b/confluent_client/confluent/tlvdata.py index 356a4ee0..5a13f901 100644 --- a/confluent_client/confluent/tlvdata.py +++ b/confluent_client/confluent/tlvdata.py @@ -38,6 +38,9 @@ def send(handle, data): if isinstance(data, str): # plain text, e.g. console data tl = len(data) + if tl == 0: + # if you don't have anything to say, don't say anything at all + return if tl < 16777216: # type for string is '0', so we don't need # to xor anything in diff --git a/confluent_server/confluent/consoleserver.py b/confluent_server/confluent/consoleserver.py index 37a70161..0e0bdeaa 100644 --- a/confluent_server/confluent/consoleserver.py +++ b/confluent_server/confluent/consoleserver.py @@ -347,6 +347,9 @@ class _ConsoleHandler(object): if data == conapi.ConsoleEvent.Disconnect: self._got_disconnected() return + elif data == '': + # ignore empty strings from a cconsole provider + return if '\x1b[?1l' in data: # request for ansi mode cursor keys self.appmodedetected = False if '\x1b[?1h' in data: # remember the session wants the client to use