From 5869a38cd563b82f934059d193194749e7ca576c Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Wed, 19 Jun 2019 17:16:17 +0200 Subject: [PATCH] osmo_trap2cgi.py: Don't recurse in ctrl_client() Use a loop instead. Without it the script will eventually crash with a RecursionError. File "/usr/bin/osmo_trap2cgi.py", line 211, in conn_client await ctrl_client(proxy, reader, writer) File "/usr/bin/osmo_trap2cgi.py", line 202, in ctrl_client proxy.dispatch(wr, data) [...] File "/usr/bin/osmo_trap2cgi.py", line 202, in ctrl_client proxy.dispatch(wr, data) File "/usr/bin/osmo_trap2cgi.py", line 201, in ctrl_client [...] RecursionError: maximum recursion depth exceeded in comparison Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Related: SYS#4399 --- scripts/osmo_trap2cgi.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/osmo_trap2cgi.py b/scripts/osmo_trap2cgi.py index ad66e7b..8aa7649 100755 --- a/scripts/osmo_trap2cgi.py +++ b/scripts/osmo_trap2cgi.py @@ -194,12 +194,12 @@ async def recon_reader(proxy, reader, num_bytes): async def ctrl_client(proxy, rd, wr): """ - Recursively read CTRL stream and handle selected messages. + Read CTRL stream and handle selected messages. """ - header = await recon_reader(proxy, rd, 4) - data = await recon_reader(proxy, rd, get_ctrl_len(proxy, header)) - proxy.dispatch(wr, data) - await ctrl_client(proxy, rd, wr) + while True: + header = await recon_reader(proxy, rd, 4) + data = await recon_reader(proxy, rd, get_ctrl_len(proxy, header)) + proxy.dispatch(wr, data) async def conn_client(proxy): """