summaryrefslogtreecommitdiff
path: root/src/ipcpd/unicast/fa.c
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2021-06-21 20:24:03 +0200
committerSander Vrijders <[email protected]>2021-06-23 08:36:48 +0200
commit8ca960fa0274018cb4f94a1826029d74e6f762e0 (patch)
tree268ffb6b24027d65c738a8edd196a1ed52134fcc /src/ipcpd/unicast/fa.c
parentac53f8ea09b9a24321bc2c00832ba8a117115134 (diff)
downloadouroboros-8ca960fa0274018cb4f94a1826029d74e6f762e0.tar.gz
ouroboros-8ca960fa0274018cb4f94a1826029d74e6f762e0.zip
lib, ipcpd, irmd: Wrap pthread unlocks for cleanup
This add an ouroboros/pthread.h header that wraps the pthread_..._unlock() functions for cleanup using pthread_cleanup_push() as this casting is not safe (and there were definitely bad casts in the code). The close() function is now also wrapped for cleanup in ouroboros/sockets.h. This allows enabling more compiler checks. Signed-off-by: Dimitri Staessens <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/ipcpd/unicast/fa.c')
-rw-r--r--src/ipcpd/unicast/fa.c5
1 files changed, 2 insertions, 3 deletions
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);