]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Fixes.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 22 May 2007 15:02:39 +0000 (15:02 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 22 May 2007 15:02:39 +0000 (15:02 +0000)
git-svn-id: file:///svn/unbound/trunk@330 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
services/cache/infra.c
testcode/unitlruhash.c
testcode/unitslabhash.c
testdata/fwd_three.tpkg
testdata/fwd_three_service.tpkg
util/data/msgreply.c
util/data/packed_rrset.c
util/mini_event.c

index d9c37c8b3138e718b33c4acd0c5941254c07764d..53b8af6a50337d092fbf74043ec034aae7919e11 100644 (file)
@@ -4,6 +4,9 @@
        - testbound support for new serviced queries.
        - test for retry to TCP cannot use testbound any longer.
        - testns test for EDNS fallback, test for TCP fallback already exists.
+       - fixes for no-locking compile.
+       - mini_event timer precision and fix for change in timeouts during
+         timeout callback. Fix for fwd_three tests, performed nonexit query.
 
 21 May 2007: Wouter
        - small comment on hash table locking.
index fbc0d050236d9b75a6a73183958795bd2fc0c6cb..5e9c861bc070053a8d0ea07b72088ed5cbf97cbe 100644 (file)
@@ -75,7 +75,7 @@ infra_host_delkeyfunc(void* k, void* ATTR_UNUSED(arg), int il)
        struct infra_host_key* key = (struct infra_host_key*)k;
        if(!key)
                return;
-       if(il) lock_rw_unlock(&key->entry.lock);
+       if(il) { lock_rw_unlock(&key->entry.lock); }
        lock_rw_destroy(&key->entry.lock);
        free(key);
 }
@@ -322,7 +322,7 @@ infra_lame_delkeyfunc(void* k, void* ATTR_UNUSED(arg), int il)
        struct infra_lame_key* key = (struct infra_lame_key*)k;
        if(!key) 
                return;
-       if(il) lock_rw_unlock(&key->entry.lock);
+       if(il) { lock_rw_unlock(&key->entry.lock); }
        lock_rw_destroy(&key->entry.lock);
        free(key->zonename);
        free(key);
