Fail early if configuration module can not initialize properly
In the case that the config module cannot load the driver for libconfig
or yaml, currently, there might be a cascade of errors that are
difficult for users to understand. For instance (partially redacted for
clarity):
[CONFIG] Error calling dlopen(libparams_libconfig.so): libparams_libconfig.so: cannot open shared object file: No such file or directory
[CONFIG] config module "libconfig" couldn't be loaded
[CONFIG] config_get, section log_config skipped, config module not properly initialized
[LOG] init aborted, configuration couldn't be performed
[CONFIG] config_get, section (null) skipped, config module not properly initialized
[CONFIG] /home/francesco/openairinterface5g/common/config/config_userapi.c 68 nfapi has no processed integer availablle
[CONFIG] config_get, section (null) skipped, config module not properly initialized
Assertion (get_softmodem_params()->default_pdu_session_id == -1) failed!
In get_common_options() /home/francesco/openairinterface5g/executables/softmodem-common.c:161
Use uicc0.pdu_sessions.[0].id to change the requested PDU session ID (is 0)
Here, the error is the missing shared object, but a user is more likely
to look at the last error instead of the first.
This commit addresses it by checking early for
CONFIG_ISFLAGSET(CONFIG_ABORT), and stopping if it is set. Additionally
changes include making functions static, removing late
CONFIG_ISFLAGSET() checks, and the CONFIG_ISFLAGSET() in
load_configmodule(), because at that time "uniqCfg" is not set yet and
thus does not do anything (this is likely a regression of an earlier
cleanup).
See-also: f50d5f5a9b ("make multiple config instead of one implicit
global")
This commit is contained in:
@@ -514,7 +514,7 @@ int main( int argc, char **argv ) {
|
||||
start_background_system();
|
||||
|
||||
///static configuration for NR at the moment
|
||||
if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == NULL) {
|
||||
if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == NULL || CONFIG_ISFLAGSET(CONFIG_ABORT)) {
|
||||
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
|
||||
}
|
||||
|
||||
@@ -528,11 +528,6 @@ int main( int argc, char **argv ) {
|
||||
lock_memory_to_ram();
|
||||
get_options(uniqCfg);
|
||||
|
||||
if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) {
|
||||
fprintf(stderr,"Getting configuration failed\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!has_cap_sys_nice())
|
||||
LOG_W(UTIL,
|
||||
"no SYS_NICE capability: cannot set thread priority and affinity, consider running with sudo for optimum performance\n");
|
||||
|
||||
@@ -248,7 +248,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
start_background_system();
|
||||
|
||||
if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == NULL) {
|
||||
if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == NULL || CONFIG_ISFLAGSET(CONFIG_ABORT)) {
|
||||
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
|
||||
}
|
||||
//set_softmodem_sighandler();
|
||||
|
||||
Reference in New Issue
Block a user