diff options
author | Tobias Brunner <tobias@strongswan.org> | 2012-06-19 13:29:09 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2012-06-25 17:38:59 +0200 |
commit | 26d77eb3e61b2ff929dff96bbb53a5d22d76ce4f (patch) | |
tree | 5d5b7bd7bb2cd6a721c65b82f8ce2a8b3f4fdf22 /src/libcharon/network/receiver.c | |
parent | 7fec83af28f233a02b7ae08c6fd4de65799cb6b4 (diff) | |
download | strongswan-26d77eb3e61b2ff929dff96bbb53a5d22d76ce4f.tar.bz2 strongswan-26d77eb3e61b2ff929dff96bbb53a5d22d76ce4f.tar.xz |
Centralized thread cancellation in processor_t
This ensures that no threads are active when plugins and the rest of the
daemon are unloaded.
callback_job_t was simplified a lot in the process as its main
functionality is now contained in processor_t. The parent-child
relationships were abandoned as these were only needed to simplify job
cancellation.
Diffstat (limited to 'src/libcharon/network/receiver.c')
-rw-r--r-- | src/libcharon/network/receiver.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/libcharon/network/receiver.c b/src/libcharon/network/receiver.c index 1e00eb239..f0cb0b2d1 100644 --- a/src/libcharon/network/receiver.c +++ b/src/libcharon/network/receiver.c @@ -55,11 +55,6 @@ struct private_receiver_t { receiver_t public; /** - * Threads job receiving packets - */ - callback_job_t *job; - - /** * current secret to use for cookie calculation */ char secret[SECRET_LENGTH]; @@ -393,8 +388,6 @@ static job_requeue_t receive_packets(private_receiver_t *this) status = charon->socket->receive(charon->socket, &packet); if (status == NOT_SUPPORTED) { - /* the processor destroys this job */ - this->job = NULL; return JOB_REQUEUE_NONE; } else if (status != SUCCESS) @@ -504,10 +497,6 @@ static job_requeue_t receive_packets(private_receiver_t *this) METHOD(receiver_t, destroy, void, private_receiver_t *this) { - if (this->job) - { - this->job->cancel(this->job); - } this->rng->destroy(this->rng); this->hasher->destroy(this->hasher); free(this); @@ -568,9 +557,9 @@ receiver_t *receiver_create() this->rng->get_bytes(this->rng, SECRET_LENGTH, this->secret); memcpy(this->secret_old, this->secret, SECRET_LENGTH); - this->job = callback_job_create_with_prio((callback_job_cb_t)receive_packets, - this, NULL, NULL, JOB_PRIO_CRITICAL); - lib->processor->queue_job(lib->processor, (job_t*)this->job); + lib->processor->queue_job(lib->processor, + (job_t*)callback_job_create_with_prio((callback_job_cb_t)receive_packets, + this, NULL, (callback_job_cancel_t)return_false, JOB_PRIO_CRITICAL)); return &this->public; } |