diff --git a/common/utils/threadPool/thread-pool.h b/common/utils/threadPool/thread-pool.h index 6dc8d6ae8c190417e08a02895842c5200e521c84..1a06e4c655c6b8f2fabfc02dda847eb77d78c366 100644 --- a/common/utils/threadPool/thread-pool.h +++ b/common/utils/threadPool/thread-pool.h @@ -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; diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 0db095c1483b82d32eabec9e4959e548dbefaf53..388d701b83189116696f338eeddb2b0fc7223766 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -477,6 +477,11 @@ void init_gNB_Tpool(int inst) { void term_gNB_Tpool(int inst) { PHY_VARS_gNB *gNB = RC.gNB[inst]; abortTpool(&gNB->threadPool); + abortNotifiedFIFO(&gNB->respDecode); + abortNotifiedFIFO(&gNB->resp_L1); + abortNotifiedFIFO(&gNB->L1_tx_free); + abortNotifiedFIFO(&gNB->L1_tx_filled); + abortNotifiedFIFO(&gNB->L1_tx_out); } /*!