]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- For #391: use struct timeval* start_time for callback information.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 8 Jan 2021 08:47:46 +0000 (09:47 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 8 Jan 2021 08:47:46 +0000 (09:47 +0100)
13 files changed:
daemon/worker.c
doc/Changelog
dynlibmod/dynlibmod.c
dynlibmod/dynlibmod.h
dynlibmod/examples/helloworld.c
pythonmod/interface.i
pythonmod/pythonmod.h
services/authzone.c
services/localzone.c
services/mesh.c
util/data/msgreply.c
util/data/msgreply.h
util/module.h

index edf96988a3067926c10a377bacd6a9db75465c54..33b70e83e68e5250d9ebeb4d911c47d78032e743 100644 (file)
@@ -514,7 +514,7 @@ answer_norec_from_cache(struct worker* worker, struct query_info* qinfo,
                        edns->bits &= EDNS_DO;
                        if(!inplace_cb_reply_servfail_call(&worker->env, qinfo, NULL,
                                msg->rep, LDNS_RCODE_SERVFAIL, edns, repinfo, worker->scratchpad,
-                               *worker->env.now_tv))
+                               worker->env.now_tv))
                                        return 0;
                        error_encode(repinfo->c->buffer, LDNS_RCODE_SERVFAIL, 
                                &msg->qinfo, id, flags, edns);
@@ -546,7 +546,7 @@ answer_norec_from_cache(struct worker* worker, struct query_info* qinfo,
        edns->bits &= EDNS_DO;
        if(!inplace_cb_reply_cache_call(&worker->env, qinfo, NULL, msg->rep,
                (int)(flags&LDNS_RCODE_MASK), edns, repinfo, worker->scratchpad,
-        *worker->env.now_tv))
+        worker->env.now_tv))
                        return 0;
        msg->rep->flags |= BIT_QR|BIT_RA;
        if(!apply_edns_options(edns, &edns_bak, worker->env.cfg,
@@ -556,7 +556,7 @@ answer_norec_from_cache(struct worker* worker, struct query_info* qinfo,
                udpsize, edns, (int)(edns->bits & EDNS_DO), secure)) {
                if(!inplace_cb_reply_servfail_call(&worker->env, qinfo, NULL, NULL,
                        LDNS_RCODE_SERVFAIL, edns, repinfo, worker->scratchpad,
-                       *worker->env.now_tv))
+                       worker->env.now_tv))
                                edns->opt_list = NULL;
                error_encode(repinfo->c->buffer, LDNS_RCODE_SERVFAIL, 
                        &msg->qinfo, id, flags, edns);
@@ -688,7 +688,7 @@ answer_from_cache(struct worker* worker, struct query_info* qinfo,
                edns->bits &= EDNS_DO;
                if(!inplace_cb_reply_servfail_call(&worker->env, qinfo, NULL, rep,
                        LDNS_RCODE_SERVFAIL, edns, repinfo, worker->scratchpad,
-           *worker->env.now_tv))
+           worker->env.now_tv))
                        goto bail_out;
                error_encode(repinfo->c->buffer, LDNS_RCODE_SERVFAIL,
                        qinfo, id, flags, edns);
@@ -723,7 +723,7 @@ answer_from_cache(struct worker* worker, struct query_info* qinfo,
        edns->bits &= EDNS_DO;
        if(!inplace_cb_reply_cache_call(&worker->env, qinfo, NULL, rep,
                (int)(flags&LDNS_RCODE_MASK), edns, repinfo, worker->scratchpad,
-               *worker->env.now_tv))
+               worker->env.now_tv))
                goto bail_out;
        *alias_rrset = NULL; /* avoid confusion if caller set it to non-NULL */
        if((worker->daemon->use_response_ip || worker->daemon->use_rpz) &&
@@ -760,7 +760,7 @@ answer_from_cache(struct worker* worker, struct query_info* qinfo,
                udpsize, edns, (int)(edns->bits & EDNS_DO), *is_secure_answer)) {
                if(!inplace_cb_reply_servfail_call(&worker->env, qinfo, NULL, NULL,
                        LDNS_RCODE_SERVFAIL, edns, repinfo, worker->scratchpad,
-           *worker->env.now_tv))
+           worker->env.now_tv))
                                edns->opt_list = NULL;
                error_encode(repinfo->c->buffer, LDNS_RCODE_SERVFAIL, 
                        qinfo, id, flags, edns);
