mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
queue_signalled: handle cancellation while waiting correctly
This commit is contained in:
parent
a6ffa0ed0d
commit
1365f9d026
1 changed files with 3 additions and 0 deletions
|
@ -39,8 +39,11 @@ int queue_signalled_push_many(struct queue_signalled *qs, void *ptr[], size_t cn
|
|||
|
||||
int queue_signalled_pull_many(struct queue_signalled *qs, void *ptr[], size_t cnt)
|
||||
{
|
||||
/* Make sure that qs->mt is unlocked if this thread gets cancelled. */
|
||||
pthread_cleanup_push((void (*)(void*)) pthread_mutex_unlock, &qs->mt);
|
||||
pthread_mutex_lock(&qs->mt);
|
||||
pthread_cond_wait(&qs->ready, &qs->mt);
|
||||
pthread_mutex_unlock(&qs->mt);
|
||||
pthread_cleanup_pop(0);
|
||||
return queue_pull_many(&qs->q, ptr, cnt);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue