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.
This commit is contained in:
PMunch 2019-11-20 15:11:51 +01:00
parent 5eabc429bc
commit 8802509a61
3 changed files with 4 additions and 4 deletions

View file

@ -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_delete_wrapped = &inplace_cb_delete_wrapped;
de->inplace_cb_register_wrapped = &inplace_cb_register_wrapped; de->inplace_cb_register_wrapped = &inplace_cb_register_wrapped;
de->func_init(env, id); return de->func_init(env, id);
return 1;
} }
/** dynlib module deinit */ /** dynlib module deinit */

View file

@ -101,7 +101,7 @@ struct cb_pair {
* Global state for the module. * 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_deinit_t)(struct module_env*, int);
typedef void (*func_operate_t)(struct module_qstate*, enum module_ev, int, struct outbound_entry*); 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*); typedef void (*func_inform_t)(struct module_qstate*, int, struct module_qstate*);

View file

@ -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 /* 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. */ * 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"); log_info("dynlib: hello world from init");
struct dynlibmod_env* de = (struct dynlibmod_env*) env->modinfo[id]; struct dynlibmod_env* de = (struct dynlibmod_env*) env->modinfo[id];
de->inplace_cb_register_wrapped(&reply_callback, de->inplace_cb_register_wrapped(&reply_callback,
@ -41,6 +41,7 @@ EXPORT void init(struct module_env* env, int id) {
NULL, env, id); NULL, env, id);
struct dynlibmod_env* local_env = env->modinfo[id]; struct dynlibmod_env* local_env = env->modinfo[id];
local_env->dyn_env = NULL; local_env->dyn_env = NULL;
return 1;
} }
/* Deinit is run as the program is shutting down. It should be used to clean up /* Deinit is run as the program is shutting down. It should be used to clean up