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
messages.

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

Change-Id: Ia6de02c2f13a56f0381c97a9ab02c6c7a31cc32f
Related: SYS#4399
changes/09/11909/5
Maxim Suraev 4 years ago
parent 1c668f2c47
commit 2a1d8930f6
  1. 8
      scripts/osmo_ctrl.py

@ -41,7 +41,13 @@ def do_set_get(sck, var, value = None):
_leftovers(sck, socket.MSG_DONTWAIT)
(r, c) = Ctrl().cmd(var, value)
sck.send(c)
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)
break;
return (Ctrl().rem_header(ret),) + Ctrl().verify(ret, r, var, value)
def set_var(sck, var, val):

Loading…
Cancel
Save