From 2c8e29ca7a997c5aa9d34e3fa956b120a0bbf20c Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Thu, 18 Aug 2016 14:22:06 +0200 Subject: 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. --- src/ipcpd/ipcp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/ipcpd/ipcp.c') 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; } -- cgit v1.2.3