summaryrefslogtreecommitdiff
path: root/src/ipcpd
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-12-25 11:27:43 +0100
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-12-25 11:27:43 +0100
commitbd99555a130400cfec1cbdcf5e4eaa08f133d041 (patch)
tree75bbe4ec07abb96119f153a7bf687b187ff868b6 /src/ipcpd
parent64b5f41e1723a034fab8eee45931e1aa8b50e104 (diff)
parent5ae1fb3db5bf11ee2159b8461cdf1e54a2a0ef45 (diff)
downloadouroboros-bd99555a130400cfec1cbdcf5e4eaa08f133d041.tar.gz
ouroboros-bd99555a130400cfec1cbdcf5e4eaa08f133d041.zip
Merged in dstaesse/ouroboros/be-flat (pull request #328)
Some fixes
Diffstat (limited to 'src/ipcpd')
-rw-r--r--src/ipcpd/normal/pol/flat.c16
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);
}