diff options
author | dimitri staessens <[email protected]> | 2017-03-21 15:19:02 +0000 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-03-21 15:19:02 +0000 |
commit | b04b4933fc7f03aef940b4de5fd43815834951ca (patch) | |
tree | 835d86fa8c9695e95ef213dc5644d1a7f1fdc395 /src/irmd/api_table.c | |
parent | 15b492ffb0de010b94bfb4e80c721e04ef6f63c2 (diff) | |
parent | 19a3277dbff7fc79c12be8a200ab6c8dfe6b50b9 (diff) | |
download | ouroboros-b04b4933fc7f03aef940b4de5fd43815834951ca.tar.gz ouroboros-b04b4933fc7f03aef940b4de5fd43815834951ca.zip |
Merged in dstaesse/ouroboros/testing-waits (pull request #407)
irmd: Fix timeouts in reg_entry
Diffstat (limited to 'src/irmd/api_table.c')
-rw-r--r-- | src/irmd/api_table.c | 23 |
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; } |