mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Fix probable crash and signal handler
This commit is contained in:
parent
3cdbb5432c
commit
72ad1ac91a
4 changed files with 22 additions and 43 deletions
|
|
@ -57,19 +57,10 @@ static void sig_handler(int sig)
|
|||
if (sig == SIGSEGV) {
|
||||
handle_pending_signal(sig);
|
||||
} else if (sig == SIGUSR1) {
|
||||
ERR("# Exception in PID[%ld]", getpid());
|
||||
ERR("# SIGUSR1 handler for main process PID[%ld]", getpid());
|
||||
}
|
||||
}
|
||||
|
||||
static void service_sig_handler(int sig)
|
||||
{
|
||||
WARNING("# PID[%ld] received %d signal ...", getpid(), sig);
|
||||
if (sig == SIGSEGV) {
|
||||
ERR("# Exception in PID[%ld] ...", getpid());
|
||||
}
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
static void signal_init(void)
|
||||
{
|
||||
signal(SIGSEGV, sig_handler);
|
||||
|
|
@ -78,7 +69,7 @@ static void signal_init(void)
|
|||
|
||||
static void service_signal_init(void)
|
||||
{
|
||||
signal(SIGSEGV, service_sig_handler);
|
||||
signal(SIGSEGV, sig_handler);
|
||||
}
|
||||
|
||||
static void usage(char *prog)
|
||||
|
|
@ -1607,10 +1598,9 @@ void bbfdm_ctx_init(struct bbfdm_context *bbfdm_ctx)
|
|||
int daemon_load_datamodel(struct bbfdm_context *daemon_ctx)
|
||||
{
|
||||
int err = -1;
|
||||
char *tmp = daemon_ctx->config.in_type;
|
||||
char *file_path = daemon_ctx->config.in_name;
|
||||
|
||||
if (DM_STRLEN(tmp) == 0 || DM_STRLEN(file_path) == 0) {
|
||||
if (DM_STRLEN(file_path) == 0) {
|
||||
ERR("Input type/name not supported or defined");
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1629,21 +1619,28 @@ int daemon_load_datamodel(struct bbfdm_context *daemon_ctx)
|
|||
ERR("output object not defined");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (DM_STRLEN(daemon_ctx->config.out_root_obj) == 0) {
|
||||
ERR("output root obj not defined");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (strcasecmp(tmp, "JSON") == 0) {
|
||||
char *ext = strrchr(file_path, '.');
|
||||
if (ext == NULL) {
|
||||
ERR("Input file without extension");
|
||||
} else if (strcasecmp(ext, ".json") == 0) {
|
||||
INFO("Loading JSON plugin %s", file_path);
|
||||
err = load_json_plugin(&loaded_json_files, &json_list, &json_memhead, file_path, &DEAMON_DM_ROOT_OBJ);
|
||||
} else if (strcasecmp(tmp, "DotSo") == 0) {
|
||||
} else if (strcasecmp(ext, ".so") == 0) {
|
||||
INFO("Loading DotSo plugin %s", file_path);
|
||||
err = load_dotso_plugin(&deamon_lib_handle, file_path, &DEAMON_DM_ROOT_OBJ, DEAMON_DM_VENDOR_EXTENSION, &DEAMON_DM_VENDOR_EXTENSION_EXCLUDE);
|
||||
} else {
|
||||
ERR("Input type %s not supported", tmp);
|
||||
ERR("Input type %s not supported", ext);
|
||||
}
|
||||
|
||||
if (!err) {
|
||||
INFO("Loading sub-modules %s", daemon_ctx->config.in_plugin_dir);
|
||||
bbf_global_init(DEAMON_DM_ROOT_OBJ, DEAMON_DM_VENDOR_EXTENSION, DEAMON_DM_VENDOR_EXTENSION_EXCLUDE, daemon_ctx->config.in_plugin_dir);
|
||||
} else {
|
||||
ERR("Failed loading %s", file_path);
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ int bbfdm_cmd_exec(struct dmctx *bbf_ctx, int cmd)
|
|||
} else {
|
||||
ERR("PID [%ld]::Exception on [%d => %s]", getpid(), cmd, bbf_ctx->in_param);
|
||||
fault = USP_FAULT_INTERNAL_ERROR;
|
||||
if (is_micro_service) {
|
||||
ERR("Micro-service PID [%ld]::Exception on [%d => %s]", getpid(), cmd, bbf_ctx->in_param);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
gs_jump_called_by_bbf = false;
|
||||
|
|
|
|||
|
|
@ -23,8 +23,10 @@ int load_dotso_plugin(void **lib_handle, const char *file_path,
|
|||
DM_MAP_VENDOR *main_Extension[],
|
||||
DM_MAP_VENDOR_EXCLUDE **main_Extension_exclude)
|
||||
{
|
||||
if (!lib_handle || !file_path || !strlen(file_path) || !main_entry || !main_Extension || !main_Extension_exclude)
|
||||
if (!lib_handle || !file_path || !strlen(file_path) || !main_entry || !main_Extension || !main_Extension_exclude) {
|
||||
ERR("Input validation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *handle = dlopen(file_path, RTLD_NOW|RTLD_LOCAL);
|
||||
if (!handle) {
|
||||
|
|
|
|||
|
|
@ -196,25 +196,6 @@ void get_list_of_registered_service(struct list_head *srvlist, struct blob_buf *
|
|||
}
|
||||
}
|
||||
|
||||
static void free_specific_dynamic_node(DMOBJ *entryobj, int indx)
|
||||
{
|
||||
for (; (entryobj && entryobj->obj); entryobj++) {
|
||||
|
||||
if (entryobj->nextdynamicobj) {
|
||||
struct dm_dynamic_obj *next_dyn_array = entryobj->nextdynamicobj + indx;
|
||||
FREE(next_dyn_array->nextobj);
|
||||
}
|
||||
|
||||
if (entryobj->dynamicleaf) {
|
||||
struct dm_dynamic_leaf *next_dyn_array = entryobj->dynamicleaf + indx;
|
||||
FREE(next_dyn_array->nextleaf);
|
||||
}
|
||||
|
||||
if (entryobj->nextobj)
|
||||
free_specific_dynamic_node(entryobj->nextobj, indx);
|
||||
}
|
||||
}
|
||||
|
||||
static void free_all_dynamic_nodes(DMOBJ *entryobj)
|
||||
{
|
||||
for (; (entryobj && entryobj->obj); entryobj++) {
|
||||
|
|
@ -410,22 +391,17 @@ int load_plugins(DMOBJ *dm_entryobj, DM_MAP_VENDOR *dm_VendorExtension[], DM_MAP
|
|||
|
||||
#ifdef BBF_VENDOR_EXTENSION
|
||||
// Load objects and parameters exposed via vendor extension plugin
|
||||
free_specific_dynamic_node(dm_entryobj, INDX_VENDOR_MOUNT);
|
||||
load_vendor_dynamic_arrays(dm_entryobj, dm_VendorExtension, dm_VendorExtensionExclude);
|
||||
#endif /* BBF_VENDOR_EXTENSION */
|
||||
|
||||
if (DM_STRLEN(plugin_path) == 0)
|
||||
if (DM_STRLEN(plugin_path) == 0) // If empty, return without further action
|
||||
return 0;
|
||||
|
||||
if (!folder_exists(plugin_path)) {
|
||||
TRACE("(%s) doesn't exist", plugin_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
free_json_plugins();
|
||||
free_specific_dynamic_node(dm_entryobj, INDX_JSON_MOUNT);
|
||||
free_dotso_plugins();
|
||||
free_specific_dynamic_node(dm_entryobj, INDX_LIBRARY_MOUNT);
|
||||
|
||||
sysfs_foreach_file_sorted(plugin_path, max_num_files) {
|
||||
char buf[512] = {0};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue