diff options
Diffstat (limited to 'src/ipcpd/normal')
-rw-r--r-- | src/ipcpd/normal/pol/flat.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/ipcpd/normal/pol/flat.c b/src/ipcpd/normal/pol/flat.c index 0ab1e604..82c7db93 100644 --- a/src/ipcpd/normal/pol/flat.c +++ b/src/ipcpd/normal/pol/flat.c @@ -133,9 +133,12 @@ int flat_init(void) { struct ro_attr rattr; pthread_condattr_t cattr; + struct timespec t; char * name; - srand(time(NULL)); + clock_gettime(CLOCK_REALTIME, &t); + + srand(t.tv_nsec); flat.addr_in_use = false; ro_attr_init(&rattr); @@ -235,12 +238,22 @@ uint64_t flat_address(void) } pthread_mutex_lock(&flat.lock); + + if (ro_exists(ro_name)) { + pthread_mutex_unlock(&flat.lock); + free(ro_name); + free(buf); + continue; + } + + if (ro_create(ro_name, &attr, buf, sizeof(*msg))) { pthread_mutex_unlock(&flat.lock); free(ro_name); free(buf); return INVALID_ADDR; } + free(ro_name); while (flat.addr_in_use == false) { @@ -250,6 +263,7 @@ uint64_t flat_address(void) if (ret == -ETIMEDOUT) break; } + pthread_mutex_unlock(&flat.lock); } |