aboutsummaryrefslogtreecommitdiffstats
path: root/src/charon/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/charon/network')
-rw-r--r--src/charon/network/receiver.c6
-rw-r--r--src/charon/network/sender.c13
-rw-r--r--src/charon/network/socket-raw.c12
-rw-r--r--src/charon/network/socket.c13
4 files changed, 20 insertions, 24 deletions
diff --git a/src/charon/network/receiver.c b/src/charon/network/receiver.c
index 1a33251b6..6cd99439b 100644
--- a/src/charon/network/receiver.c
+++ b/src/charon/network/receiver.c
@@ -17,7 +17,6 @@
#include <stdlib.h>
#include <unistd.h>
-#include <pthread.h>
#include "receiver.h"
@@ -57,11 +56,6 @@ struct private_receiver_t {
callback_job_t *job;
/**
- * Assigned thread.
- */
- pthread_t assigned_thread;
-
- /**
* current secret to use for cookie calculation
*/
char secret[SECRET_LENGTH];
diff --git a/src/charon/network/sender.c b/src/charon/network/sender.c
index c644f1d41..3be5861dd 100644
--- a/src/charon/network/sender.c
+++ b/src/charon/network/sender.c
@@ -15,13 +15,14 @@
*/
#include <stdlib.h>
-#include <pthread.h>
#include "sender.h"
#include <daemon.h>
#include <network/socket.h>
#include <processing/jobs/callback_job.h>
+#include <threading/thread.h>
+#include <threading/condvar.h>
#include <threading/mutex.h>
@@ -85,19 +86,19 @@ static void send_(private_sender_t *this, packet_t *packet)
static job_requeue_t send_packets(private_sender_t * this)
{
packet_t *packet;
- int oldstate;
+ bool oldstate;
this->mutex->lock(this->mutex);
while (this->list->get_count(this->list) == 0)
{
/* add cleanup handler, wait for packet, remove cleanup handler */
- pthread_cleanup_push((void(*)(void*))this->mutex->unlock, this->mutex);
- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
+ thread_cleanup_push((thread_cleanup_t)this->mutex->unlock, this->mutex);
+ oldstate = thread_cancelability(TRUE);
this->got->wait(this->got, this->mutex);
- pthread_setcancelstate(oldstate, NULL);
- pthread_cleanup_pop(0);
+ thread_cancelability(oldstate);
+ thread_cleanup_pop(FALSE);
}
this->list->remove_first(this->list, (void**)&packet);
this->sent->signal(this->sent);
diff --git a/src/charon/network/socket-raw.c b/src/charon/network/socket-raw.c
index 18b31d637..6cc0463b2 100644
--- a/src/charon/network/socket-raw.c
+++ b/src/charon/network/socket-raw.c
@@ -18,7 +18,6 @@
/* for struct in6_pktinfo */
#define _GNU_SOURCE
-#include <pthread.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
@@ -38,6 +37,7 @@
#include "socket.h"
#include <daemon.h>
+#include <threading/thread.h>
/* constants for packet handling */
#define IP_LEN sizeof(struct iphdr)
@@ -127,8 +127,8 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
packet_t *pkt;
struct udphdr *udp;
host_t *source = NULL, *dest = NULL;
- int bytes_read = 0;
- int data_offset, oldstate;
+ int bytes_read = 0, data_offset;
+ bool oldstate;
fd_set rfds;
FD_ZERO(&rfds);
@@ -144,13 +144,13 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
DBG2(DBG_NET, "waiting for data on raw sockets");
- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
+ oldstate = thread_cancelability(TRUE);
if (select(max(this->recv4, this->recv6) + 1, &rfds, NULL, NULL, NULL) <= 0)
{
- pthread_setcancelstate(oldstate, NULL);
+ thread_cancelability(oldstate);
return FAILED;
}
- pthread_setcancelstate(oldstate, NULL);
+ thread_cancelability(oldstate);
if (this->recv4 && FD_ISSET(this->recv4, &rfds))
{
diff --git a/src/charon/network/socket.c b/src/charon/network/socket.c
index ab276aedc..8d2b3badb 100644
--- a/src/charon/network/socket.c
+++ b/src/charon/network/socket.c
@@ -23,7 +23,6 @@
#define __EXTENSIONS__
#endif
-#include <pthread.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
@@ -45,6 +44,7 @@
#include "socket.h"
#include <daemon.h>
+#include <threading/thread.h>
/* length of non-esp marker */
#define MARKER_LEN sizeof(u_int32_t)
@@ -117,8 +117,9 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
chunk_t data;
packet_t *pkt;
host_t *source = NULL, *dest = NULL;
- int bytes_read = 0;
- int data_offset, oldstate;
+ int bytes_read = 0, data_offset;
+ bool oldstate;
+
fd_set rfds;
int max_fd = 0, selected = 0;
u_int16_t port = 0;
@@ -144,13 +145,13 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
max_fd = max(max(this->ipv4, this->ipv4_natt), max(this->ipv6, this->ipv6_natt));
DBG2(DBG_NET, "waiting for data on sockets");
- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
+ oldstate = thread_cancelability(TRUE);
if (select(max_fd + 1, &rfds, NULL, NULL, NULL) <= 0)
{
- pthread_setcancelstate(oldstate, NULL);
+ thread_cancelability(oldstate);
return FAILED;
}
- pthread_setcancelstate(oldstate, NULL);
+ thread_cancelability(oldstate);
if (FD_ISSET(this->ipv4, &rfds))
{