Skip to content

Commit

Permalink
nuts: add 20 millisecond delay before nng_fini
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gdamore committed Dec 21, 2024
1 parent 2565488 commit 2bcccc2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/testing/nuts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2bcccc2

Please sign in to comment.