From: Marek VavruĊĦa Date: Wed, 8 Apr 2015 15:45:30 +0000 (+0200) Subject: daemon: all Lua bindings return X-Git-Tag: v1.0.0-beta1~265^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a16eceb8b7c46f86b5ea1a05499690ca21da408;p=thirdparty%2Fknot-resolver.git daemon: all Lua bindings return --- diff --git a/daemon/bindings.c b/daemon/bindings.c index cbb181837..7eebee38a 100644 --- a/daemon/bindings.c +++ b/daemon/bindings.c @@ -34,11 +34,13 @@ 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) diff --git a/modules/cachectl/cachectl.c b/modules/cachectl/cachectl.c index 1fb323c6b..97041da3a 100644 --- a/modules/cachectl/cachectl.c +++ b/modules/cachectl/cachectl.c @@ -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;