@@ -397,7 +397,7 @@ infra_set_lame(struct infra_cache* infra,
                        log_err("set_lame: malloc failure");
                        if(needtoinsert) slabhash_insert(infra->hosts, 
                                e->hash, e, e->data, NULL);
-                       else    lock_rw_unlock(&e->lock);
+                       else    { lock_rw_unlock(&e->lock); }
                        free(k->zonename);
                        free(k);
                        free(d);
@@ -409,7 +409,7 @@ infra_set_lame(struct infra_cache* infra,
        
        if(needtoinsert)
                slabhash_insert(infra->hosts, e->hash, e, e->data, NULL);
-       else    lock_rw_unlock(&e->lock);
+       else    { lock_rw_unlock(&e->lock); }
        return 1;
 }
 
@@ -436,7 +436,7 @@ infra_rtt_update(struct infra_cache* infra,
 
        if(needtoinsert)
                slabhash_insert(infra->hosts, e->hash, e, e->data, NULL);
-       else    lock_rw_unlock(&e->lock);
+       else    { lock_rw_unlock(&e->lock); }
        return 1;
 }
 
@@ -461,6 +461,6 @@ infra_edns_update(struct infra_cache* infra,
 
        if(needtoinsert)
                slabhash_insert(infra->hosts, e->hash, e, e->data, NULL);
-       else    lock_rw_unlock(&e->lock);
+       else    { lock_rw_unlock(&e->lock); }
        return 1;
 }
index d03f5a9ced50e5490e2035d246f5fb56437e76e7..489df94248f285e384fb60aa75ebb317b160e332 100644 (file)
@@ -526,7 +526,7 @@ static int test_compfunc(void* key1, void* key2)
 
 static void test_delkey(void* key, void* ATTR_UNUSED(arg), int l)
 {
-       if(l) lock_rw_unlock(&((struct testkey*)key)->entry.lock);
+       if(l) { lock_rw_unlock(&((struct testkey*)key)->entry.lock); }
        delkey((struct testkey*)key);
 }
 
index c525e1df72f76522cc03b8f82ac53fd6f908bf95..32d17838a0ea64c49abf9f7fd6b3d8cb6ba48c08 100644 (file)
@@ -406,7 +406,7 @@ static int test_compfunc(void* key1, void* key2)
 
 static void test_delkey(void* key, void* ATTR_UNUSED(arg), int l)
 {
-       if(l) lock_rw_unlock(&((struct slabtestkey*)key)->entry.lock);
+       if(l) { lock_rw_unlock(&((struct slabtestkey*)key)->entry.lock); }
        delkey((struct slabtestkey*)key);
 }
 
index 86a1aab3dc5c565ba458ac30f4121949a1bfa6df..ce0a7414b4e0988af6ce6430ebe8884b6f42f47a 100644 (file)
Binary files a/testdata/fwd_three.tpkg and b/testdata/fwd_three.tpkg differ
index 9decdba891c7e5c914f597262110427992f1d3b4..b0e74bc8383f1e223ab95843e33ea1331bfdfb2d 100644 (file)
Binary files a/testdata/fwd_three_service.tpkg and b/testdata/fwd_three_service.tpkg differ
index 6fd26841ba17b8a42afd54dfa29d8b64d1c32e9c..d4f3a82d00979e424926cd2488190eaf139762e3 100644 (file)
@@ -499,8 +499,9 @@ void
 query_entry_delete(void *k, void* ATTR_UNUSED(arg), int is_locked)
 {
        struct msgreply_entry* q = (struct msgreply_entry*)k;
-       if(is_locked)
+       if(is_locked) {
                lock_rw_unlock(&q->entry.lock);
+       }
        lock_rw_destroy(&q->entry.lock);
        query_info_clear(&q->key);
        free(q);
index 1393c58c2658c686e40d39fa8bf3324dde139095..23aa080a27bf94d6713e39c61490aa1309423338 100644 (file)
@@ -106,8 +106,9 @@ ub_rrset_key_delete(void* key, void* userdata, int is_locked)
        struct ub_packed_rrset_key* k = (struct ub_packed_rrset_key*)key;
        struct alloc_cache* a = (struct alloc_cache*)userdata;
        k->id = 0;
-       if(is_locked)
+       if(is_locked) {
                lock_rw_unlock(&k->entry.lock);
+       }
        free(k->rk.dname);
        k->rk.dname = NULL;
        alloc_special_release(a, k);
index aec29d089cd2c101d79ec35bbcd707bebc7055a9..6eb5b500c885afae92c4b029c838188876d3e492 100644 (file)
@@ -115,46 +115,56 @@ const char *event_get_method(void)
 }
 
 /** call timeouts handlers, and return how long to wait for next one or -1 */
-static void handle_timeouts(struct event_base* base, time_t now, time_t *wait)
+static void handle_timeouts(struct event_base* base, struct timeval* now, 
+       struct timeval* wait)
 {
-       struct event* p, *np;
-       *wait = (time_t)-1;
+       struct event* p;
+#ifndef S_SPLINT_S
+       wait->tv_sec = (time_t)-1;
+#endif
 
-       p = (struct event*)rbtree_first(base->times);
-       while((rbnode_t*)p!=RBTREE_NULL) {
-               /* store next to make deletion possible */
-               np = (struct event*)rbtree_next((rbnode_t*)p);
-               if(!p || p->ev_timeout.tv_sec > now ||
-               (p->ev_timeout.tv_sec==now && p->ev_timeout.tv_usec>0)) {
+       while((rbnode_t*)(p = (struct event*)rbtree_first(base->times))
+               !=RBTREE_NULL) {
+#ifndef S_SPLINT_S
+               if(p->ev_timeout.tv_sec > now->tv_sec ||
+                       (p->ev_timeout.tv_sec==now->tv_sec && 
+                       p->ev_timeout.tv_usec > now->tv_usec)) {
                        /* there is a next larger timeout. wait for it */
-                       *wait = p->ev_timeout.tv_sec - now;
-                       if(p->ev_timeout.tv_usec > 0)
-                               *wait+=1; /* wait a bit longer */
+                       wait->tv_sec = p->ev_timeout.tv_sec - now->tv_sec;
+                       if(now->tv_usec > p->ev_timeout.tv_usec) {
+                               wait->tv_sec--;
+                               wait->tv_usec = 1000000 - (now->tv_usec -
+                                       p->ev_timeout.tv_usec);
+                       } else {
+                               wait->tv_usec = p->ev_timeout.tv_usec 
+                                       - now->tv_usec;
+                       }
                        return;
                }
+#endif
                /* event times out, remove it */
                (void)rbtree_delete(base->times, p);
                p->ev_events &= ~EV_TIMEOUT;
                (*p->ev_callback)(p->ev_fd, EV_TIMEOUT, p->ev_arg);
-               /* next is a valid pointer and next larger element */
-               p = np;
        }
 }
 
 /** call select and callbacks for that */
-static int handle_select(struct event_base* base, time_t wait)
+static int handle_select(struct event_base* base, struct timeval* wait)
 {
-       struct timeval tv;
        fd_set r, w;
        int ret, i;
 
-       tv.tv_sec = wait;
-       tv.tv_usec = 0;
+#ifndef S_SPLINT_S
+       if(wait->tv_sec==(time_t)-1)
+               wait = NULL;
+#endif
+       if(wait) log_info("waiting for %d %d", wait->tv_sec, wait->tv_usec);
+       else log_info("wait forever");
        memmove(&r, &base->reads, sizeof(fd_set));
        memmove(&w, &base->writes, sizeof(fd_set));
 
-       if((ret = select(base->maxfd+1, &r, &w, NULL, 
-               (wait==(time_t)-1)?NULL:&tv)) == -1) {
+       if((ret = select(base->maxfd+1, &r, &w, NULL, wait)) == -1) {
                return -1;
        }
        
@@ -185,13 +195,15 @@ static int handle_select(struct event_base* base, time_t wait)
 /** run select in a loop */
 int event_base_dispatch(struct event_base* base)
 {
+       struct timeval now, wait;
        while(!base->need_to_exit)
        {
-               time_t now = time(NULL), wait;
+               if(gettimeofday(&now, NULL) < 0)
+                       return -1;
                /* see if timeouts need handling */
-               handle_timeouts(base, now, &wait);
+               handle_timeouts(base, &now, &wait);
                /* do select */
-               if(handle_select(base, wait) < 0) {
+               if(handle_select(base, &wait) < 0) {
                        if(base->need_to_exit)
                                return 0;
                        return -1;
@@ -258,8 +270,15 @@ int event_add(struct event* ev, struct timeval* tv)
        }
        if(tv && ev->ev_events&EV_TIMEOUT) {
 #ifndef S_SPLINT_S
-               ev->ev_timeout.tv_sec = tv->tv_sec + time(NULL);
-               ev->ev_timeout.tv_usec = tv->tv_usec;
+               struct timeval now;
+               if(gettimeofday(&now, NULL) < 0)
+                       return -1;
+               ev->ev_timeout.tv_sec = tv->tv_sec + now.tv_sec;
+               ev->ev_timeout.tv_usec = tv->tv_usec + now.tv_usec;
+               while(ev->ev_timeout.tv_usec > 1000000) {
+                       ev->ev_timeout.tv_usec -= 1000000;
+                       ev->ev_timeout.tv_sec++;
+               }
 #endif
                (void)rbtree_insert(ev->ev_base->times, &ev->node);
        }