diff options
author | Tobias Brunner <tobias@strongswan.org> | 2011-12-22 10:59:47 +0100 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2012-05-02 14:45:38 +0200 |
commit | 052e0a17b8ed2d5b301c1b2aee1a8e11b355304b (patch) | |
tree | 2677fa32931cf4a1f8c5356036d93d3161a08a3a /src/libstrongswan/processing | |
parent | aac20ec784d6b2cd5b299d16502e365c396d364f (diff) | |
download | strongswan-052e0a17b8ed2d5b301c1b2aee1a8e11b355304b.tar.bz2 strongswan-052e0a17b8ed2d5b301c1b2aee1a8e11b355304b.tar.xz |
Use wrapped semaphore in callback_job_t.
Diffstat (limited to 'src/libstrongswan/processing')
-rw-r--r-- | src/libstrongswan/processing/jobs/callback_job.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/libstrongswan/processing/jobs/callback_job.c b/src/libstrongswan/processing/jobs/callback_job.c index 13f22e69c..452c07ce6 100644 --- a/src/libstrongswan/processing/jobs/callback_job.c +++ b/src/libstrongswan/processing/jobs/callback_job.c @@ -17,10 +17,9 @@ #include "callback_job.h" -#include <semaphore.h> - #include <threading/thread.h> #include <threading/condvar.h> +#include <threading/semaphore.h> #include <threading/mutex.h> #include <utils/linked_list.h> @@ -84,10 +83,10 @@ struct private_callback_job_t { /** * semaphore to synchronize the termination of the assigned thread. * - * separately allocated during cancellation, so that we can wait on it - * without risking that it gets freed too early during destruction. + * separately created during cancellation, so that we can wait on it + * without risking that it gets destroyed too early during destruction. */ - sem_t *terminated; + semaphore_t *terminated; /** * Priority of this job @@ -129,7 +128,7 @@ METHOD(job_t, destroy, void, } if (this->terminated) { - sem_post(this->terminated); + this->terminated->post(this->terminated); } this->children->destroy(this->children); this->destroyable->destroy(this->destroyable); @@ -142,7 +141,7 @@ METHOD(callback_job_t, cancel, void, private_callback_job_t *this) { callback_job_t *child; - sem_t *terminated = NULL; + semaphore_t *terminated = NULL; this->mutex->lock(this->mutex); this->cancelled = TRUE; @@ -158,8 +157,7 @@ METHOD(callback_job_t, cancel, void, /* terminate the thread, if there is currently one executing the job. * we wait for its termination using a semaphore */ this->thread->cancel(this->thread); - terminated = this->terminated = malloc_thing(sem_t); - sem_init(terminated, 0, 0); + terminated = this->terminated = semaphore_create(0); } else { @@ -174,9 +172,8 @@ METHOD(callback_job_t, cancel, void, if (terminated) { - sem_wait(terminated); - sem_destroy(terminated); - free(terminated); + terminated->wait(terminated); + terminated->destroy(terminated); } } |