osmo_ctrl.py: properly ignore out-of-order traps

Sometimes when we set variable we might receive arbitrary number of TRAP
messages before we get SET_REPLY. Those could be either separate
messages or combined together with SET_REPLY depending on tcp buffering
at server side. Let's handle this gracefully by skipping over all TRAP

An example command which often triggers this behavior:
./osmo_ctrl.py -s -d -p 4249 bts.0.location (date +%s)",fix2d,1,2,3"

Change-Id: Ia6de02c2f13a56f0381c97a9ab02c6c7a31cc32f
Related: SYS#4399
Max 2018-11-23 23:02:27 +01:00
parent 1c668f2c47
commit 2a1d8930f6
1 changed files with 7 additions and 1 deletions

View File

@ -41,7 +41,13 @@ def do_set_get(sck, var, value = None):
_leftovers(sck, socket.MSG_DONTWAIT)
(r, c) = Ctrl().cmd(var, value)
ret = sck.recv(4096)
while True:
ret = sck.recv(4096)
# handle multiple messages, ignore TRAPs
ret = Ctrl().skip_traps(ret)
if ret != None:
(i, k, v) = Ctrl().parse(ret)
return (Ctrl().rem_header(ret),) + Ctrl().verify(ret, r, var, value)
def set_var(sck, var, val):