From df8a6718208e6d9be662804f633d4644e2ce83e9 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 21 Dec 2024 14:34:20 -0800 Subject: nuts: add 20 millisecond delay before nng_fini This is to allow finalizers to run for the HTTP framework. This is a bug workaround for now, and should be fixed in the HTTP framework later by using reference counts correctly. --- src/testing/nuts.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/testing') diff --git a/src/testing/nuts.h b/src/testing/nuts.h index f2e50c2c..421e0a53 100644 --- a/src/testing/nuts.h +++ b/src/testing/nuts.h @@ -23,8 +23,15 @@ extern void nuts_logger( nng_log_level, nng_log_facility, const char *, const char *); // Call nng_fini during test finalization -- this avoids leak warnings. +// We add a 20 millisecond delay as a hack to allow for other subsytems to +// drain first. (Notably the HTTP framework can fail if we shut down too +// quickly. These bugs should be fixed and then the sleep can be removed.) #ifndef TEST_FINI -#define TEST_FINI nng_fini() +#define TEST_FINI \ + do { \ + nng_msleep(20); \ + nng_fini(); \ + } while (0) #endif #ifndef TEST_INIT -- cgit v1.2.3-70-g09d2