]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Answers from the cache work.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 23 Mar 2007 12:41:38 +0000 (12:41 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 23 Mar 2007 12:41:38 +0000 (12:41 +0000)
git-svn-id: file:///svn/unbound/trunk@192 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/daemon.c
daemon/worker.c
doc/Changelog
util/data/msgreply.c
util/data/msgreply.h

index f7c0f1f8010f0c6be7fce791dbeee93d4ba8cfee..53722540d9a01d08333a39949dab0ebf2091abfc 100644 (file)
@@ -119,7 +119,7 @@ daemon_init()
        daemon->need_to_exit = 0;
        daemon->msg_cache = lruhash_create(HASH_DEFAULT_STARTARRAY,
                HASH_DEFAULT_MAXMEM, msgreply_sizefunc, query_info_compare,
-               query_info_delete, reply_info_delete, NULL);
+               query_entry_delete, reply_info_delete, NULL);
        if(!daemon->msg_cache) {
                free(daemon);
                return NULL;
index b7ddfe8e97efa3d023e2eac362a49acfe628e794..593de374550d3c1c3d113a9e8a19ed603bc949cd 100644 (file)
@@ -288,6 +288,7 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
        if((e=lruhash_lookup(worker->daemon->msg_cache, h, &worker->qinfo, 
                0))) {
                /* answer from cache */
+               log_info("answer from the cache");
                query_info_clear(&worker->qinfo);
                /* id is still in the buffer, no need to touch it */
                reply_info_answer((struct reply_info*)e->data, 
index 0e45e54ca1bdcb9089829733a8cd1185098f6d9e..aaa246ed360245a1d16fb0737f7c05ea4fc3692b 100644 (file)
@@ -1,5 +1,7 @@
 23 March 2007: Wouter
        - review of yesterday's commits.
+       - covered up memory leak of the entry locks.
+       - answers from the cache correctly. Copies flags correctly.
 
 22 March 2007: Wouter
        - AIX configure check.
index 53be329ec4b40695c2c12e0c4c5ea88c9881145b..e006c5247eacbd140f8f7cb02a0d277029b64c40 100644 (file)
@@ -140,10 +140,11 @@ size_t msgreply_sizefunc(void* k, void* d)
                + r->replysize + q->qnamesize;
 }
 
-void query_info_delete(void *k, void* ATTR_UNUSED(arg))
+void query_entry_delete(void *k, void* ATTR_UNUSED(arg))
 {
-       struct query_info* q = (struct query_info*)k;
-       query_info_clear(q);
+       struct msgreply_entry* q = (struct msgreply_entry*)k;
+       lock_rw_destroy(&q->entry.lock);
+       query_info_clear(&q->key);
        free(q);
 }
 
@@ -170,7 +171,7 @@ void reply_info_answer(struct reply_info* rep, uint16_t qflags,
        uint16_t flags;
        ldns_buffer_clear(buffer);
        ldns_buffer_skip(buffer, 2); /* ID */
-       flags = ldns_read_uint16(rep->reply+2);
+       flags = ldns_read_uint16(rep->reply);
        flags |= (qflags & 0x0100); /* copy RD bit */
        log_info("flags %x", flags);
        ldns_buffer_write_u16(buffer, flags);
index a524a5d8c3f1741ad458c5868f84121737c71f63..c29474a01e99249bdd63564bf4e185b9514707d2 100644 (file)
@@ -116,8 +116,8 @@ void reply_info_clear(struct reply_info* m);
 /** calculate size of struct query_info + reply_info */
 size_t msgreply_sizefunc(void* k, void* d);
 
-/** delete query_info key structure */
-void query_info_delete(void *q, void* arg);
+/** delete msgreply_entry key structure */
+void query_entry_delete(void *q, void* arg);
 
 /** delete reply_info data structure */
 void reply_info_delete(void* d, void* arg);