diff --git a/configure.ac b/configure.ac index db82222e0d..5a7b9f0cbc 100644 --- a/configure.ac +++ b/configure.ac @@ -1986,6 +1986,16 @@ if test "${enable_address_sanitizer}" = "yes"; then APR_ADDTO(LDFLAGS, -fsanitize=address) fi +# Enable fake dlclose +AC_ARG_ENABLE(fake_dlclose, + [AC_HELP_STRING([--enable-fake-dlclose],[Do not unload dynamic libraries])], + [enable_fake_dlclose="$enable_fake_dlclose"], + [enable_fake_dlclose="no"]) + +if test "${enable_fake_dlclose}" = "yes"; then + APR_ADDTO(SWITCH_AM_CFLAGS, -DHAVE_FAKE_DLCLOSE) +fi + AC_ARG_ENABLE(, [AC_HELP_STRING([--enable-pool-sanitizer],[build with sanitizer friendly pool behavior])], [enable_pool_sanitizer="$enable_pool_sanitizer"], diff --git a/src/switch_dso.c b/src/switch_dso.c index a78bba2f8c..86ffb0f419 100644 --- a/src/switch_dso.c +++ b/src/switch_dso.c @@ -91,7 +91,9 @@ SWITCH_DECLARE(void *) switch_dso_data_sym(switch_dso_lib_t lib, const char *sym void switch_dso_destroy(switch_dso_lib_t *lib) { if (lib && *lib) { +#ifndef HAVE_FAKE_DLCLOSE dlclose(*lib); +#endif *lib = NULL; } }