In particular this gets rid of last light user data inside kresd.
It was still causing problems on some systems, for example Debian Sid.
The error was the same: "bad light userdata pointer" from luajit,
but note that the problem can still be triggered by lua libraries,
e.g. cqueues.
'libknot_SONAME',
'libzscanner_SONAME',
'table_print',
- '__engine',
'_ENV',
}
------------
- capabilities are no longer constrained when running as root (!1012)
- cache: add percentage usage to cache.stats() (!1025)
+- aarch64 support again, as some systems still didn't work (!1033)
Bugfixes
--------
#include "kresconfig.h"
#include "daemon/engine.h"
#include "daemon/ffimodule.h"
+#include "daemon/worker.h"
#include "lib/nsrep.h"
#include "lib/cache/api.h"
#include "lib/defines.h"
lua_setglobal(engine->L, "fromjson");
lua_pushcfunction(engine->L, l_map);
lua_setglobal(engine->L, "map");
- lua_pushlightuserdata(engine->L, engine);
- lua_setglobal(engine->L, "__engine");
/* Random number generator */
lua_getfield(engine->L, LUA_GLOBALSINDEX, "math");
lua_getfield(engine->L, -1, "randomseed");
struct engine *engine_luaget(lua_State *L)
{
- lua_getglobal(L, "__engine");
- struct engine *engine = lua_touserdata(L, -1);
- if (!engine) luaL_error(L, "internal error, empty engine pointer");
- lua_pop(L, 1);
- return engine;
+ return the_worker->engine;
}
int engine_register(struct engine *engine, const char *name, const char *precedence, const char* ref);
int engine_unregister(struct engine *engine, const char *name);
-/** Return engine light userdata. */
+/** Return engine light userdata; TODO: remove this function? */
struct engine *engine_luaget(struct lua_State *L);
/** Set/get the per engine hostname */
int worker_resolve_exec(struct qr_task *, knot_pkt_t *);
knot_pkt_t *worker_resolve_mk_pkt(const char *, uint16_t, uint16_t, const struct kr_qflags *);
struct qr_task *worker_resolve_start(knot_pkt_t *, struct kr_qflags);
+struct engine {
+ struct kr_context resolver;
+ char _stub[];
+};
+struct worker_ctx {
+ struct engine *engine;
+ char _stub[];
+};
+struct worker_ctx *the_worker;
typedef struct {
uint8_t bitmap[32];
uint8_t length;
worker_resolve_start
EOF
+echo "struct engine" | ${CDEFS} ${KRESD} types | sed '/struct network/,$ d'
+printf "\tchar _stub[];\n};\n"
+
+echo "struct worker_ctx" | ${CDEFS} ${KRESD} types | sed '/uv_loop_t/,$ d'
+printf "\tchar _stub[];\n};\n"
+
+echo "struct worker_ctx *the_worker;"
+
## libzscanner API for ./zonefile.lua
${CDEFS} libzscanner types <<-EOF
if ret ~= 1 then return nil end
return ffi.string(addr_buf, C.kr_family_len(family))
end,
- context = function () return ffi.cast('struct kr_context *', __engine) end,
+ context = function () return ffi.C.the_worker.engine.resolver end,
knot_pkt_rr = knot_pkt_rr,
}
elseif arg ~= nil then
arg_conv = tostring(arg)
end
- local ret_cstr = cb(__engine, kr_module, arg_conv)
+ local ret_cstr = cb(ffi.C.the_worker.engine, kr_module, arg_conv)
if ret_cstr == nil then
return nil
end
.ctx = mp_new (4096),
.alloc = (knot_mm_alloc_t) mp_alloc
};
- /** Static to work around lua_pushlightuserdata() limitations.
- * TODO: convert to a proper singleton like worker, most likely. */
static struct engine engine;
ret = engine_init(&engine, &pool);
if (ret != 0) {