From: Alan T. DeKok Date: Wed, 23 Jan 2019 18:56:33 +0000 (-0500) Subject: call pthread destructors for the main thread. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df279b4181c5533db88e7ac2346a2f4e3afa3074;p=thirdparty%2Ffreeradius-server.git call pthread destructors for the main thread. 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. --- diff --git a/src/bin/unit_test_module.c b/src/bin/unit_test_module.c index 11c34b1d66c..4e1296c5fab 100644 --- a/src/bin/unit_test_module.c +++ b/src/bin/unit_test_module.c @@ -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); }