diff options
author | Martin Willi <martin@strongswan.org> | 2005-12-02 14:58:45 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2005-12-02 14:58:45 +0000 |
commit | a0fb67f500cf3d459ed133f71ef08dd4366f83ac (patch) | |
tree | 54c615e47fc9079995f3c22558dee282726c6524 /Source | |
parent | 016dfc72535275bf9af60f488926dd04a0c8a9d5 (diff) | |
download | strongswan-a0fb67f500cf3d459ed133f71ef08dd4366f83ac.tar.bz2 strongswan-a0fb67f500cf3d459ed133f71ef08dd4366f83ac.tar.xz |
- allow termination of getting thread
Diffstat (limited to 'Source')
-rw-r--r-- | Source/charon/queues/event_queue.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/charon/queues/event_queue.c b/Source/charon/queues/event_queue.c index 7c76aa682..c641a5a60 100644 --- a/Source/charon/queues/event_queue.c +++ b/Source/charon/queues/event_queue.c @@ -189,7 +189,15 @@ static job_t *get(private_event_queue_t *this) timeout.tv_sec = next_event->time.tv_sec; timeout.tv_nsec = next_event->time.tv_usec * 1000; + /* add mutex unlock handler for cancellation, enable cancellation */ + pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock, (void*)&(this->mutex)); + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); + pthread_cond_timedwait( &(this->condvar), &(this->mutex),&timeout); + + /* reset cancellation, remove mutex-unlock handler (without executing) */ + pthread_setcancelstate(oldstate, NULL); + pthread_cleanup_pop(0); } else { |