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/charon-nm/nm | |
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/charon-nm/nm')
-rw-r--r-- | src/charon-nm/nm/nm_backend.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/charon-nm/nm/nm_backend.c b/src/charon-nm/nm/nm_backend.c index 19382a028..19d095935 100644 --- a/src/charon-nm/nm/nm_backend.c +++ b/src/charon-nm/nm/nm_backend.c @@ -67,6 +67,22 @@ static job_requeue_t run(nm_backend_t *this) return JOB_REQUEUE_NONE; } +/** + * Cancel the GLib Main Event Loop + */ +static bool cancel(nm_backend_t *this) +{ + if (this->loop) + { + if (g_main_loop_is_running(this->loop)) + { + g_main_loop_quit(this->loop); + } + g_main_loop_unref(this->loop); + } + return TRUE; +} + /* * see header file */ @@ -78,14 +94,6 @@ void nm_backend_deinit() { return; } - if (this->loop) - { - if (g_main_loop_is_running(this->loop)) - { - g_main_loop_quit(this->loop); - } - g_main_loop_unref(this->loop); - } if (this->plugin) { g_object_unref(this->plugin); @@ -132,8 +140,8 @@ bool nm_backend_init() charon->keep_cap(charon, CAP_DAC_OVERRIDE); lib->processor->queue_job(lib->processor, - (job_t*)callback_job_create_with_prio((callback_job_cb_t)run, - this, NULL, NULL, JOB_PRIO_CRITICAL)); + (job_t*)callback_job_create_with_prio((callback_job_cb_t)run, this, + NULL, (callback_job_cancel_t)cancel, JOB_PRIO_CRITICAL)); return TRUE; } |