aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin/vapi/include
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2020-01-27 16:04:33 +0100
committerAlberto Compagno <acompagn+fdio@cisco.com>2020-01-27 16:56:28 +0100
commitb0768b35fb515b7c0a15c3c7d8c1227497c59786 (patch)
tree1e2b1318f680fffd555ddc26a48e4a4156b06dfc /hicn-plugin/vapi/include
parentbe54ac541c9700eaa9085bc8b4ee21b7a5f7e30a (diff)
[HICN-488] Adding lock to vapi calls and manage vapi_connect in order to connect only once.
- Added library to hicn-plugin called safe_vapi that takes care of handling concurrent calls to the vapi. - Removed dependency of libhicnctrl from libtransport and added dependency to safe_vapi. - Added dependency to safe_vapi on libhicnctrl Change-Id: Ie49e8319f64a50e7ed6a56e041db977c3b184cc5 Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'hicn-plugin/vapi/include')
-rw-r--r--hicn-plugin/vapi/include/vapi/vapi_safe.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/hicn-plugin/vapi/include/vapi/vapi_safe.h b/hicn-plugin/vapi/include/vapi/vapi_safe.h
new file mode 100644
index 000000000..df1114cde
--- /dev/null
+++ b/hicn-plugin/vapi/include/vapi/vapi_safe.h
@@ -0,0 +1,19 @@
+#ifndef VAPI_SAFE
+#include <vapi/vapi.h>
+#include <pthread.h>
+
+extern pthread_mutex_t *mutex;
+
+vapi_error_e vapi_connect_safe(vapi_ctx_t * vapi_ctx_ret, int async);
+
+vapi_error_e vapi_disconnect_safe();
+void vapi_lock();
+
+void vapi_unlock();
+
+#define VAPI_SAFE (NAME, res, ...) \
+ vapi_lock(); \
+ res = ## NAME (__ARGS__); \
+ vapi_unlock();
+
+#endif //VAPI_SAFE