diff options
Diffstat (limited to 'src/charon/plugins')
-rw-r--r-- | src/charon/plugins/eap_radius/radius_client.c | 1 | ||||
-rw-r--r-- | src/charon/plugins/kernel_klips/kernel_klips_ipsec.c | 9 | ||||
-rw-r--r-- | src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c | 10 | ||||
-rw-r--r-- | src/charon/plugins/kernel_netlink/kernel_netlink_net.c | 10 | ||||
-rw-r--r-- | src/charon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c | 10 | ||||
-rw-r--r-- | src/charon/plugins/kernel_pfroute/kernel_pfroute_net.c | 9 | ||||
-rw-r--r-- | src/charon/plugins/load_tester/load_tester_listener.c | 2 | ||||
-rw-r--r-- | src/charon/plugins/load_tester/load_tester_plugin.c | 1 | ||||
-rw-r--r-- | src/charon/plugins/smp/smp.c | 22 | ||||
-rw-r--r-- | src/charon/plugins/stroke/stroke_socket.c | 9 | ||||
-rw-r--r-- | src/charon/plugins/uci/uci_control.c | 9 |
11 files changed, 52 insertions, 40 deletions
diff --git a/src/charon/plugins/eap_radius/radius_client.c b/src/charon/plugins/eap_radius/radius_client.c index e6d68c920..a28f80571 100644 --- a/src/charon/plugins/eap_radius/radius_client.c +++ b/src/charon/plugins/eap_radius/radius_client.c @@ -21,6 +21,7 @@ #include <daemon.h> #include <utils/host.h> #include <utils/linked_list.h> +#include <threading/condvar.h> #include <threading/mutex.h> /** diff --git a/src/charon/plugins/kernel_klips/kernel_klips_ipsec.c b/src/charon/plugins/kernel_klips/kernel_klips_ipsec.c index 29a77de8b..c4adc2413 100644 --- a/src/charon/plugins/kernel_klips/kernel_klips_ipsec.c +++ b/src/charon/plugins/kernel_klips/kernel_klips_ipsec.c @@ -21,7 +21,6 @@ #include <linux/udp.h> #include <net/if.h> #include <unistd.h> -#include <pthread.h> #include <stdio.h> #include <string.h> #include <time.h> @@ -30,6 +29,7 @@ #include "kernel_klips_ipsec.h" #include <daemon.h> +#include <threading/thread.h> #include <threading/mutex.h> #include <processing/jobs/callback_job.h> #include <processing/jobs/acquire_job.h> @@ -1375,11 +1375,12 @@ static job_requeue_t receive_events(private_kernel_klips_ipsec_t *this) { unsigned char buf[PFKEY_BUFFER_SIZE]; struct sadb_msg *msg = (struct sadb_msg*)buf; - int len, oldstate; + int len; + bool oldstate; - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); + oldstate = thread_cancelability(TRUE); len = recv(this->socket_events, buf, sizeof(buf), 0); - pthread_setcancelstate(oldstate, NULL); + thread_cancelability(oldstate); if (len < 0) { diff --git a/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c b/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c index c7f005a32..7fd5c560f 100644 --- a/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c +++ b/src/charon/plugins/kernel_netlink/kernel_netlink_ipsec.c @@ -26,8 +26,8 @@ #include <linux/rtnetlink.h> #include <linux/xfrm.h> #include <linux/udp.h> -#include <pthread.h> #include <unistd.h> +#include <time.h> #include <errno.h> #include <string.h> #include <fcntl.h> @@ -36,6 +36,7 @@ #include "kernel_netlink_shared.h" #include <daemon.h> +#include <threading/thread.h> #include <threading/mutex.h> #include <utils/hashtable.h> #include <processing/jobs/callback_job.h> @@ -748,12 +749,13 @@ static job_requeue_t receive_events(private_kernel_netlink_ipsec_t *this) struct nlmsghdr *hdr = (struct nlmsghdr*)response; struct sockaddr_nl addr; socklen_t addr_len = sizeof(addr); - int len, oldstate; + int len; + bool oldstate; - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); + oldstate = thread_cancelability(TRUE); len = recvfrom(this->socket_xfrm_events, response, sizeof(response), 0, (struct sockaddr*)&addr, &addr_len); - pthread_setcancelstate(oldstate, NULL); + thread_cancelability(oldstate); if (len < 0) { diff --git a/src/charon/plugins/kernel_netlink/kernel_netlink_net.c b/src/charon/plugins/kernel_netlink/kernel_netlink_net.c index 4447dc096..4a9fdf69a 100644 --- a/src/charon/plugins/kernel_netlink/kernel_netlink_net.c +++ b/src/charon/plugins/kernel_netlink/kernel_netlink_net.c @@ -17,7 +17,6 @@ #include <sys/socket.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> -#include <pthread.h> #include <unistd.h> #include <errno.h> #include <net/if.h> @@ -26,6 +25,8 @@ #include "kernel_netlink_shared.h" #include <daemon.h> +#include <threading/thread.h> +#include <threading/condvar.h> #include <threading/mutex.h> #include <utils/linked_list.h> #include <processing/jobs/callback_job.h> @@ -481,12 +482,13 @@ static job_requeue_t receive_events(private_kernel_netlink_net_t *this) struct nlmsghdr *hdr = (struct nlmsghdr*)response; struct sockaddr_nl addr; socklen_t addr_len = sizeof(addr); - int len, oldstate; + int len; + bool oldstate; - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); + oldstate = thread_cancelability(TRUE); len = recvfrom(this->socket_events, response, sizeof(response), 0, (struct sockaddr*)&addr, &addr_len); - pthread_setcancelstate(oldstate, NULL); + thread_cancelability(oldstate); if (len < 0) { diff --git a/src/charon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c b/src/charon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c index 8dc03b80b..9c50746ac 100644 --- a/src/charon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c +++ b/src/charon/plugins/kernel_pfkey/kernel_pfkey_ipsec.c @@ -49,13 +49,14 @@ #endif /*HAVE_NATT*/ #include <unistd.h> -#include <pthread.h> +#include <time.h> #include <errno.h> #include "kernel_pfkey_ipsec.h" #include <daemon.h> #include <utils/host.h> +#include <threading/thread.h> #include <threading/mutex.h> #include <processing/jobs/callback_job.h> #include <processing/jobs/acquire_job.h> @@ -1083,11 +1084,12 @@ static job_requeue_t receive_events(private_kernel_pfkey_ipsec_t *this) { unsigned char buf[PFKEY_BUFFER_SIZE]; struct sadb_msg *msg = (struct sadb_msg*)buf; - int len, oldstate; + int len; + bool oldstate; - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); + oldstate = thread_cancelability(TRUE); len = recvfrom(this->socket_events, buf, sizeof(buf), 0, NULL, 0); - pthread_setcancelstate(oldstate, NULL); + thread_cancelability(oldstate); if (len < 0) { diff --git a/src/charon/plugins/kernel_pfroute/kernel_pfroute_net.c b/src/charon/plugins/kernel_pfroute/kernel_pfroute_net.c index 9aee53928..9f1baf5b5 100644 --- a/src/charon/plugins/kernel_pfroute/kernel_pfroute_net.c +++ b/src/charon/plugins/kernel_pfroute/kernel_pfroute_net.c @@ -19,13 +19,13 @@ #include <ifaddrs.h> #include <net/route.h> #include <unistd.h> -#include <pthread.h> #include <errno.h> #include "kernel_pfroute_net.h" #include <daemon.h> #include <utils/host.h> +#include <threading/thread.h> #include <threading/mutex.h> #include <utils/linked_list.h> #include <processing/jobs/callback_job.h> @@ -326,11 +326,12 @@ static job_requeue_t receive_events(private_kernel_pfroute_net_t *this) { unsigned char buf[PFROUTE_BUFFER_SIZE]; struct rt_msghdr *msg = (struct rt_msghdr*)buf; - int len, oldstate; + int len; + bool oldstate; - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); + oldstate = thread_cancelability(TRUE); len = recvfrom(this->socket_events, buf, sizeof(buf), 0, NULL, 0); - pthread_setcancelstate(oldstate, NULL); + thread_cancelability(oldstate); if (len < 0) { diff --git a/src/charon/plugins/load_tester/load_tester_listener.c b/src/charon/plugins/load_tester/load_tester_listener.c index 540d4fa4f..96b0cf1ec 100644 --- a/src/charon/plugins/load_tester/load_tester_listener.c +++ b/src/charon/plugins/load_tester/load_tester_listener.c @@ -68,7 +68,7 @@ static bool ike_state_change(private_load_tester_listener_t *this, if (this->shutdown_on == ++this->established) { DBG1(DBG_CFG, "load-test complete, raising SIGTERM"); - pthread_kill(charon->main_thread_id, SIGTERM); + kill(0, SIGTERM); } } } diff --git a/src/charon/plugins/load_tester/load_tester_plugin.c b/src/charon/plugins/load_tester/load_tester_plugin.c index 9c6cc9974..e25f97423 100644 --- a/src/charon/plugins/load_tester/load_tester_plugin.c +++ b/src/charon/plugins/load_tester/load_tester_plugin.c @@ -24,6 +24,7 @@ #include <daemon.h> #include <processing/jobs/callback_job.h> +#include <threading/condvar.h> #include <threading/mutex.h> typedef struct private_load_tester_plugin_t private_load_tester_plugin_t; diff --git a/src/charon/plugins/smp/smp.c b/src/charon/plugins/smp/smp.c index 66e4fa6d9..21e682a0a 100644 --- a/src/charon/plugins/smp/smp.c +++ b/src/charon/plugins/smp/smp.c @@ -23,13 +23,13 @@ #include <sys/un.h> #include <unistd.h> #include <errno.h> -#include <pthread.h> #include <signal.h> #include <libxml/xmlreader.h> #include <libxml/xmlwriter.h> #include <library.h> #include <daemon.h> +#include <threading/thread.h> #include <processing/jobs/callback_job.h> @@ -361,7 +361,7 @@ static bool xml_callback(xmlTextWriterPtr writer, debug_t group, level_t level, xmlTextWriterStartElement(writer, "item"); xmlTextWriterWriteFormatAttribute(writer, "level", "%d", level); xmlTextWriterWriteFormatAttribute(writer, "source", "%N", debug_names, group); - xmlTextWriterWriteFormatAttribute(writer, "thread", "%u", pthread_self()); + xmlTextWriterWriteFormatAttribute(writer, "thread", "%u", thread_current_id()); xmlTextWriterWriteVFormatString(writer, format, args); xmlTextWriterEndElement(writer); /* </item> */ @@ -622,17 +622,18 @@ static void closefdp(int *fd) */ static job_requeue_t process(int *fdp) { - int oldstate, fd = *fdp; + int fd = *fdp; + bool oldstate; char buffer[4096]; size_t len; xmlTextReaderPtr reader; char *id = NULL, *type = NULL; - pthread_cleanup_push((void*)closefdp, (void*)&fd); - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); + thread_cleanup_push((thread_cleanup_t)closefdp, (void*)&fd); + oldstate = thread_cancelability(TRUE); len = read(fd, buffer, sizeof(buffer)); - pthread_setcancelstate(oldstate, NULL); - pthread_cleanup_pop(0); + thread_cancelability(oldstate); + thread_cleanup_pop(FALSE); if (len <= 0) { close(fd); @@ -682,13 +683,14 @@ static job_requeue_t process(int *fdp) static job_requeue_t dispatch(private_smp_t *this) { struct sockaddr_un strokeaddr; - int oldstate, fd, *fdp, strokeaddrlen = sizeof(strokeaddr); + int fd, *fdp, strokeaddrlen = sizeof(strokeaddr); callback_job_t *job; + bool oldstate; /* wait for connections, but allow thread to terminate */ - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); + oldstate = thread_cancelability(TRUE); fd = accept(this->socket, (struct sockaddr *)&strokeaddr, &strokeaddrlen); - pthread_setcancelstate(oldstate, NULL); + thread_cancelability(oldstate); if (fd < 0) { diff --git a/src/charon/plugins/stroke/stroke_socket.c b/src/charon/plugins/stroke/stroke_socket.c index 6a599992e..820e097f1 100644 --- a/src/charon/plugins/stroke/stroke_socket.c +++ b/src/charon/plugins/stroke/stroke_socket.c @@ -23,11 +23,10 @@ #include <sys/fcntl.h> #include <unistd.h> #include <errno.h> -#include <pthread.h> #include <processing/jobs/callback_job.h> #include <daemon.h> -#include <threading/mutex.h> /* for Mac OS X compatible accept */ +#include <threading/thread.h> #include "stroke_config.h" #include "stroke_control.h" @@ -547,13 +546,13 @@ static job_requeue_t receive(private_stroke_socket_t *this) struct sockaddr_un strokeaddr; int strokeaddrlen = sizeof(strokeaddr); int strokefd; - int oldstate; + bool oldstate; callback_job_t *job; stroke_job_context_t *ctx; - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); + oldstate = thread_cancelability(TRUE); strokefd = accept(this->socket, (struct sockaddr *)&strokeaddr, &strokeaddrlen); - pthread_setcancelstate(oldstate, NULL); + thread_cancelability(oldstate); if (strokefd < 0) { diff --git a/src/charon/plugins/uci/uci_control.c b/src/charon/plugins/uci/uci_control.c index 9bfc4ecee..3c4928be4 100644 --- a/src/charon/plugins/uci/uci_control.c +++ b/src/charon/plugins/uci/uci_control.c @@ -21,11 +21,11 @@ #include <sys/types.h> #include <sys/stat.h> #include <errno.h> -#include <pthread.h> #include "uci_control.h" #include <daemon.h> +#include <threading/thread.h> #include <processing/jobs/callback_job.h> #define FIFO_FILE "/var/run/charon.fifo" @@ -237,13 +237,14 @@ static void process(private_uci_control_t *this, char *message) static job_requeue_t receive(private_uci_control_t *this) { char message[128]; - int oldstate, len; + int len; + bool oldstate; FILE *in; memset(message, 0, sizeof(message)); - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); + oldstate = thread_cancelability(TRUE); in = fopen(FIFO_FILE, "r"); - pthread_setcancelstate(oldstate, NULL); + thread_cancelability(oldstate); if (in) { len = fread(message, 1, sizeof(message) - 1, in); |