diff --git a/common/utils/actor/actor.c b/common/utils/actor/actor.c index 68661ddb6d7c017846b37c656bc47fa0a8b75e2c..de4022e40bc1df730dcddf458a28092638cdf31e 100644 --- a/common/utils/actor/actor.c +++ b/common/utils/actor/actor.c @@ -50,7 +50,8 @@ void *actor_thread(void *arg) break; } - elt->processingFunc(NotifiedFifoData(elt)); + if (elt->processingFunc) // processing function can be NULL + elt->processingFunc(NotifiedFifoData(elt)); if (elt->reponseFifo) { pushNotifiedFIFO(elt->reponseFifo, elt); } else @@ -85,3 +86,14 @@ void shutdown_actor(Actor_t *actor) abortNotifiedFIFO(&response_fifo); pthread_join(actor->thread, NULL); } + +void flush_actor(Actor_t *actor) +{ + notifiedFIFO_t response_fifo; + initNotifiedFIFO(&response_fifo); + notifiedFIFO_elt_t *elt = newNotifiedFIFO_elt(0, 0, &response_fifo, NULL); + pushNotifiedFIFO(&actor->fifo, elt); + elt = pullNotifiedFIFO(&response_fifo); + delNotifiedFIFO_elt(elt); + abortNotifiedFIFO(&response_fifo); +} diff --git a/common/utils/actor/actor.h b/common/utils/actor/actor.h index 474554c6673b256876cfea6ca417061fff1301d6..023533d2d780b2ea74b62d93dd4f68be8cafb94c 100644 --- a/common/utils/actor/actor.h +++ b/common/utils/actor/actor.h @@ -49,4 +49,9 @@ void destroy_actor(Actor_t *actor); /// @param actor void shutdown_actor(Actor_t *actor); +/// @brief This function will return when all current jobs in the queue are finished. +/// The caller should make sure no new jobs are added to the queue between this function call and return. +/// @param actor +void flush_actor(Actor_t *actor); + #endif diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 1dd1836fa7e18dfa11118e89f910f2cbacedcfe4..1c4fc333446b469d6cdf1680a49256e0b92d121c 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -570,7 +570,6 @@ static int handle_sync_req_from_mac(PHY_VARS_NR_UE *UE) NR_DL_FRAME_PARMS *fp = &UE->frame_parms; // Start synchronization with a target gNB if (UE->synch_request.received_synch_request == 1) { - UE->is_synchronized = 0; // if upper layers signal BW scan we do as instructed by command line parameter // if upper layers disable BW scan we set it to false if (UE->synch_request.synch_req.ssb_bw_scan) @@ -590,7 +589,15 @@ static int handle_sync_req_from_mac(PHY_VARS_NR_UE *UE) init_symbol_rotation(fp); } + /* Clearing UE harq while DL actors are active causes race condition. + So we let the current execution to complete here.*/ + for (int i = 0; i < NUM_DL_ACTORS; i++) { + flush_actor(UE->dl_actors + i); + } + /*TODO: Flush UL jobs */ + clean_UE_harq(UE); + UE->is_synchronized = 0; UE->synch_request.received_synch_request = 0; return 0; }