summaryrefslogtreecommitdiff
path: root/src/irmd/api_table.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-03-21 16:21:25 +0100
committerSander Vrijders <sander.vrijders@ugent.be>2017-03-21 16:21:25 +0100
commit4b257b249ea91d1ee7e2341c563bac561911e8a6 (patch)
treef45378a6118390d279062577188741ab3d256127 /src/irmd/api_table.c
parent8907220599bec8067c1701c3d8bd19f9bcb19275 (diff)
parentb04b4933fc7f03aef940b4de5fd43815834951ca (diff)
downloadouroboros-4b257b249ea91d1ee7e2341c563bac561911e8a6.tar.gz
ouroboros-4b257b249ea91d1ee7e2341c563bac561911e8a6.zip
Merge branch 'testing' into be
Diffstat (limited to 'src/irmd/api_table.c')
-rw-r--r--src/irmd/api_table.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/irmd/api_table.c b/src/irmd/api_table.c
index df300cea..83153aac 100644
--- a/src/irmd/api_table.c
+++ b/src/irmd/api_table.c
@@ -34,6 +34,7 @@
struct api_entry * api_entry_create(pid_t api, char * apn)
{
struct api_entry * e;
+ pthread_condattr_t cattr;
if (apn == NULL)
return NULL;
@@ -53,8 +54,26 @@ struct api_entry * api_entry_create(pid_t api, char * apn)
e->state = API_INIT;
- pthread_mutex_init(&e->state_lock, NULL);
- pthread_cond_init(&e->state_cond, NULL);
+ if (pthread_condattr_init(&cattr)) {
+ free(e);
+ return NULL;
+ }
+
+#ifndef __APPLE__
+ pthread_condattr_setclock(&cattr, PTHREAD_COND_CLOCK);
+#endif
+
+ if (pthread_mutex_init(&e->state_lock, NULL)) {
+ free(e);
+ return NULL;
+ }
+
+
+ if (pthread_cond_init(&e->state_cond, &cattr)) {
+ pthread_mutex_destroy(&e->state_lock);
+ free(e);
+ return NULL;
+ }
return e;
}