lib,rf_imp: load rf plugins when loading this library

This fixes race of concurrently loading the same plugins
when srsran_rf_open_devname is called by multiple threads

Plugins are now loaded when srsran_rf is loaded (for
shared lib) or right before main() (for static lib)
This commit is contained in:
Robert Falkenberg 2022-03-21 10:39:39 +01:00
parent e6f42331ba
commit a5c61418d5
2 changed files with 8 additions and 6 deletions

View File

@ -94,11 +94,6 @@ const char* srsran_rf_get_devname(srsran_rf_t* rf)
int srsran_rf_open_devname(srsran_rf_t* rf, const char* devname, char* args, uint32_t nof_channels) int srsran_rf_open_devname(srsran_rf_t* rf, const char* devname, char* args, uint32_t nof_channels)
{ {
if (srsran_rf_load_plugins() != SRSRAN_SUCCESS) {
ERROR("Failed to load RF plugins");
return SRSRAN_ERROR;
}
rf->thread_gain_run = false; rf->thread_gain_run = false;
bool no_rf_devs_detected = true; bool no_rf_devs_detected = true;
@ -482,3 +477,11 @@ int srsran_rf_load_plugins()
#endif /* ENABLE_RF_PLUGINS */ #endif /* ENABLE_RF_PLUGINS */
return SRSRAN_SUCCESS; return SRSRAN_SUCCESS;
} }
// Search and load plugins when this library is loaded (shared) or right before main (static)
void __attribute__((constructor)) init()
{
if (srsran_rf_load_plugins() != SRSRAN_SUCCESS) {
ERROR("Failed to load RF plugins");
}
}

View File

@ -233,7 +233,6 @@ int param_test(const char* args_param, const int num_channels)
int main() int main()
{ {
srsran_rf_load_plugins();
// // two Rx ports // // two Rx ports
// if (param_test("rx_port=ipc://dl0,rx_port1=ipc://dl1", 2)) { // if (param_test("rx_port=ipc://dl0,rx_port1=ipc://dl1", 2)) {
// fprintf(stderr, "Param test failed!\n"); // fprintf(stderr, "Param test failed!\n");