From b56e6824ca8be66f446f79a920d7297d17f481ab Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 8 Jun 2015 17:00:28 +0200 Subject: [PATCH] (configd) speedup configd commandline tool --- src/opnsense/service/configd_ctl.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/opnsense/service/configd_ctl.py b/src/opnsense/service/configd_ctl.py index 09ff1891d..25c796b20 100755 --- a/src/opnsense/service/configd_ctl.py +++ b/src/opnsense/service/configd_ctl.py @@ -60,17 +60,19 @@ def exec_config_cmd(exec_command): try: sock.send(exec_command) - data = "" + data = [] while True: - line = sock.recv(4096) + line = sock.recv(65536) if line: - data = data + line + data.append(line) # end of stream marker found, exit - if data.find("%c%c%c"%(chr(0),chr(0),chr(0))) > -1: + if line.find("%c%c%c"%(chr(0), chr(0), chr(0))) > -1 or ( + len(line) < 3 and len(data) > 1 and (''.join(data[-2:])).find("%c%c%c"%(chr(0), chr(0), chr(0))) > -1 + ): break - return (data[:-3]) + return ''.join(data)[:-3] except: print ('error in configd communication %s, see syslog for details') syslog.syslog(syslog.LOG_ERR,'error in configd communication \n%s'%traceback.format_exc())