]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Fix return code of init to mirror native modules
authorPMunch <peterme@peterme.net>
Wed, 20 Nov 2019 14:11:51 +0000 (15:11 +0100)
committerPMunch <peterme@peterme.net>
Wed, 20 Nov 2019 14:13:57 +0000 (15:13 +0100)
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
dynlibmod/dynlibmod.h
dynlibmod/examples/helloworld.c

index 7c77009d72ff4fea78088099766714c3edc4afdd..5a93a7ce564fdbb23cc3744b8a1a50f4bf163132 100644 (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_register_wrapped = &inplace_cb_register_wrapped;
-    de->func_init(env, id);
-    return 1;
+    return de->func_init(env, id);
 }
 
 /** dynlib module deinit */
index a8ba23cc9af6a3e3bb7d7bab677c3e9678453213..1097db1e73d30d0e4d02f76bf1c9fbf55d20d6b4 100644 (file)
@@ -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*);
index d001b3ee88fafbb88bbe95ddfb5bebb95d4a2c58..2ec50223e2d5e7774f5dc65db29d11d918f98088 100644 (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
  * 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