]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix testbound for alloccheck runs, memory purify and lock checks.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 4 Dec 2019 10:37:24 +0000 (11:37 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 4 Dec 2019 10:37:24 +0000 (11:37 +0100)
doc/Changelog
testcode/testbound.c

index 21d25034827962fb3110c0aba3efaf745b11e392..9eea61490af47081568f259fb9f0b3f322a4bb27 100644 (file)
@@ -1,5 +1,6 @@
 4 December 2019: Wouter
        - Fix lock type for memory purify log lock deletion.
+       - Fix testbound for alloccheck runs, memory purify and lock checks.
 
 3 December 2019: Wouter
        - Merge pull request #124 from rmetrich: Changed log lock
index 735cbea62d71d2c86ea7a706f8c099558f465e32..4405231c0862661900c1ae6aa14b983291f63c75 100644 (file)
 /** config files (removed at exit) */
 static struct config_strlist* cfgfiles = NULL;
 
+#ifdef UNBOUND_ALLOC_STATS
+#  define strdup(s) unbound_stat_strdup_log(s, __FILE__, __LINE__, __func__)
+char* unbound_stat_strdup_log(char* s, const char* file, int line,
+       const char* func);
+char* unbound_stat_strdup_log(char* s, const char* file, int line,
+        const char* func) {
+       char* result;
+       size_t len;
+       if(!s) return NULL;
+       len = strlen(s);
+       log_info("%s:%d %s strdup(%u)", file, line, func, (unsigned)len+1);
+       result = unbound_stat_malloc(len+1);
+       memmove(result, s, len+1);
+       return result;
+}
+#endif /* UNBOUND_ALLOC_STATS */
+
 /** give commandline usage for testbound. */
 static void
 testbound_usage(void)
@@ -463,6 +480,12 @@ main(int argc, char* argv[])
                free(pass_argv[c]);
        if(res == 0) {
                log_info("Testbound Exit Success\n");
+               /* remove configfile from here, the atexit() is for when
+                * there is a crash to remove the tmpdir file.
+                * This one removes the file while alloc and log locks are
+                * still valid, and can be logged (for memory calculation),
+                * it leaves the ptr NULL so the atexit does nothing. */
+               remove_configfile();
                if(log_get_lock()) {
                        lock_basic_destroy((lock_basic_type*)log_get_lock());
                }