]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/engine: unload module if loaded
authorMarek Vavruša <marek.vavrusa@nic.cz>
Thu, 23 Apr 2015 12:33:00 +0000 (14:33 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Thu, 23 Apr 2015 12:33:00 +0000 (14:33 +0200)
daemon/engine.c

index 10ed169d0333a6f716f4132c80c49c3ed3ce59cb..f5a48f0aafcdcb3318b22131d620fa1c900f435a 100644 (file)
@@ -289,6 +289,9 @@ int engine_register(struct engine *engine, const char *name)
                return kr_error(EINVAL);
        }
 
+       /* Make sure module is unloaded */
+       (void) engine_unregister(engine, name);
+
        /* Load module */
        size_t next = engine->modules.len;
        array_reserve(engine->modules, next + 1);
@@ -324,6 +327,8 @@ int engine_unregister(struct engine *engine, const char *name)
        if (found < mod_list->len) {
                kr_module_unload(&mod_list->at[found]);
                array_del(*mod_list, found);
+               lua_pushnil(engine->L);
+               lua_setglobal(engine->L, name);
                return kr_ok();
        }