]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Don't dlclose() modules on "radiusd -m"
authorAlan T. DeKok <aland@freeradius.org>
Thu, 7 Mar 2013 14:57:41 +0000 (09:57 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 7 Mar 2013 14:57:41 +0000 (09:57 -0500)
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.

src/include/radiusd.h
src/main/modules.c
src/main/radiusd.c
src/modules/rlm_eap/eap.c

index 1be743fcff8dd210ab365d18e5c11d8333e8548e..1ab4b4a57170b71f8ce9a305218ac79695044e9e 100644 (file)
@@ -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 */
index cbe351dfdc78aafc0e26692ad22528414c5fa264..4c2b425da8a3e12f126a8d6d643eebe9329f88df 100644 (file)
@@ -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;
 }
 
index 7b5205c8974ceaea3fa511d73810e4d8d7ae744e..1942f0136cf56a0615ee4e085c1cd1c33075b01c 100644 (file)
@@ -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;
                        }
index e2855efcbec1ec3685b7087dff3cc6111437d35e..8b8951b0f16110fcfd8d5a85eec5e7b43eca18dd 100644 (file)
@@ -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;
 }