From 8802509a61bd6eb026811fecf474b207b3f42716 Mon Sep 17 00:00:00 2001 From: PMunch Date: Wed, 20 Nov 2019 15:11:51 +0100 Subject: [PATCH] Fix return code of init to mirror native modules The return code of the init procedure was just set to be 1 in the dynamic library loading module. This ha been rectified and it will now return whatever is returned from the loaded module. --- dynlibmod/dynlibmod.c | 3 +-- dynlibmod/dynlibmod.h | 2 +- dynlibmod/examples/helloworld.c | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dynlibmod/dynlibmod.c b/dynlibmod/dynlibmod.c index 7c77009d7..5a93a7ce5 100644 --- a/dynlibmod/dynlibmod.c +++ b/dynlibmod/dynlibmod.c @@ -132,8 +132,7 @@ int dynlibmod_init(struct module_env* env, int id) { } de->inplace_cb_delete_wrapped = &inplace_cb_delete_wrapped; de->inplace_cb_register_wrapped = &inplace_cb_register_wrapped; - de->func_init(env, id); - return 1; + return de->func_init(env, id); } /** dynlib module deinit */ diff --git a/dynlibmod/dynlibmod.h b/dynlibmod/dynlibmod.h index a8ba23cc9..1097db1e7 100644 --- a/dynlibmod/dynlibmod.h +++ b/dynlibmod/dynlibmod.h @@ -101,7 +101,7 @@ struct cb_pair { * Global state for the module. */ -typedef void (*func_init_t)(struct module_env*, int); +typedef int (*func_init_t)(struct module_env*, int); typedef void (*func_deinit_t)(struct module_env*, int); typedef void (*func_operate_t)(struct module_qstate*, enum module_ev, int, struct outbound_entry*); typedef void (*func_inform_t)(struct module_qstate*, int, struct module_qstate*); diff --git a/dynlibmod/examples/helloworld.c b/dynlibmod/examples/helloworld.c index d001b3ee8..2ec50223e 100644 --- a/dynlibmod/examples/helloworld.c +++ b/dynlibmod/examples/helloworld.c @@ -33,7 +33,7 @@ int reply_callback(struct query_info* qinfo, /* Init is called when the module is first loaded. It should be used to set up * the environment for this module and do any other initialisation required. */ -EXPORT void init(struct module_env* env, int id) { +EXPORT int init(struct module_env* env, int id) { log_info("dynlib: hello world from init"); struct dynlibmod_env* de = (struct dynlibmod_env*) env->modinfo[id]; de->inplace_cb_register_wrapped(&reply_callback, @@ -41,6 +41,7 @@ EXPORT void init(struct module_env* env, int id) { NULL, env, id); struct dynlibmod_env* local_env = env->modinfo[id]; local_env->dyn_env = NULL; + return 1; } /* Deinit is run as the program is shutting down. It should be used to clean up -- 2.47.3