summaryrefslogtreecommitdiffstats
path: root/src/vpp-api
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2019-06-20 13:46:46 -0400
committerAndrew Yourtchenko <ayourtch@gmail.com>2019-06-25 11:25:07 +0000
commit08d82e98cdf75c810659fcb347e89198cf7b0bc5 (patch)
treeecd94110b1288a3ffb170ca2e546f7f95ca004d7 /src/vpp-api
parent8f818cc35972f447acd3cf68229d5f9e634926f3 (diff)
api: fix vac_read return codes
- vac_read was returning the same code for multiple errors. - Refactor VppTransportShmemIOError to capture rv and description. Type: refactor Change-Id: Ifb8ca5ff679f658bcd92a43ecddaffd2fc18dbd5 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'src/vpp-api')
-rw-r--r--src/vpp-api/client/client.c6
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_transport_shmem.py11
2 files changed, 13 insertions, 4 deletions
diff --git a/src/vpp-api/client/client.c b/src/vpp-api/client/client.c
index 5b47fd4dd7d..50d088c1bfb 100644
--- a/src/vpp-api/client/client.c
+++ b/src/vpp-api/client/client.c
@@ -450,11 +450,13 @@ vac_read (char **p, int *l, u16 timeout)
int rv;
vl_shmem_hdr_t *shmem_hdr;
- if (!pm->connected_to_vlib) return -1;
+ /* svm_queue_sub(below) returns {-1, -2} */
+ if (!pm->connected_to_vlib) return -3;
*l = 0;
- if (am->our_pid == 0) return (-1);
+ /* svm_queue_sub(below) returns {-1, -2} */
+ if (am->our_pid == 0) return (-4);
/* Poke timeout thread */
if (timeout)
diff --git a/src/vpp-api/python/vpp_papi/vpp_transport_shmem.py b/src/vpp-api/python/vpp_papi/vpp_transport_shmem.py
index 53ae775069f..64c1a59ba74 100644
--- a/src/vpp-api/python/vpp_papi/vpp_transport_shmem.py
+++ b/src/vpp-api/python/vpp_papi/vpp_transport_shmem.py
@@ -48,7 +48,13 @@ def vac_error_handler(arg, msg, msg_len):
class VppTransportShmemIOError(IOError):
- pass
+ """ exception communicating with vpp over shared memory """
+
+ def __init__(self, rv, descr):
+ self.rv = rv
+ self.desc = descr
+
+ super(VppTransportShmemIOError, self).__init__(rv, descr)
class VppTransport(object):
@@ -117,7 +123,8 @@ class VppTransport(object):
size = ffi.new("int *")
rv = vpp_api.vac_read(mem, size, self.read_timeout)
if rv:
- raise VppTransportShmemIOError(rv, 'vac_read failed')
+ strerror = 'vac_read failed. It is likely that VPP died.'
+ raise VppTransportShmemIOError(rv, strerror)
msg = bytes(ffi.buffer(mem[0], size[0]))
vpp_api.vac_free(mem[0])
return msg