From 26d77eb3e61b2ff929dff96bbb53a5d22d76ce4f Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Tue, 19 Jun 2012 13:29:09 +0200 Subject: 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. --- src/libcharon/plugins/dhcp/dhcp_socket.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/libcharon/plugins/dhcp/dhcp_socket.c') diff --git a/src/libcharon/plugins/dhcp/dhcp_socket.c b/src/libcharon/plugins/dhcp/dhcp_socket.c index 091d91c2d..b4e9af788 100644 --- a/src/libcharon/plugins/dhcp/dhcp_socket.c +++ b/src/libcharon/plugins/dhcp/dhcp_socket.c @@ -105,11 +105,6 @@ struct private_dhcp_socket_t { * DHCP server address, or broadcast */ host_t *dst; - - /** - * Callback job receiving DHCP responses - */ - callback_job_t *job; }; /** @@ -613,10 +608,6 @@ static job_requeue_t receive_dhcp(private_dhcp_socket_t *this) METHOD(dhcp_socket_t, destroy, void, private_dhcp_socket_t *this) { - if (this->job) - { - this->job->cancel(this->job); - } while (this->waiting) { this->condvar->signal(this->condvar); @@ -761,9 +752,9 @@ dhcp_socket_t *dhcp_socket_create() return NULL; } - this->job = callback_job_create_with_prio((callback_job_cb_t)receive_dhcp, - 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_dhcp, + this, NULL, (callback_job_cancel_t)return_false, JOB_PRIO_CRITICAL)); return &this->public; } -- cgit v1.2.3