From d73e1a41335a12efdf662bb2e37c90800c277c3c Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 30 Jun 2022 11:44:11 +0200 Subject: [PATCH] Handle NULL return of pullTpool() --- executables/main-fs6.c | 2 ++ executables/nr-gnb.c | 9 ++++++++- executables/nr-ru.c | 2 ++ executables/nr-ue.c | 4 ++++ openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c | 2 ++ openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c | 2 ++ openair1/SCHED/phy_procedures_lte_eNb.c | 7 ++++++- openair1/SCHED_NR/fapi_nr_l1.c | 2 ++ openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 ++ 9 files changed, 30 insertions(+), 2 deletions(-) diff --git a/executables/main-fs6.c b/executables/main-fs6.c index fff4c51155..01dfc526e9 100644 --- a/executables/main-fs6.c +++ b/executables/main-fs6.c @@ -740,6 +740,8 @@ void pusch_procedures_fromsplit(uint8_t *bufferZone, int bufSize, PHY_VARS_eNB * while (proc->nbDecode > 0) { notifiedFIFO_elt_t *req=pullTpool(proc->respDecode, proc->threadPool); + if (req == NULL) + break; // Tpool has been stopped postDecode(proc, req); delNotifiedFIFO_elt(req); } diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 3e195e0046..0db095c148 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -248,6 +248,8 @@ void rx_func(void *param) { // Its a FIFO so it maitains the order in which the MAC fills the messages // so no need for checking for right slot res = pullTpool(&gNB->L1_tx_filled, &gNB->threadPool); + if (res == NULL) + return; // Tpool has been stopped syncMsg = (processingData_L1tx_t *)NotifiedFifoData(res); syncMsg->gNB = gNB; syncMsg->timestamp_tx = info->timestamp_tx; @@ -255,6 +257,8 @@ void rx_func(void *param) { pushTpool(&gNB->threadPool, res); } else if (get_softmodem_params()->continuous_tx) { notifiedFIFO_elt_t *res = pullTpool(&gNB->L1_tx_free, &gNB->threadPool); + if (res == NULL) + return; // Tpool has been stopped processingData_L1tx_t *syncMsg = (processingData_L1tx_t *)NotifiedFifoData(res); syncMsg->gNB = gNB; syncMsg->timestamp_tx = info->timestamp_tx; @@ -377,6 +381,7 @@ void *tx_reorder_thread(void* param) { resL1Reserve = pullTpool(&gNB->L1_tx_out, &gNB->threadPool); + AssertFatal(resL1Reserve != NULL, "pullTpool() did not return start message in %s\n", __func__); int next_tx_slot=((processingData_L1tx_t *)NotifiedFifoData(resL1Reserve))->slot; while (!oai_exit) { @@ -390,7 +395,7 @@ void *tx_reorder_thread(void* param) { } } else { resL1 = pullTpool(&gNB->L1_tx_out, &gNB->threadPool); - if (((processingData_L1tx_t *)NotifiedFifoData(resL1))->slot != next_tx_slot) { + if (resL1 != NULL && ((processingData_L1tx_t *)NotifiedFifoData(resL1))->slot != next_tx_slot) { if (resL1Reserve) LOG_E(PHY,"error, have a stored packet, then a second one\n"); resL1Reserve = resL1; @@ -399,6 +404,8 @@ void *tx_reorder_thread(void* param) { LOG_E(PHY,"error, pull two msg, none is good\n"); } } + if (resL1 == NULL) + break; // Tpool has been stopped processingData_L1tx_t *syncMsgL1= (processingData_L1tx_t *)NotifiedFifoData(resL1); processingData_RU_t syncMsgRU; syncMsgRU.frame_tx = syncMsgL1->frame; diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 31c555e61d..b29947c9be 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1252,6 +1252,8 @@ void *ru_thread( void *param ) { // At this point, all information for subframe has been received on FH interface res = pullTpool(&gNB->resp_L1, &gNB->threadPool); + if (res == NULL) + break; // Tpool has been stopped syncMsg = (processingData_L1_t *)NotifiedFifoData(res); syncMsg->gNB = gNB; syncMsg->frame_rx = proc->frame_rx; diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 616312a21a..7a981e9a58 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -692,6 +692,8 @@ void processSlotRX(void *arg) { // Wait for PUSCH processing to finish notifiedFIFO_elt_t *res; res = pullTpool(&rxtxD->txFifo,&(get_nrUE_params()->Tpool)); + if (res == NULL) + return; // Tpool has been stopped delNotifiedFIFO_elt(res); // calling UL_indication to schedule things other than PUSCH (eg, PUCCH) @@ -1008,6 +1010,8 @@ void *UE_thread(void *arg) { while (nbSlotProcessing >= NR_RX_NB_TH) { res=pullTpool(&nf, &(get_nrUE_params()->Tpool)); + if (res == NULL) + break; // Tpool has been stopped nbSlotProcessing--; nr_rxtx_thread_data_t *tmp=(nr_rxtx_thread_data_t *)res->msgData; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 5b57cd125f..af00abddc5 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -430,6 +430,8 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, } while(nbJobs) { notifiedFIFO_elt_t *req=pullTpool(&nf, &gNB->threadPool); + if (req == NULL) + break; // Tpool has been stopped delNotifiedFIFO_elt(req); nbJobs--; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 5aa792fb19..7bfc2203dc 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -615,6 +615,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, } for (r=0; rthreadPool->activated ) { // Wait all other threads finish to process while (proc->nbEncode) { - delNotifiedFIFO_elt(pullTpool(proc->respEncode, proc->threadPool)); + notifiedFIFO_elt_t *res = pullTpool(proc->respEncode, proc->threadPool); + if (res == NULL) + break; // Tpool has been stopped + delNotifiedFIFO_elt(res); proc->nbEncode--; } } @@ -1502,6 +1505,8 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { while (proc->nbDecode > 0) { notifiedFIFO_elt_t *req=pullTpool(proc->respDecode, proc->threadPool); + if (req == NULL) + break; // Tpool has been stopped postDecode(proc, req); delNotifiedFIFO_elt(req); } diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index 2c61704508..49e6edd54e 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -164,6 +164,8 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ if (slot_type == NR_DOWNLINK_SLOT || slot_type == NR_MIXED_SLOT) { notifiedFIFO_elt_t *res; res = pullTpool(&gNB->L1_tx_free, &gNB->threadPool); + if (res == NULL) + return; // Tpool has been stopped, nothing to process processingData_L1tx_t *msgTx = (processingData_L1tx_t *)NotifiedFifoData(res); const time_stats_t ts = exec_time_stats_NotifiedFIFO(res); merge_meas(&gNB->phy_proc_tx, &ts); diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 1298ce3d49..684869dbd9 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -364,6 +364,8 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH while (gNB->nbDecode > 0) { notifiedFIFO_elt_t *req = pullTpool(&gNB->respDecode, &gNB->threadPool); + if (req == NULL) + break; // Tpool has been stopped nr_postDecode(gNB, req); delNotifiedFIFO_elt(req); }