aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/libhicnctrl
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-12-12 17:39:44 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-12-12 17:49:01 +0100
commit7795737fc9254bc75d6ff1dcbc9b8372a537b511 (patch)
tree2901ea15e7bcc3356fbdf8491720b2eebbb43d44 /ctrl/libhicnctrl
parent63a3a23b3e72e72c88b44e74e9923c1ae2b817a3 (diff)
[HICN-451] libhicnctrl creates collisions in created connection names when two instances are started in the same second
Change-Id: I70ccaf9199aa50074501d368d189c01521f37971 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'ctrl/libhicnctrl')
-rw-r--r--ctrl/libhicnctrl/src/api.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/ctrl/libhicnctrl/src/api.c b/ctrl/libhicnctrl/src/api.c
index b836ef800..9fb923d13 100644
--- a/ctrl/libhicnctrl/src/api.c
+++ b/ctrl/libhicnctrl/src/api.c
@@ -26,6 +26,12 @@
#include <sys/socket.h> // socket
#include <unistd.h> // close, fcntl
#include <fcntl.h> // fcntl
+#include <sys/types.h> // getpid
+#include <unistd.h> // getpid
+#ifdef __linux__
+#include <sys/syscall.h>
+#define gettid() syscall(SYS_gettid)
+#endif /* __linux__ */
#include <hicn/ctrl/api.h>
#include <hicn/ctrl/commands.h>
@@ -435,7 +441,11 @@ hc_sock_parse_url(const char * url, struct sockaddr * sa)
/* FIXME URL parsing is currently not implemented */
assert(!url);
- srand(time(NULL));
+#ifdef __linux__
+ srand(time(NULL) ^ getpid() ^ gettid());
+#else
+ srand(time(NULL) ^ getpid());
+#endif /* __linux__ */
/*
* A temporary solution is to inspect the sa_family fields of the passed in