diff options
author | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-08-18 14:22:06 +0200 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-08-19 13:24:39 +0200 |
commit | 2c8e29ca7a997c5aa9d34e3fa956b120a0bbf20c (patch) | |
tree | 6807a23a6def167a2b9ab26937fe25bbcc2a8064 /src/ipcpd/ipcp.c | |
parent | 0192488015770b4855165db8502214dad1941dd2 (diff) | |
download | ouroboros-2c8e29ca7a997c5aa9d34e3fa956b120a0bbf20c.tar.gz ouroboros-2c8e29ca7a997c5aa9d34e3fa956b120a0bbf20c.zip |
ipcpd: normal: Handle enrollment replies
This adds a condition variable with a timeout to the CDAP request so
that we can respond correctly to the answer from the remote. It also
adds a timeout to the condition variable waiting on completion of
enrollment. Furthermore, for every CDAP callback a new thread is now
spawned, to avoid deadlocking in case a callback is stuck.
Diffstat (limited to 'src/ipcpd/ipcp.c')
-rw-r--r-- | src/ipcpd/ipcp.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index 544b10df..0263d7b5 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -33,6 +33,8 @@ struct ipcp * ipcp_instance_create() { + pthread_condattr_t cattr; + struct ipcp * i = malloc(sizeof *i); if (i == NULL) return NULL; @@ -43,7 +45,9 @@ struct ipcp * ipcp_instance_create() i->state = IPCP_INIT; pthread_mutex_init(&i->state_lock, NULL); - pthread_cond_init(&i->state_cond, NULL); + pthread_condattr_init(&cattr); + pthread_condattr_setclock(&cattr, PTHREAD_COND_CLOCK); + pthread_cond_init(&i->state_cond, &cattr); return i; } |