From 7795737fc9254bc75d6ff1dcbc9b8372a537b511 Mon Sep 17 00:00:00 2001 From: Jordan Augé Date: Thu, 12 Dec 2019 17:39:44 +0100 Subject: [HICN-451] libhicnctrl creates collisions in created connection names when two instances are started in the same second MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I70ccaf9199aa50074501d368d189c01521f37971 Signed-off-by: Jordan Augé --- ctrl/libhicnctrl/src/api.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'ctrl') 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 // socket #include // close, fcntl #include // fcntl +#include // getpid +#include // getpid +#ifdef __linux__ +#include +#define gettid() syscall(SYS_gettid) +#endif /* __linux__ */ #include #include @@ -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 -- cgit 1.2.3-korg