]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
fix to please gcc 8 and lint.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 3 May 2018 14:29:15 +0000 (14:29 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 3 May 2018 14:29:15 +0000 (14:29 +0000)
git-svn-id: file:///svn/unbound/trunk@4678 be551aaa-1e26-0410-a405-d3ace91eadb9

libunbound/context.c
libunbound/context.h
libunbound/libunbound.c
libunbound/libworker.c

index 9dddb9d3cd25c6ed98c21d6fc8a45504864cf8da..95e6a8e7fbe622693e6080b35fc594d4c20413bf 100644 (file)
@@ -130,7 +130,7 @@ find_id(struct ub_ctx* ctx, int* id)
 
 struct ctx_query* 
 context_new(struct ub_ctx* ctx, const char* name, int rrtype, int rrclass, 
-       void* cb, void* cbarg)
+       ub_callback_type cb, ub_event_callback_type cb_event, void* cbarg)
 {
        struct ctx_query* q = (struct ctx_query*)calloc(1, sizeof(*q));
        if(!q) return NULL;
@@ -142,8 +142,9 @@ context_new(struct ub_ctx* ctx, const char* name, int rrtype, int rrclass,
        }
        lock_basic_unlock(&ctx->cfglock);
        q->node.key = &q->querynum;
-       q->async = (cb != NULL);
+       q->async = (cb != NULL && cb_event != NULL);
        q->cb = cb;
+       q->cb_event = cb_event;
        q->cb_arg = cbarg;
        q->res = (struct ub_result*)calloc(1, sizeof(*q->res));
        if(!q->res) {
index 5375f0423e711825cae03910190c3bdb4647e467..11147226a8cc687cc84b9f46a55d7e023f3b325b 100644 (file)
@@ -45,6 +45,7 @@
 #include "util/rbtree.h"
 #include "services/modstack.h"
 #include "libunbound/unbound.h"
+#include "libunbound/unbound-event.h"
 #include "util/data/packed_rrset.h"
 struct libworker;
 struct tube;
@@ -148,9 +149,10 @@ struct ctx_query {
        /** was this query cancelled (for bg worker) */
        int cancelled;
 
-       /** for async query, the callback function of type ub_callback_type
-        * for event callbacks the type is ub_event_callback_type */
-       void* cb;
+       /** for async query, the callback function of type ub_callback_type */
+       ub_callback_type cb;
+       /** for event callbacks the type is ub_event_callback_type */
+        ub_event_callback_type cb_event;
        /** for async query, the callback user arg */
        void* cb_arg;
 
@@ -239,11 +241,13 @@ void context_query_delete(struct ctx_query* q);
  * @param rrtype: type
  * @param rrclass: class
  * @param cb: callback for async, or NULL for sync.
+ * @param cb_event: event callback for async, or NULL for sync.
  * @param cbarg: user arg for async queries.
  * @return new ctx_query or NULL for malloc failure.
  */
 struct ctx_query* context_new(struct ub_ctx* ctx, const char* name, int rrtype,
-        int rrclass, void* cb, void* cbarg);
+        int rrclass,  ub_callback_type cb, ub_event_callback_type cb_event,
+       void* cbarg);
 
 /**
  * Get a new alloc. Creates a new one or uses a cached one.
index 729b32e33cad8068362ecf8e69e2743c90782c8e..275e8d25a1686bc31b5a61b0fdec053ea1f5297e 100644 (file)
@@ -537,7 +537,7 @@ process_answer_detail(struct ub_ctx* ctx, uint8_t* msg, uint32_t len,
                *cb = NULL;
                *cbarg = NULL;
        } else {
-               *cb = (ub_callback_type)q->cb;
+               *cb = q->cb;
                *cbarg = q->cb_arg;
        }
        if(*err) {
@@ -690,7 +690,7 @@ ub_resolve(struct ub_ctx* ctx, const char* name, int rrtype,
        }
        /* create new ctx_query and attempt to add to the list */
        lock_basic_unlock(&ctx->cfglock);
-       q = context_new(ctx, name, rrtype, rrclass, NULL, NULL);
+       q = context_new(ctx, name, rrtype, rrclass, NULL, NULL, NULL);
        if(!q)
                return UB_NOMEM;
        /* become a resolver thread for a bit */
@@ -747,7 +747,7 @@ ub_resolve_event(struct ub_ctx* ctx, const char* name, int rrtype,
        ub_comm_base_now(ctx->event_worker->base);
 
        /* create new ctx_query and attempt to add to the list */
-       q = context_new(ctx, name, rrtype, rrclass, callback, mydata);
+       q = context_new(ctx, name, rrtype, rrclass, NULL, callback, mydata);
        if(!q)
                return UB_NOMEM;
 
@@ -792,7 +792,7 @@ ub_resolve_async(struct ub_ctx* ctx, const char* name, int rrtype,
        }
 
        /* create new ctx_query and attempt to add to the list */
-       q = context_new(ctx, name, rrtype, rrclass, callback, mydata);
+       q = context_new(ctx, name, rrtype, rrclass, callback, NULL, mydata);
        if(!q)
                return UB_NOMEM;
 
index 4380d69caa6cd20ba153b2480db5fbeb6a15e38c..aef1178697f9253392d31a37ab8bc498396149d8 100644 (file)
@@ -637,7 +637,7 @@ libworker_event_done_cb(void* arg, int rcode, sldns_buffer* buf,
        enum sec_status s, char* why_bogus)
 {
        struct ctx_query* q = (struct ctx_query*)arg;
-       ub_event_callback_type cb = (ub_event_callback_type)q->cb;
+       ub_event_callback_type cb = q->cb_event;
        void* cb_arg = q->cb_arg;
        int cancelled = q->cancelled;