Implement abortNotifiedFIFO() to unlock FIFO waits

This commit is contained in:
Robert Schmidt
2022-08-16 14:41:02 +02:00
parent dfd9a91b50
commit 31dcdf2152
2 changed files with 23 additions and 0 deletions
+18
View File
@@ -222,6 +222,24 @@ static inline int abortNotifiedFIFOJob(notifiedFIFO_t *nf, uint64_t key) {
return nbDeleted;
}
// This functions aborts all messages in the queue, and marks the queue as
// "aborted", such that every call to it will return NULL
static inline void abortNotifiedFIFO(notifiedFIFO_t *nf) {
mutexlock(nf->lockF);
nf->abortFIFO = true;
notifiedFIFO_elt_t **elt = &nf->outF;
while(*elt != NULL) {
notifiedFIFO_elt_t *p = *elt;
*elt = (*elt)->next;
delNotifiedFIFO_elt(p);
}
if (nf->outF == NULL)
nf->inF = NULL;
mutexunlock(nf->lockF);
condsignal(nf->notifF);
}
struct one_thread {
pthread_t threadID;
int id;