summaryrefslogtreecommitdiff
path: root/src/ipcpd/unicast
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipcpd/unicast')
-rw-r--r--src/ipcpd/unicast/dht.c18
-rw-r--r--src/ipcpd/unicast/fa.c5
-rw-r--r--src/ipcpd/unicast/pol/link_state.c19
3 files changed, 19 insertions, 23 deletions
diff --git a/src/ipcpd/unicast/dht.c b/src/ipcpd/unicast/dht.c
index 3dc592db..2b668f9f 100644
--- a/src/ipcpd/unicast/dht.c
+++ b/src/ipcpd/unicast/dht.c
@@ -42,12 +42,12 @@
#include <ouroboros/time_utils.h>
#include <ouroboros/tpm.h>
#include <ouroboros/utils.h>
+#include <ouroboros/pthread.h>
#include "common/connmgr.h"
#include "dht.h"
#include "dt.h"
-#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
@@ -308,8 +308,7 @@ int dht_wait_running(struct dht * dht)
pthread_mutex_lock(&dht->mtx);
- pthread_cleanup_push((void *)(void *) pthread_mutex_unlock,
- &dht->mtx);
+ pthread_cleanup_push(__cleanup_mutex_unlock, &dht->mtx);
while (dht->state == DHT_JOINING)
pthread_cond_wait(&dht->cond, &dht->mtx);
@@ -466,8 +465,7 @@ static int kad_req_wait(struct kad_req * req,
req->state = REQ_PENDING;
- pthread_cleanup_push((void *)(void *) pthread_mutex_unlock,
- &req->lock);
+ pthread_cleanup_push(__cleanup_mutex_unlock, &req->lock);
while (req->state == REQ_PENDING && ret != -ETIMEDOUT)
ret = -pthread_cond_timedwait(&req->cond, &req->lock, &abs);
@@ -819,8 +817,7 @@ static void lookup_update(struct dht * dht,
return;
}
- pthread_cleanup_push((void *)(void *) pthread_mutex_unlock,
- &lu->lock);
+ pthread_cleanup_push(__cleanup_mutex_unlock, &lu->lock);
while (lu->state == LU_INIT) {
pthread_rwlock_unlock(&dht->lock);
@@ -967,7 +964,7 @@ static void lookup_set_state(struct lookup * lu,
pthread_mutex_unlock(&lu->lock);
}
-static void cleanup_wait(void * o)
+static void cancel_lookup_wait(void * o)
{
struct lookup * lu = (struct lookup *) o;
lu->state = LU_NULL;
@@ -991,7 +988,7 @@ static enum lookup_state lookup_wait(struct lookup * lu)
if (lu->state == LU_INIT || lu->state == LU_UPDATE)
lu->state = LU_PENDING;
- pthread_cleanup_push(cleanup_wait, lu);
+ pthread_cleanup_push(cancel_lookup_wait, lu);
while (lu->state == LU_PENDING && ret != -ETIMEDOUT)
ret = -pthread_cond_timedwait(&lu->cond, &lu->lock, &abs);
@@ -2421,8 +2418,7 @@ static void * dht_handle_packet(void * o)
pthread_mutex_lock(&dht->mtx);
- pthread_cleanup_push((void *)(void *) pthread_mutex_unlock,
- &dht->mtx);
+ pthread_cleanup_push(__cleanup_mutex_unlock, &dht->mtx);
while (list_is_empty(&dht->cmds))
pthread_cond_wait(&dht->cond, &dht->mtx);
diff --git a/src/ipcpd/unicast/fa.c b/src/ipcpd/unicast/fa.c
index b3b9b42c..3ebdc1f1 100644
--- a/src/ipcpd/unicast/fa.c
+++ b/src/ipcpd/unicast/fa.c
@@ -38,6 +38,7 @@
#include <ouroboros/ipcp-dev.h>
#include <ouroboros/rib.h>
#include <ouroboros/random.h>
+#include <ouroboros/pthread.h>
#include "dir.h"
#include "fa.h"
@@ -47,7 +48,6 @@
#include "ca.h"
#include <inttypes.h>
-#include <pthread.h>
#include <stdlib.h>
#include <string.h>
@@ -442,8 +442,7 @@ static void * fa_handle_packet(void * o)
pthread_mutex_lock(&fa.mtx);
- pthread_cleanup_push((void (*)(void *)) pthread_mutex_unlock,
- &fa.mtx);
+ pthread_cleanup_push(__cleanup_mutex_unlock, &fa.mtx);
while (list_is_empty(&fa.cmds))
pthread_cond_wait(&fa.cond, &fa.mtx);
diff --git a/src/ipcpd/unicast/pol/link_state.c b/src/ipcpd/unicast/pol/link_state.c
index e8983ec6..cca85d63 100644
--- a/src/ipcpd/unicast/pol/link_state.c
+++ b/src/ipcpd/unicast/pol/link_state.c
@@ -38,6 +38,7 @@
#include <ouroboros/list.h>
#include <ouroboros/logs.h>
#include <ouroboros/notifier.h>
+#include <ouroboros/pthread.h>
#include <ouroboros/rib.h>
#include <ouroboros/utils.h>
@@ -52,7 +53,6 @@
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
-#include <pthread.h>
#define RECALC_TIME 4
#define LS_UPDATE_TIME 15
@@ -648,8 +648,7 @@ static void * lsupdate(void * o)
pthread_rwlock_wrlock(&ls.db_lock);
- pthread_cleanup_push((void (*) (void *)) pthread_rwlock_unlock,
- (void *) &ls.db_lock);
+ pthread_cleanup_push(__cleanup_rwlock_unlock, &ls.db_lock);
list_for_each_safe(p, h, &ls.db) {
struct adjacency * adj;
@@ -709,8 +708,7 @@ static void forward_lsm(uint8_t * buf,
pthread_rwlock_rdlock(&ls.db_lock);
- pthread_cleanup_push((void (*))(void *) pthread_rwlock_unlock,
- &ls.db_lock);
+ pthread_cleanup_push(__cleanup_rwlock_unlock, &ls.db_lock);
list_for_each(p, &ls.nbs) {
struct nb * nb = list_entry(p, struct nb, next);
@@ -721,6 +719,11 @@ static void forward_lsm(uint8_t * buf,
pthread_cleanup_pop(true);
}
+static void cleanup_fqueue(void * fq)
+{
+ fqueue_destroy((fqueue_t *) fq);
+}
+
static void * lsreader(void * o)
{
fqueue_t * fq;
@@ -739,8 +742,7 @@ static void * lsreader(void * o)
if (fq == NULL)
return (void *) -1;
- pthread_cleanup_push((void (*) (void *)) fqueue_destroy,
- (void *) fq);
+ pthread_cleanup_push(cleanup_fqueue, fq);
while (true) {
ret = fevent(ls.mgmt_set, fq, NULL);
@@ -813,8 +815,7 @@ static void handle_event(void * self,
case NOTIFY_DT_CONN_ADD:
pthread_rwlock_rdlock(&ls.db_lock);
- pthread_cleanup_push((void (*) (void *)) pthread_rwlock_unlock,
- (void *) &ls.db_lock);
+ pthread_cleanup_push(__cleanup_rwlock_unlock, &ls.db_lock);
send_lsm(ipcpi.dt_addr, c->conn_info.addr, 0);
pthread_cleanup_pop(true);