@@ -849,7 +849,7 @@ chaos_replystr(sldns_buffer* pkt, char** str, int num, struct edns_data* edns,
        edns->bits &= EDNS_DO;
        if(!inplace_cb_reply_local_call(&worker->env, NULL, NULL, NULL,
                LDNS_RCODE_NOERROR, edns, repinfo, worker->scratchpad,
-        *worker->env.now_tv))
+        worker->env.now_tv))
                        edns->opt_list = NULL;
        if(sldns_buffer_capacity(pkt) >=
                sldns_buffer_limit(pkt)+calc_edns_field_size(edns))
index fa91a09bbfac2d7473010b200a33596c5a2fb422..e8da85d6ae76df739ed5c497e415b1f67fbf2458 100644 (file)
@@ -1,6 +1,7 @@
 8 January 2021: Wouter
        - Merge PR #391 from fhriley: Add start_time to reply callbacks so
          modules can compute the response time.
+       - For #391: use struct timeval* start_time for callback information.
 
 6 January 2021: Wouter
        - Fix #379: zone loading over HTTP appears to have buffer issues.
index e842c9d8a2d1b8ad7a04736fc40ebb0637a78a1a..ffac7ff306a5a6474c2c673720fb7a99f284e7bf 100644 (file)
@@ -213,7 +213,7 @@ int dynlib_inplace_cb_reply_generic(struct query_info* qinfo,
     struct module_qstate* qstate, struct reply_info* rep, int rcode,
     struct edns_data* edns, struct edns_option** opt_list_out,
     struct comm_reply* repinfo, struct regional* region,
-    struct timeval start_time, int id, void* callback) {
+    struct timeval* start_time, int id, void* callback) {
     struct cb_pair* cb_pair = (struct cb_pair*) callback;
     return ((inplace_cb_reply_func_type*) cb_pair->cb)(qinfo, qstate, rep, rcode, edns, opt_list_out, repinfo, region, start_time, id, cb_pair->cb_arg);
 }
index f35dafa1a1d1fb466b931968879d8f1a2f700448..321f4f6936f0c80b067b01fad5807c29f6d6b71c 100644 (file)
@@ -71,7 +71,7 @@ int dynlib_inplace_cb_reply_generic(struct query_info* qinfo,
     struct module_qstate* qstate, struct reply_info* rep, int rcode,
     struct edns_data* edns, struct edns_option** opt_list_out,
     struct comm_reply* repinfo, struct regional* region,
-       struct timeval start_time, int id, void* callback);
+       struct timeval* start_time, int id, void* callback);
 
 int dynlib_inplace_cb_query_generic(struct query_info* qinfo, uint16_t flags,
     struct module_qstate* qstate, struct sockaddr_storage* addr,
index 5ea9c51bea6e7204181d936b12e344136e285113..7da32d9bbeba07ad89305a01b0112a4b3d240070 100644 (file)
@@ -31,7 +31,7 @@ int reply_callback(struct query_info* qinfo,
     struct module_qstate* qstate, struct reply_info* rep, int rcode,
     struct edns_data* edns, struct edns_option** opt_list_out,
     struct comm_reply* repinfo, struct regional* region,
-    struct timeval start_time, int id, void* callback);
+    struct timeval* start_time, int id, void* callback);
 
 /* Init is called when the module is first loaded. It should be used to set up
  * the environment for this module and do any other initialisation required. */
