reducing capabilities of the threads to a minimum

proper flush of pending packets on daemon shutdown
adding local address as gateway address in dynamic route
This commit is contained in:
Martin Willi
2007-05-03 14:21:22 +00:00
parent 3d63b7639e
commit 66560f4267
11 changed files with 215 additions and 41 deletions
+3
View File
@@ -254,6 +254,9 @@ static void receive_packets(private_receiver_t *this)
DBG1(DBG_NET, "receiver thread running, thread_ID: %06u",
(int)pthread_self());
/* drop threads capabilities */
charon->drop_capabilities(charon, FALSE, FALSE);
while (TRUE)
{
/* read in a packet */
+9 -2
View File
@@ -84,10 +84,12 @@ static void send_(private_sender_t *this, packet_t *packet)
*/
static void send_packets(private_sender_t * this)
{
/* cancellation disabled by default */
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
DBG1(DBG_NET, "sender thread running, thread_ID: %06u", (int)pthread_self());
/* drop threads capabilities */
charon->drop_capabilities(charon, FALSE, FALSE);
while (TRUE)
{
@@ -119,9 +121,14 @@ static void send_packets(private_sender_t * this)
*/
static void destroy(private_sender_t *this)
{
/* send all packets in the queue */
while (this->list->get_count(this->list))
{
sched_yield();
}
pthread_cancel(this->assigned_thread);
pthread_join(this->assigned_thread, NULL);
this->list->destroy_offset(this->list, offsetof(packet_t, destroy));
this->list->destroy(this->list);
free(this);
}