]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
call pthread destructors for the main thread.
authorAlan T. DeKok <aland@freeradius.org>
Wed, 23 Jan 2019 18:56:33 +0000 (13:56 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 23 Jan 2019 18:56:33 +0000 (13:56 -0500)
An alternative would be to run all of the tests under a child
thread, and then join it.  If the various compilers like this
patch, then it's fine for now.

src/bin/unit_test_module.c

index 11c34b1d66c59afeb71758c87de03559ede7dadd..4e1296c5fabd837febe7a859235b74bb5f1c3fd0 100644 (file)
@@ -1149,11 +1149,18 @@ cleanup:
        fr_dict_free(&dict);
 
        /*
-        *      Free the strerror buffer.
+        *      Call pthread destructors.  Which aren't normally
+        *      called for the main thread.
+        *
+        *      Note that pthread_exit() never returns, and always
+        *      causes the process to exit with status '0'.  So we
+        *      check for test failure here, and if so, don't call the
+        *      destructors.  If the tests fail, who cares about
+        *      memory leaks...
         */
-       fr_strerror_free();
+       if (ret != 0) return ret;
 
-       return ret;
+       pthread_exit(NULL);
 }