From: Marek VavruĊĦa Date: Thu, 7 May 2015 08:36:16 +0000 (+0200) Subject: daemon/bindings: report errors in events X-Git-Tag: v1.0.0-beta1~208 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=978d0fdc4f26df8527f94059a474d8ac990fbf2a;p=thirdparty%2Fknot-resolver.git daemon/bindings: report errors in events --- diff --git a/daemon/bindings.c b/daemon/bindings.c index 9f97f0b2f..4a0adab48 100644 --- a/daemon/bindings.c +++ b/daemon/bindings.c @@ -426,10 +426,13 @@ static void event_callback(uv_timer_t *timer) lua_rawgeti(L, LUA_REGISTRYINDEX, (intptr_t) timer->data); lua_rawgeti(L, -1, 1); lua_pushinteger(L, (intptr_t) timer->data); - engine_pcall(L, 1); - - /* Free callback if not recurrent */ - if (uv_timer_get_repeat(timer) == 0) { + int ret = engine_pcall(L, 1); + if (ret != 0) { + fprintf(stderr, "error: %s\n", lua_tostring(L, -1)); + lua_pop(L, 1); + } + /* Free callback if not recurrent or an error */ + if (ret != 0 || uv_timer_get_repeat(timer) == 0) { uv_close((uv_handle_t *)timer, (uv_close_cb) event_free); } }