]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon: all Lua bindings return
authorMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 8 Apr 2015 15:45:30 +0000 (17:45 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 8 Apr 2015 15:45:30 +0000 (17:45 +0200)
daemon/bindings.c
modules/cachectl/cachectl.c

index cbb181837053f11d9240d3caa644fb626ae9a158..7eebee38ab270a8043270c8b63022db082cf7f26 100644 (file)
 static int mod_list(lua_State *L)
 {
        struct engine *engine = engine_luaget(L);
+       lua_newtable(L);
        for (unsigned i = 0; i < engine->modules.len; ++i) {
                struct kr_module *module = &engine->modules.at[i];
                lua_pushstring(L, module->name);
+               lua_rawseti(L, -2, i + 1);
        }
-       return engine->modules.len;
+       return 1;
 }
 
 /** Load module. */
@@ -57,7 +59,9 @@ static int mod_load(lua_State *L)
                lua_pushstring(L, kr_strerror(ret));
                lua_error(L);
        }
-       return 0;
+
+       lua_pushboolean(L, 1);
+       return 1;
 }
 
 /** Unload module. */
@@ -76,7 +80,9 @@ static int mod_unload(lua_State *L)
                lua_pushstring(L, kr_strerror(ret));
                lua_error(L);
        }
-       return 0;
+
+       lua_pushboolean(L, 1);
+       return 1;
 }
 
 int lib_modules(lua_State *L)
@@ -253,7 +259,8 @@ static int cache_close(lua_State *L)
                engine->resolver.cache = NULL;
        }
 
-       return 0;
+       lua_pushboolean(L, 1);
+       return 1;
 }
 
 int lib_cache(lua_State *L)
index 1fb323c6b6a9526a6d9afc6d87533a6bb10beb91..97041da3a7c5f38992d449ee55632c1d692a8839 100644 (file)
@@ -54,6 +54,8 @@ static char* get_size(void *env, struct kr_module *module, const char *args)
        if (ret == 0) {
                asprintf(&result, "{ \"size\": %d }", storage->count(&txn));
                kr_cache_txn_abort(&txn);
+       } else {
+               asprintf(&result, "{ \"error\": \"%s\" }", knot_strerror(ret));
        }
        
        return result;