From: Alan T. DeKok Date: Thu, 7 Mar 2013 14:57:41 +0000 (-0500) Subject: Don't dlclose() modules on "radiusd -m" X-Git-Tag: release_3_0_0_beta1~808 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6776032099268a2d327baa89b762794d89e23d66;p=thirdparty%2Ffreeradius-server.git Don't dlclose() modules on "radiusd -m" It's a bit counter-intuitive to the meaning of "-m", but it means that the libraries hang around, so that valgrind can find symbols in them. --- diff --git a/src/include/radiusd.h b/src/include/radiusd.h index 1be743fcff8..1ab4b4a5717 100644 --- a/src/include/radiusd.h +++ b/src/include/radiusd.h @@ -476,6 +476,7 @@ typedef struct main_config_t { int colourise; //!< Messages output to stderr and //!< stdout may be formatted using //!< VT100 escape sequences. + int debug_memory; } MAIN_CONFIG_T; /* DEBUG is defined below */ diff --git a/src/main/modules.c b/src/main/modules.c index cbe351dfdc7..4c2b425da8a 100644 --- a/src/main/modules.c +++ b/src/main/modules.c @@ -452,7 +452,15 @@ static int module_entry_free(void *ctx) this = talloc_get_type_abort(ctx, module_entry_t); - lt_dlclose(this->handle); /* ignore any errors */ +#ifndef NDEBUG + /* + * Don't dlclose() modules if we're doing memory + * debugging. This removes the symbols needed by + * valgrind. + */ + if (!mainconfig.debug_memory) +#endif + lt_dlclose(this->handle); /* ignore any errors */ return 0; } diff --git a/src/main/radiusd.c b/src/main/radiusd.c index 7b5205c8974..1942f0136cf 100644 --- a/src/main/radiusd.c +++ b/src/main/radiusd.c @@ -74,8 +74,6 @@ const char *radiusd_version = "FreeRADIUS Version " RADIUSD_VERSION_STRING pid_t radius_pid; -static int debug_memory = 0; - /* * Configuration items. */ @@ -201,12 +199,12 @@ int main(int argc, char *argv[]) break; case 'm': - debug_memory = 1; + mainconfig.debug_memory = 1; break; case 'M': memory_report = 1; - debug_memory = 1; + mainconfig.debug_memory = 1; break; case 'p': @@ -384,7 +382,7 @@ int main(int argc, char *argv[]) * server to die immediately. Use SIGTERM to shut down * the server cleanly in that case. */ - if ((debug_memory == 1) || (debug_flag == 0)) { + if ((mainconfig.debug_memory == 1) || (debug_flag == 0)) { #ifdef HAVE_SIGACTION act.sa_handler = sig_fatal; sigaction(SIGINT, &act, NULL); @@ -552,7 +550,7 @@ static void sig_fatal(int sig) #ifdef SIGQUIT case SIGQUIT: #endif - if (debug_memory || memory_report) { + if (mainconfig.debug_memory || memory_report) { radius_signal_self(RADIUS_SIGNAL_SELF_TERM); break; } diff --git a/src/modules/rlm_eap/eap.c b/src/modules/rlm_eap/eap.c index e2855efcbec..8b8951b0f16 100644 --- a/src/modules/rlm_eap/eap.c +++ b/src/modules/rlm_eap/eap.c @@ -75,7 +75,16 @@ static int eaptype_free(void *ctx) node = talloc_get_type_abort(ctx, EAP_TYPES); if (node->type->detach) (node->type->detach)(node->type_data); - if (node->handle) lt_dlclose(node->handle); + +#ifndef NDEBUG + /* + * Don't dlclose() modules if we're doing memory + * debugging. This removes the symbols needed by + * valgrind. + */ + if (!mainconfig.debug_memory) +#endif + if (node->handle) lt_dlclose(node->handle); return 0; }