@@ -117,7 +117,7 @@ int reply_callback(struct query_info* qinfo,
     struct module_qstate* qstate, struct reply_info* rep, int rcode,
     struct edns_data* edns, struct edns_option** opt_list_out,
     struct comm_reply* repinfo, struct regional* region,
-    struct timeval start_time, int id, void* callback) {
+    struct timeval* start_time, int id, void* callback) {
     log_info("dynlib: hello world from callback");
     struct dynlibmod_env* env = qstate->env->modinfo[id];
     if (env->dyn_env != NULL) {
index 8f44e52b6631f3569c8d60e1d7ef3f13a3e38f36..6e629fa70a3b607371703d964193ee3c26351165 100644 (file)
@@ -1542,13 +1542,13 @@ int edns_opt_list_append(struct edns_option** list, uint16_t code, size_t len,
         struct module_qstate* qstate, struct reply_info* rep, int rcode,
         struct edns_data* edns, struct edns_option** opt_list_out,
         struct comm_reply* repinfo, struct regional* region,
-        struct timeval start_time, int id, void* python_callback)
+        struct timeval* start_time, int id, void* python_callback)
     {
         PyObject *func, *py_edns, *py_qstate, *py_opt_list_out, *py_qinfo;
         PyObject *py_rep, *py_repinfo, *py_region;
         PyObject *py_args, *py_kwargs, *result;
         int res = 0;
-        double py_start_time = start_time.tv_sec + start_time.tv_usec / 1e6;
+        double py_start_time = start_time->tv_sec + start_time->tv_usec / 1e6;
 
         PyGILState_STATE gstate = PyGILState_Ensure();
         func = (PyObject *) python_callback;
index 222ebd71e6616d5899b3a633d8488ed84858db5c..f5ae9ca56bcde929bcd49e7cc3737cb17d19df2b 100644 (file)
@@ -73,7 +73,7 @@ int python_inplace_cb_reply_generic(struct query_info* qinfo,
        struct module_qstate* qstate, struct reply_info* rep, int rcode,
        struct edns_data* edns, struct edns_option** opt_list_out,
        struct comm_reply* repinfo, struct regional* region,
-    struct timeval start_time, int id, void* python_callback);
+    struct timeval* start_time, int id, void* python_callback);
 
 /** Declared here for fptr_wlist access. The definition is in interface.i. */
 int python_inplace_cb_query_generic(
index 0f6d691a26241704ede4cea22243b7d305aa924f..3ad38865e35d13d53aba30c791024e6dcc59f815 100644 (file)
@@ -3286,7 +3286,7 @@ auth_answer_encode(struct query_info* qinfo, struct module_env* env,
        edns->bits &= EDNS_DO;
 
        if(!inplace_cb_reply_local_call(env, qinfo, NULL, msg->rep,
-               (int)FLAGS_GET_RCODE(msg->rep->flags), edns, repinfo, temp, *env->now_tv)
+               (int)FLAGS_GET_RCODE(msg->rep->flags), edns, repinfo, temp, env->now_tv)
                || !reply_info_answer_encode(qinfo, msg->rep,
                *(uint16_t*)sldns_buffer_begin(buf),
                sldns_buffer_read_u16_at(buf, 2),
@@ -3310,7 +3310,7 @@ auth_error_encode(struct query_info* qinfo, struct module_env* env,
        edns->bits &= EDNS_DO;
 
        if(!inplace_cb_reply_local_call(env, qinfo, NULL, NULL,
-               rcode, edns, repinfo, temp, *env->now_tv))
+               rcode, edns, repinfo, temp, env->now_tv))
                edns->opt_list = NULL;
        error_encode(buf, rcode|BIT_AA, qinfo,
                *(uint16_t*)sldns_buffer_begin(buf),
index 308150a00b3593219dfa3fa164aaff95d9a23749..c7ae95888b3ce31ffaae68e72eae955c812fd3e4 100644 (file)
@@ -1215,7 +1215,7 @@ local_encode(struct query_info* qinfo, struct module_env* env,
        edns->ext_rcode = 0;
        edns->bits &= EDNS_DO;
        if(!inplace_cb_reply_local_call(env, qinfo, NULL, &rep, rcode, edns,
-               repinfo, temp, *env->now_tv) || !reply_info_answer_encode(qinfo, &rep,
+               repinfo, temp, env->now_tv) || !reply_info_answer_encode(qinfo, &rep,
                *(uint16_t*)sldns_buffer_begin(buf), sldns_buffer_read_u16_at(buf, 2),
                buf, 0, 0, temp, udpsize, edns, (int)(edns->bits&EDNS_DO), 0)) {
                error_encode(buf, (LDNS_RCODE_SERVFAIL|BIT_AA), qinfo,
@@ -1237,7 +1237,7 @@ local_error_encode(struct query_info* qinfo, struct module_env* env,
        edns->bits &= EDNS_DO;
 
        if(!inplace_cb_reply_local_call(env, qinfo, NULL, NULL,
-               rcode, edns, repinfo, temp, *env->now_tv))
+               rcode, edns, repinfo, temp, env->now_tv))
                edns->opt_list = NULL;
        error_encode(buf, r, qinfo, *(uint16_t*)sldns_buffer_begin(buf),
                sldns_buffer_read_u16_at(buf, 2), edns);
index de481c0d5e5bdbded6eeef342e6993ae42035789..4c806dc4b2181cf07b50486f880a954a1757412f 100644 (file)
@@ -498,7 +498,7 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo,
                if(!s) {
                        log_err("mesh_state_create: out of memory; SERVFAIL");
                        if(!inplace_cb_reply_servfail_call(mesh->env, qinfo, NULL, NULL,
-                               LDNS_RCODE_SERVFAIL, edns, rep, mesh->env->scratch, *s->s.env->now_tv))
+                               LDNS_RCODE_SERVFAIL, edns, rep, mesh->env->scratch, s->s.env->now_tv))
                                        edns->opt_list = NULL;
                        error_encode(r_buffer, LDNS_RCODE_SERVFAIL,
                                qinfo, qid, qflags, edns);
@@ -514,7 +514,7 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo,
                        if(!s->s.edns_opts_front_in) {
                                log_err("mesh_state_create: out of memory; SERVFAIL");
                                if(!inplace_cb_reply_servfail_call(mesh->env, qinfo, NULL,
-                                       NULL, LDNS_RCODE_SERVFAIL, edns, rep, mesh->env->scratch, *s->s.env->now_tv))
+                                       NULL, LDNS_RCODE_SERVFAIL, edns, rep, mesh->env->scratch, s->s.env->now_tv))
                                                edns->opt_list = NULL;
                                error_encode(r_buffer, LDNS_RCODE_SERVFAIL,
                                        qinfo, qid, qflags, edns);
@@ -587,7 +587,7 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo,
 
 servfail_mem:
        if(!inplace_cb_reply_servfail_call(mesh->env, qinfo, &s->s,
-               NULL, LDNS_RCODE_SERVFAIL, edns, rep, mesh->env->scratch, *s->s.env->now_tv))
+               NULL, LDNS_RCODE_SERVFAIL, edns, rep, mesh->env->scratch, s->s.env->now_tv))
                        edns->opt_list = NULL;
        error_encode(r_buffer, LDNS_RCODE_SERVFAIL,
                qinfo, qid, qflags, edns);
@@ -1115,7 +1115,7 @@ int mesh_state_attachment(struct mesh_state* super, struct mesh_state* sub)
  */
 static void
 mesh_do_callback(struct mesh_state* m, int rcode, struct reply_info* rep,
-       struct mesh_cb* r, struct timeval start_time)
+       struct mesh_cb* r, struct timeval* start_time)
 {
        int secure;
        char* reason = NULL;
@@ -1256,11 +1256,11 @@ mesh_send_reply(struct mesh_state* m, int rcode, struct reply_info* rep,
                m->s.qinfo.local_alias = r->local_alias;
                if(rcode == LDNS_RCODE_SERVFAIL) {
                        if(!inplace_cb_reply_servfail_call(m->s.env, &m->s.qinfo, &m->s,
-                               rep, rcode, &r->edns, &r->query_reply, m->s.region, r->start_time))
+                               rep, rcode, &r->edns, &r->query_reply, m->s.region, &r->start_time))
                                        r->edns.opt_list = NULL;
                } else { 
                        if(!inplace_cb_reply_call(m->s.env, &m->s.qinfo, &m->s, rep, rcode,
-                               &r->edns, &r->query_reply, m->s.region, r->start_time))
+                               &r->edns, &r->query_reply, m->s.region, &r->start_time))
                                        r->edns.opt_list = NULL;
                }
                error_encode(r_buffer, rcode, &m->s.qinfo, r->qid,
@@ -1277,7 +1277,7 @@ mesh_send_reply(struct mesh_state* m, int rcode, struct reply_info* rep,
                m->s.qinfo.qname = r->qname;
                m->s.qinfo.local_alias = r->local_alias;
                if(!inplace_cb_reply_call(m->s.env, &m->s.qinfo, &m->s, rep,
-                       LDNS_RCODE_NOERROR, &r->edns, &r->query_reply, m->s.region, r->start_time) ||
+                       LDNS_RCODE_NOERROR, &r->edns, &r->query_reply, m->s.region, &r->start_time) ||
                        !apply_edns_options(&r->edns, &edns_bak,
                                m->s.env->cfg, r->query_reply.c,
                                m->s.region) ||
@@ -1287,7 +1287,7 @@ mesh_send_reply(struct mesh_state* m, int rcode, struct reply_info* rep,
                        secure)) 
                {
                        if(!inplace_cb_reply_servfail_call(m->s.env, &m->s.qinfo, &m->s,
-                       rep, LDNS_RCODE_SERVFAIL, &r->edns, &r->query_reply, m->s.region, r->start_time))
+                       rep, LDNS_RCODE_SERVFAIL, &r->edns, &r->query_reply, m->s.region, &r->start_time))
                                r->edns.opt_list = NULL;
                        error_encode(r_buffer, LDNS_RCODE_SERVFAIL,
                                &m->s.qinfo, r->qid, r->qflags, &r->edns);
