vcl: add api to check if vcl disconnected from vpp 66/37366/5
authorMaros Ondrejicka <maros.ondrejicka@pantheon.tech>
Thu, 6 Oct 2022 16:17:05 +0000 (18:17 +0200)
committerFlorin Coras <florin.coras@gmail.com>
Thu, 6 Oct 2022 20:32:43 +0000 (20:32 +0000)
Type: feature
Signed-off-by: Maros Ondrejicka <maros.ondrejicka@pantheon.tech>
Change-Id: I98bc108360f9d04a33126865ce49d2702cbe9cdf

src/vcl/vppcom.c
src/vcl/vppcom.h

index d217058..ae45be3 100644 (file)
@@ -4490,6 +4490,17 @@ vppcom_session_get_error (uint32_t session_handle)
     return VPPCOM_OK;
 }
 
+int
+vppcom_worker_is_detached (void)
+{
+  vcl_worker_t *wrk = vcl_worker_get_current ();
+
+  if (!vcm->cfg.use_mq_eventfd)
+    return VPPCOM_ENOTSUP;
+
+  return wrk->api_client_handle == ~0;
+}
+
 /*
  * fd.io coding-style-patch-verification: ON
  *
index 6e15cd1..08724cc 100644 (file)
@@ -102,7 +102,8 @@ typedef enum
   VPPCOM_ENOPROTOOPT = -ENOPROTOOPT,
   VPPCOM_EPIPE = -EPIPE,
   VPPCOM_ENOENT = -ENOENT,
-  VPPCOM_EADDRINUSE = -EADDRINUSE
+  VPPCOM_EADDRINUSE = -EADDRINUSE,
+  VPPCOM_ENOTSUP = -ENOTSUP
 } vppcom_error_t;
 
 typedef enum
@@ -272,6 +273,14 @@ extern int vppcom_worker_mqs_epfd (void);
  */
 extern int vppcom_session_get_error (uint32_t session_handle);
 
+/**
+ * Returns true if current worker is disconnected from vpp
+ *
+ * Application can use this API to check if VPP is disconnected
+ * as long as `use-mq-eventfd` is being set
+ */
+extern int vppcom_worker_is_detached (void);
+
 /* *INDENT-OFF* */
 #ifdef __cplusplus
 }