1
0
Fork 0
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:
Georg Reinke 2017-04-10 11:39:35 +02:00
parent a6ffa0ed0d
commit 1365f9d026

View file

@ -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);
}