]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon: resolve callback has request as well
authorMarek Vavrusa <marek@vavrusa.com>
Fri, 22 Jan 2016 07:39:34 +0000 (23:39 -0800)
committerMarek Vavrusa <marek@vavrusa.com>
Fri, 22 Jan 2016 07:39:34 +0000 (23:39 -0800)
the second parameter to resolve() callback function
is request (kres.request_t), so the caller can
look into request stats, timing and zone cut data

daemon/README.rst
daemon/bindings.c

index a93dbd7b71fbfedc171d35472eba1041fee6d3c7..3932ebb7b0372b3ee9116d607a0dd5f20885228e 100644 (file)
@@ -354,7 +354,7 @@ Environment
    :param number qtype: Query type (e.g. ``kres.type.NS``)
    :param number qclass: Query class *(optional)* (e.g. ``kres.class.IN``)
    :param number options: Resolution options (see query flags)
-   :param function callback: Callback to be executed when resolution completes (e.g. `function cb (pkt) end`). The callback gets a packet containing the final answer and doesn't have to return anything.
+   :param function callback: Callback to be executed when resolution completes (e.g. `function cb (pkt, req) end`). The callback gets a packet containing the final answer and doesn't have to return anything.
    :return: boolean
 
    Example:
@@ -366,7 +366,7 @@ Environment
 
       -- Query for AAAA record
       resolve('example.com', kres.type.AAAA, kres.class.IN, 0,
-      function (answer)
+      function (answer, req)
          -- Check answer RCODE
          local pkt = kres.pkt_t(answer)
          if pkt:rcode() == kres.rcode.NOERROR then
index 0c62422c372bbae4fcff31d4fbd9fa0fca5c5237..3b07a0a392ea2831039ac5cadbe2bb628598bfa3 100644 (file)
@@ -617,7 +617,8 @@ static void resolve_callback(struct worker_ctx *worker, struct kr_request *req,
        lua_rawgeti(L, LUA_REGISTRYINDEX, cb_ref);
        luaL_unref(L, LUA_REGISTRYINDEX, cb_ref);
        lua_pushlightuserdata(L, req->answer);
-       (void) execute_callback(L, 1);
+       lua_pushlightuserdata(L, req);
+       (void) execute_callback(L, 2);
 }
 
 static int wrk_resolve(lua_State *L)