From 66eb76d0fcdff78707a1bee4040e2411730d1a5a Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Thu, 16 Feb 2012 20:26:35 -0800 Subject: [PATCH] jsonrpc.py: Don't swallow errors in transact_block(). If a server returned an error in response to a request, transact_block() would ignore it. Signed-off-by: Ethan Jackson --- python/ovs/jsonrpc.py | 5 ++++- tests/test-ovsdb.py | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/python/ovs/jsonrpc.py b/python/ovs/jsonrpc.py index 25b02291..1c3f099c 100644 --- a/python/ovs/jsonrpc.py +++ b/python/ovs/jsonrpc.py @@ -301,7 +301,10 @@ class Connection(object): reply = None while not error: error, reply = self.recv_block() - if reply and reply.type == Message.T_REPLY and reply.id == id_: + if (reply + and (reply.type == Message.T_REPLY + or reply.type == Message.T_ERROR) + and reply.id == id_): break return error, reply diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py index df29fdb0..5f3cb995 100644 --- a/tests/test-ovsdb.py +++ b/tests/test-ovsdb.py @@ -375,6 +375,11 @@ def do_idl(schema_file, remote, *commands): sys.stderr.write("jsonrpc transaction failed: %s" % os.strerror(error)) sys.exit(1) + elif reply.error is not None: + sys.stderr.write("jsonrpc transaction failed: %s" + % reply.error) + sys.exit(1) + sys.stdout.write("%03d: " % step) sys.stdout.flush() step += 1 -- 2.30.2