]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
remote control tests.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 26 Sep 2008 13:02:34 +0000 (13:02 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 26 Sep 2008 13:02:34 +0000 (13:02 +0000)
git-svn-id: file:///svn/unbound/trunk@1270 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/remote.c
doc/Changelog
services/localzone.c
smallapp/unbound-control.c
testdata/09-unbound-control.tpkg

index cc7082a202d8454dc337dbeaef25c79e7d79b7d7..74c5d4262f9c66d4d2b7ff4e2ce6cb27843ada60 100644 (file)
@@ -939,9 +939,9 @@ do_zone_remove(SSL* ssl, struct worker* worker, char* arg)
                nmlabs, LDNS_RR_CLASS_IN))) {
                /* present in tree */
                local_zones_del_zone(worker->daemon->local_zones, z);
-               free(nm);
        }
        lock_quick_unlock(&worker->daemon->local_zones->lock);
+       free(nm);
        send_ok(ssl);
 }
 
index bf2791dc4d9631d7886d8aa6b8e3f1602ae12e6c..099ee3e260bcec3af305966d841bc0e367748ccd 100644 (file)
@@ -1,3 +1,8 @@
+26 September 2008: Wouter
+       - tests for remote-control.
+       - small memory leak in exception during remote control fixed.
+       - fixup for lock checking but not unchecking in remote control.
+
 23 September 2008: Wouter
        - Msg cache is loaded. A cache load enables cache responses.
        - unbound-control flush [name], flush_type and flush_zone.
index 289d3435eabec7332f53e3d8787b810d6a630db0..a7452ea393219b2696933b34fd631ab8e6374b65 100644 (file)
@@ -144,8 +144,8 @@ parse_dname(const char* str, uint8_t** res, size_t* len, int* labs)
 
 /** create a new localzone */
 static struct local_zone*
-local_zone_create(struct local_zones* zones, uint8_t* nm, size_t len
-       int labs, enum localzone_type t, uint16_t dclass)
+local_zone_create(uint8_t* nm, size_t len, int labs
+       enum localzone_type t, uint16_t dclass)
 {
        struct local_zone* z = (struct local_zone*)calloc(1, sizeof(*z));
        if(!z) {
@@ -165,13 +165,7 @@ local_zone_create(struct local_zones* zones, uint8_t* nm, size_t len,
        }
        rbtree_init(&z->data, &local_data_cmp);
        lock_protect(&z->lock, &z->parent, sizeof(*z)-sizeof(rbnode_t));
-       lock_protect(&zones->lock, &z->node, sizeof(z->node));
-       lock_protect(&zones->lock, &z->parent, sizeof(z->parent));
-       lock_protect(&zones->lock, &z->name, sizeof(z->name));
-       lock_protect(&zones->lock, &z->namelen, sizeof(z->namelen));
-       lock_protect(&zones->lock, &z->namelabs, sizeof(z->namelabs));
-       lock_protect(&zones->lock, &z->dclass, sizeof(z->dclass));
-       (void)zones; /* avoid argument unused warning if no lock checks */
+       /* also the zones->lock protects node, parent, name*, class */
        return z;
 }
 
@@ -180,7 +174,7 @@ static struct local_zone*
 lz_enter_zone_dname(struct local_zones* zones, uint8_t* nm, size_t len, 
        int labs, enum localzone_type t, uint16_t c)
 {
-       struct local_zone* z = local_zone_create(zones, nm, len, labs, t, c);
+       struct local_zone* z = local_zone_create(nm, len, labs, t, c);
        if(!z) {
                log_err("out of memory");
                return NULL;
@@ -1180,8 +1174,7 @@ struct local_zone* local_zones_add_zone(struct local_zones* zones,
        enum localzone_type tp)
 {
        /* create */
-       struct local_zone* z = local_zone_create(zones, name, len, labs, tp,
-               dclass);
+       struct local_zone* z = local_zone_create(name, len, labs, tp, dclass);
        if(!z) return NULL;
        lock_rw_wrlock(&z->lock);
 
index 050a6d5b5e11f525b1a6e9be61ffee0d51add648..9d39334cd964693047b498ce5552bd4f5f6d5ac2 100644 (file)
@@ -58,10 +58,10 @@ usage()
        printf("  -s ip[@port]  server address, if omitted config is used.\n");
        printf("  -h            show this usage help.\n");
        printf("Commands:\n");
-       printf("  start         start server; runs unbound(8)\n");
-       printf("  stop          stops the server\n");
-       printf("  reload        reloads the server\n");
-       printf("  stats         print statistics\n");
+       printf("  start                         start server; runs unbound(8)\n");
+       printf("  stop                          stops the server\n");
+       printf("  reload                        reloads the server\n");
+       printf("  stats                         print statistics\n");
        printf("  verbosity [number]            change logging detail\n");
        printf("  local_zone [name] [type]      add new local zone\n");
        printf("  local_zone_remove [name]      remove local zone and its contents\n");
@@ -302,6 +302,11 @@ int main(int argc, char* argv[])
        int c, ret;
        char* cfgfile = CONFIGFILE;
        char* svr = NULL;
+#ifdef USE_THREAD_DEBUG
+       /* stop the file output from unbound-control, overwites the servers */
+       extern int check_locking_order;
+       check_locking_order = 0;
+#endif /* USE_THREAD_DEBUG */
        log_ident_set("unbound-control");
        log_init(NULL, 0, NULL);
        checklock_start();
index b75f18cd43a79e8b4a1b865a77d09e9c4510b906..92bf70528ce3d5c7865c85f6e7ac66b4bf3f1b56 100644 (file)
Binary files a/testdata/09-unbound-control.tpkg and b/testdata/09-unbound-control.tpkg differ