diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 1dd8ba7d40805987d65cd1de1c94363a981c7506..58a5e46e09a576bc6b6d9f9f3b65f91625be209f 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1295,12 +1295,6 @@ void *ru_thread( void *param ) { printf( "Exiting ru_thread \n"); - if (ru->stop_rf != NULL) { - if (ru->stop_rf(ru) != 0) - LOG_E(HW,"Could not stop the RF device\n"); - else LOG_I(PHY,"RU %d rf device stopped\n",ru->idx); - } - ru_thread_status = 0; return &ru_thread_status; } @@ -1378,6 +1372,18 @@ void kill_NR_RU_proc(int inst) { LOG_D(PHY, "Joining ru_stats_thread\n"); pthread_join(ru->ru_stats_thread, NULL); } + + // everything should be stopped now, we can safely stop the RF device + if (ru->stop_rf == NULL) { + LOG_W(PHY, "No stop_rf() for RU %d defined, cannot stop RF!\n", ru->idx); + return; + } + int rc = ru->stop_rf(ru); + if (rc != 0) { + LOG_W(PHY, "stop_rf() returned %d, RU %d RF device did not stop properly!\n", rc, ru->idx); + return; + } + LOG_I(PHY, "RU %d RF device stopped\n",ru->idx); } int check_capabilities(RU_t *ru,RRU_capabilities_t *cap) {