@@ -1424,7 +1424,7 @@ void mesh_query_done(struct mesh_state* mstate)
                if(!mstate->reply_list && !mstate->cb_list &&
                        mstate->super_set.count == 0)
                        mstate->s.env->mesh->num_detached_states++;
-               mesh_do_callback(mstate, mstate->s.return_rcode, rep, c, tv);
+               mesh_do_callback(mstate, mstate->s.return_rcode, rep, c, &tv);
        }
 }
 
@@ -2048,6 +2048,6 @@ mesh_serve_expired_callback(void* arg)
                if(!mstate->reply_list && !mstate->cb_list &&
                        mstate->super_set.count == 0)
                        qstate->env->mesh->num_detached_states++;
-               mesh_do_callback(mstate, LDNS_RCODE_NOERROR, msg->rep, c, tv);
+               mesh_do_callback(mstate, LDNS_RCODE_NOERROR, msg->rep, c, &tv);
        }
 }
index 3f7eb5fc9af1ada4b9a53264aa6aa3323e954246..a48cb78f1218cee67d883401951a8694832ce35d 100644 (file)
@@ -1036,7 +1036,7 @@ static int inplace_cb_reply_call_generic(
        struct query_info* qinfo, struct module_qstate* qstate,
        struct reply_info* rep, int rcode, struct edns_data* edns,
        struct comm_reply* repinfo, struct regional* region,
-    struct timeval start_time)
+    struct timeval* start_time)
 {
        struct inplace_cb* cb;
        struct edns_option* opt_list_out = NULL;
@@ -1058,7 +1058,7 @@ static int inplace_cb_reply_call_generic(
 int inplace_cb_reply_call(struct module_env* env, struct query_info* qinfo,
        struct module_qstate* qstate, struct reply_info* rep, int rcode,
        struct edns_data* edns, struct comm_reply* repinfo, struct regional* region,
-    struct timeval start_time)
+    struct timeval* start_time)
 {
        return inplace_cb_reply_call_generic(
                env->inplace_cb_lists[inplace_cb_reply], inplace_cb_reply, qinfo,
@@ -1069,7 +1069,7 @@ int inplace_cb_reply_cache_call(struct module_env* env,
        struct query_info* qinfo, struct module_qstate* qstate,
        struct reply_info* rep, int rcode, struct edns_data* edns,
        struct comm_reply* repinfo, struct regional* region,
-    struct timeval start_time)
+    struct timeval* start_time)
 {
        return inplace_cb_reply_call_generic(
                env->inplace_cb_lists[inplace_cb_reply_cache], inplace_cb_reply_cache,
@@ -1080,7 +1080,7 @@ int inplace_cb_reply_local_call(struct module_env* env,
        struct query_info* qinfo, struct module_qstate* qstate,
        struct reply_info* rep, int rcode, struct edns_data* edns,
        struct comm_reply* repinfo, struct regional* region,
-    struct timeval start_time)
+    struct timeval* start_time)
 {
        return inplace_cb_reply_call_generic(
                env->inplace_cb_lists[inplace_cb_reply_local], inplace_cb_reply_local,
@@ -1091,7 +1091,7 @@ int inplace_cb_reply_servfail_call(struct module_env* env,
        struct query_info* qinfo, struct module_qstate* qstate,
        struct reply_info* rep, int rcode, struct edns_data* edns,
        struct comm_reply* repinfo, struct regional* region,
-    struct timeval start_time)
+    struct timeval* start_time)
 {
        /* We are going to servfail. Remove any potential edns options. */
        if(qstate)
index b7706b023a0e73cb7e753f26359c7b6d19ef0046..32466644f61461722f5c94ba174904c28bd336ee 100644 (file)
@@ -559,7 +559,7 @@ struct edns_option* edns_opt_list_find(struct edns_option* list, uint16_t code);
 int inplace_cb_reply_call(struct module_env* env, struct query_info* qinfo,
        struct module_qstate* qstate, struct reply_info* rep, int rcode,
        struct edns_data* edns, struct comm_reply* repinfo, struct regional* region,
-    struct timeval start_time);
+    struct timeval* start_time);
 
 /**
  * Call the registered functions in the inplace_cb_reply_cache linked list.
@@ -578,7 +578,7 @@ int inplace_cb_reply_cache_call(struct module_env* env,
        struct query_info* qinfo, struct module_qstate* qstate,
        struct reply_info* rep, int rcode, struct edns_data* edns,
        struct comm_reply* repinfo, struct regional* region,
-    struct timeval start_time);
+    struct timeval* start_time);
 
 /**
  * Call the registered functions in the inplace_cb_reply_local linked list.
@@ -597,7 +597,7 @@ int inplace_cb_reply_local_call(struct module_env* env,
        struct query_info* qinfo, struct module_qstate* qstate,
        struct reply_info* rep, int rcode, struct edns_data* edns,
        struct comm_reply* repinfo, struct regional* region,
-    struct timeval start_time);
+    struct timeval* start_time);
 
 /**
  * Call the registered functions in the inplace_cb_reply linked list.
@@ -617,7 +617,7 @@ int inplace_cb_reply_servfail_call(struct module_env* env,
        struct query_info* qinfo, struct module_qstate* qstate,
        struct reply_info* rep, int rcode, struct edns_data* edns,
        struct comm_reply* repinfo, struct regional* region,
-    struct timeval start_time);
+    struct timeval* start_time);
 
 /**
  * Call the registered functions in the inplace_cb_query linked list.
index d29b6f31845412b9dbb92adcd60d112b9b35901c..9267b49e88f2b27fd155dea01df4dee990b281c2 100644 (file)
@@ -258,7 +258,7 @@ typedef int inplace_cb_reply_func_type(struct query_info* qinfo,
        struct module_qstate* qstate, struct reply_info* rep, int rcode,
        struct edns_data* edns, struct edns_option** opt_list_out,
        struct comm_reply* repinfo, struct regional* region,
-    struct timeval start_time, int id, void* callback);
+    struct timeval* start_time, int id, void* callback);
 
 /**
  * Inplace callback function called before sending the query to a nameserver.