]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
mesh callbacks review, call error if deleted unfulfilled, check fptr wlist.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 12 Jun 2009 07:53:36 +0000 (07:53 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 12 Jun 2009 07:53:36 +0000 (07:53 +0000)
git-svn-id: file:///svn/unbound/trunk@1652 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/worker.c
doc/Changelog
doc/TODO
libunbound/libworker.c
libunbound/libworker.h
services/mesh.c
services/mesh.h
smallapp/worker_cb.c
util/fptr_wlist.c
util/fptr_wlist.h

index ac50a52a31dd5221771dabdf32a71c7976ee42a0..bb966a0cc8c7b19c15df9ba416f0eaf178814aae 100644 (file)
@@ -1285,6 +1285,18 @@ void libworker_handle_control_cmd(struct tube* ATTR_UNUSED(tube),
        log_assert(0);
 }
 
+void libworker_fg_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode),
+        ldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s))
+{
+       log_assert(0);
+}
+
+void libworker_bg_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode),
+        ldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s))
+{
+       log_assert(0);
+}
+
 int context_query_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
 {
        log_assert(0);
index b805c55e079c54209542092c998d773c2469c0f2..6e5b8dd779a2876d226177224419efd5752d2cdd 100644 (file)
@@ -1,5 +1,7 @@
 12 June 2009: Wouter
        - Fixup potential wrong NSEC picked out of the cache.
+       - If unfulfilled callbacks are deleted they are called with an error.
+       - fptr wlist checks for mesh callbacks.
 
 11 June 2009: Wouter
        - Fix queries for type DS when forward or stub zones are there.
index 8f622aecf21b9d63dc461d2b6542652b9a4addae..aba9d87d492ef381151ddd2b42673d39e0b69d15 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -100,7 +100,6 @@ o infra and lame cache: easier size config (in Mb), show usage in graphs.
 - winevent - poll if too many fds
 - fwd above stub, make hole in fwds. config non-forwarded-domain names.
 - fix indent #  ifs
-- do not flush/delete callback queries or call error on callback at least.
 
 later
 - selective verbosity; ubcontrol trace example.com
index c17dc56e856677269c8ab0317abec6c4623e243a..9f42df2c9bc2fd1445bcb2cb30cc71d5f197de8f 100644 (file)
@@ -458,8 +458,7 @@ libworker_fillup_fg(struct ctx_query* q, int rcode, ldns_buffer* buf,
        libworker_enter_result(q->res, buf, q->w->env->scratch, s);
 }
 
-/** callback with fg results */
-static void
+void
 libworker_fg_done_cb(void* arg, int rcode, ldns_buffer* buf, enum sec_status s)
 {
        struct ctx_query* q = (struct ctx_query*)arg;
@@ -574,8 +573,7 @@ add_bg_result(struct libworker* w, struct ctx_query* q, ldns_buffer* pkt,
        }
 }
 
-/** callback with bg results */
-static void
+void
 libworker_bg_done_cb(void* arg, int rcode, ldns_buffer* buf, enum sec_status s)
 {
        struct ctx_query* q = (struct ctx_query*)arg;
index 224f26775bc4a09e58a229c4387b9e266041bb75..93a6ad7f36d2dbeca36ed0513ffe51393a5562b3 100644 (file)
@@ -156,6 +156,14 @@ void libworker_handle_control_cmd(struct tube* tube, uint8_t* msg, size_t len,
 void libworker_handle_result_write(struct tube* tube, uint8_t* msg, size_t len,
        int err, void* arg);
 
+/** mesh callback with fg results */
+void libworker_fg_done_cb(void* arg, int rcode, ldns_buffer* buf, 
+       enum sec_status s);
+
+/** mesh callback with bg results */
+void libworker_bg_done_cb(void* arg, int rcode, ldns_buffer* buf, 
+       enum sec_status s);
+
 /** 
  * fill result from parsed message, on error fills servfail 
  * @param res: is clear at start, filled in at end.
index b1afec0c4c81b897019ddde851600ba0b95b37c7..f1b372e5f2925304e1df4065165b6dade1258837 100644 (file)
@@ -465,9 +465,15 @@ mesh_state_cleanup(struct mesh_state* mstate)
        /* drop unsent replies */
        if(!mstate->replies_sent) {
                struct mesh_reply* rep;
+               struct mesh_cb* cb;
                for(rep=mstate->reply_list; rep; rep=rep->next) {
                        comm_point_drop_reply(&rep->query_reply);
                }
+               for(cb=mstate->cb_list; cb; cb=cb->next) {
+                       fptr_ok(fptr_whitelist_mesh_cb(cb->cb));
+                       (*cb->cb)(cb->cb_arg, LDNS_RCODE_SERVFAIL, NULL,
+                               sec_status_unchecked);
+               }
        }
 
        /* de-init modules */
@@ -618,6 +624,7 @@ mesh_do_callback(struct mesh_state* m, int rcode, struct reply_info* rep,
                rcode = LDNS_RCODE_SERVFAIL;
        /* send the reply */
        if(rcode) {
+               fptr_ok(fptr_whitelist_mesh_cb(r->cb));
                (*r->cb)(r->cb_arg, rcode, r->buf, sec_status_unchecked);
        } else {
                size_t udp_size = r->edns.udp_size;
@@ -631,11 +638,14 @@ mesh_do_callback(struct mesh_state* m, int rcode, struct reply_info* rep,
                        m->s.env->scratch, udp_size, &r->edns, 
                        (int)(r->edns.bits & EDNS_DO), secure)) 
                {
+                       fptr_ok(fptr_whitelist_mesh_cb(r->cb));
                        (*r->cb)(r->cb_arg, LDNS_RCODE_SERVFAIL, r->buf,
                                sec_status_unchecked);
-               }
-               else    (*r->cb)(r->cb_arg, LDNS_RCODE_NOERROR, r->buf,
+               } else {
+                       fptr_ok(fptr_whitelist_mesh_cb(r->cb));
+                       (*r->cb)(r->cb_arg, LDNS_RCODE_NOERROR, r->buf,
                                rep->security);
+               }
        }
        m->s.env->mesh->num_reply_addrs--;
 }
@@ -780,6 +790,7 @@ int mesh_state_add_cb(struct mesh_state* s, struct edns_data* edns,
        if(!r)
                return 0;
        r->buf = buf;
+       log_assert(fptr_whitelist_mesh_cb(r->cb)); /* early failure ifmissing*/
        r->cb = cb;
        r->cb_arg = cb_arg;
        r->edns = *edns;
index 52ab999821c09da63e8d17b44956bbec543eea09..2e2dca69f5a58629bb4ea3ab539e1d005187461a 100644 (file)
@@ -226,7 +226,7 @@ struct mesh_cb {
        ldns_buffer* buf;
 
        /** callback routine for results. if rcode != 0 buf has message.
-        * called as cb(cb_arg, rcode, buf);
+        * called as cb(cb_arg, rcode, buf, sec_state);
         */
        mesh_cb_func_t cb;
        /** user arg for callback */
index 684f3a9f359d851a2e6a0c3fb1cb85895102933a..f756f9cd47e53d32121a4c3e22121b0b528cb94d 100644 (file)
@@ -42,6 +42,7 @@
  */
 #include "config.h"
 #include "util/log.h"
+#include "services/mesh.h"
 struct comm_reply;
 struct comm_point;
 struct module_qstate;
@@ -180,6 +181,18 @@ void libworker_handle_control_cmd(struct tube* ATTR_UNUSED(tube),
         log_assert(0);
 }
 
+void libworker_fg_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode), 
+       ldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s))
+{
+       log_assert(0);
+}
+
+void libworker_bg_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode), 
+       ldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s))
+{
+       log_assert(0);
+}
+
 int context_query_cmp(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
 {
        log_assert(0);
index 189809b22a4bd3ac080506783ac44feb526464a5..f5e3efa17559f78df064dd8cac3ed13b77bc4504 100644 (file)
@@ -376,3 +376,10 @@ int fptr_whitelist_tube_listen(tube_callback_t* fptr)
        else if(fptr == &libworker_handle_control_cmd) return 1;
        return 0;
 }
+
+int fptr_whitelist_mesh_cb(mesh_cb_func_t fptr)
+{
+       if(fptr == &libworker_fg_done_cb) return 1;
+       else if(fptr == &libworker_bg_done_cb) return 1;
+       return 0;
+}
index 28507b5a291f7aed19569242c021ddb32d185f34..11a0905d0f565a78148b0d5c8f3bc8e2fa4ec9e3 100644 (file)
@@ -58,6 +58,7 @@
 #include "util/storage/lruhash.h"
 #include "util/module.h"
 #include "util/tube.h"
+#include "services/mesh.h"
 
 /**
  * Macro to perform an assertion check for fptr wlist checks.
@@ -307,6 +308,14 @@ int fptr_whitelist_alloc_cleanup(void (*fptr)(void*));
  */
 int fptr_whitelist_tube_listen(tube_callback_t* fptr);
 
+/**
+ * Check function pointer whitelist for mesh state callback values.
+ *
+ * @param fptr: function pointer to check.
+ * @return false if not in whitelist.
+ */
+int fptr_whitelist_mesh_cb(mesh_cb_func_t fptr);
+
 /** Due to module breakage by fptr wlist, these test app declarations
  * are presented here */
 /**