leak-detective: set_state() only affects the calling thread
authorMartin Willi <martin@revosec.ch>
Wed, 10 Jul 2013 15:16:49 +0000 (17:16 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 10 Jul 2013 15:28:32 +0000 (17:28 +0200)
The only user (bfd backtraces) is fine with that, and we really should not
mess the enable flag while doing allocations with other threads.

src/libstrongswan/utils/leak_detective.c
src/libstrongswan/utils/leak_detective.h

index b2c644a..40c429c 100644 (file)
@@ -709,19 +709,7 @@ METHOD(leak_detective_t, leaks, int,
 METHOD(leak_detective_t, set_state, bool,
        private_leak_detective_t *this, bool enable)
 {
-       if (enable == enabled)
-       {
-               return enabled;
-       }
-       if (enable)
-       {
-               enable_leak_detective();
-       }
-       else
-       {
-               disable_leak_detective();
-       }
-       return !enabled;
+       return enable_thread(enable);
 }
 
 METHOD(leak_detective_t, usage, void,
index 6a39aef..7a29e81 100644 (file)
@@ -57,7 +57,7 @@ struct leak_detective_t {
        void (*usage)(leak_detective_t *this, FILE *out);
 
        /**
-        * Enable/disable leak detective hooks.
+        * Enable/disable leak detective hooks for the current thread.
         *
         * @param                               TRUE to enable, FALSE to disable
         * @return                              state active before calling set_state
@@ -76,4 +76,3 @@ struct leak_detective_t {
 leak_detective_t *leak_detective_create();
 
 #endif /** LEAK_DETECTIVE_H_ @}*/
-