]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Remove leakfinder (--enable-leakfinder) (#655)
authorFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 8 Jun 2020 21:40:57 +0000 (21:40 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Mon, 8 Jun 2020 21:41:01 +0000 (21:41 +0000)
There are better leak finding tools for most use cases now. The removed
code can be manually added back for experiments in other use cases. The
original leakfinder design required code modifications anyway.

12 files changed:
configure.ac
include/leakcheck.h [deleted file]
include/squid.h
squid.dox
src/LeakFinder.cc [deleted file]
src/LeakFinder.h [deleted file]
src/Makefile.am
src/icmp/Icmp4.cc
src/icmp/Icmp6.cc
test-suite/buildtests/layer-01-minimal.opts
test-suite/buildtests/layer-02-maximus.opts
test-suite/buildtests/layer-04-noauth-everything.opts

index cbd9c4f5afad2412fd09ab9c2626866521ccdb39..e4ec9ab7c39af4dd4bb27d4216ee8ff56146aa90 100644 (file)
@@ -2386,21 +2386,6 @@ else
   fi
 fi
 
-dnl Enable Leak Finding Functions
-AC_ARG_ENABLE(leakfinder,
-  AS_HELP_STRING([--enable-leakfinder],
-    [Enable Leak Finding code. Enabling this alone does nothing;
-     you also have to modify the source code to use the leak
-     finding functions. Probably Useful for hackers only.]), [ 
-  SQUID_YESNO([$enableval],
-     [unrecognized argument to --enable-leakfinder: $enableval])
-])
-AC_MSG_NOTICE([Leak Finder enabled: ${enable_leakfinder:=no}])
-SQUID_DEFINE_BOOL(USE_LEAKFINDER,$enable_leakfinder,
-  [Enable code for assisting in finding memory leaks. Not for the faint of heart])
-AM_CONDITIONAL(ENABLE_LEAKFINDER, [test "x$enable_leakfinder" = "xyes"])
-
-
 AC_ARG_ENABLE(follow-x-forwarded-for,
   AS_HELP_STRING([--enable-follow-x-forwarded-for],
                  [Enable support for following the X-Forwarded-For
diff --git a/include/leakcheck.h b/include/leakcheck.h
deleted file mode 100644 (file)
index f3974c1..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
- *
- * Squid software is distributed under GPLv2+ license and includes
- * contributions from numerous individuals and organizations.
- * Please see the COPYING and CONTRIBUTORS files for details.
- */
-
-#ifndef _SQUID_LEAKCHECK_H
-#define _SQUID_LEAKCHECK_H
-
-#if LEAK_CHECK_MODE && 0 /* doesn't work at the moment */
-#define LOCAL_ARRAY(type,name,size) \
-        static type *local_##name=NULL; \
-        type *name = local_##name ? local_##name : \
-                ( local_##name = (type *)xcalloc(size, sizeof(type)) )
-#else
-#define LOCAL_ARRAY(type,name,size) static type name[size]
-#endif
-
-#endif
-
index 953bbd08c1b451169ea2106aceae4074415cbe4d..0dc02cc21f6f06ecc6e593bf9cd5ed077d69dee7 100644 (file)
@@ -72,8 +72,7 @@ using namespace Squid;
 /** \endcond */
 #endif
 
-// temporary for the definition of LOCAL_ARRAY
-#include "leakcheck.h"
+#define LOCAL_ARRAY(type, name, size) static type name[size]
 
 #endif /* SQUID_CONFIG_H */
 
index 355b8dda6654f3a9d3387b1752e95b3c9edd5150..e8710e8a3a9958ea8c8460d2087eebe911833b3d 100644 (file)
--- a/squid.dox
+++ b/squid.dox
@@ -2092,7 +2092,6 @@ PREDEFINED             = __cplusplus \
                          USE_IDENT \
                          USE_IPV6 \
                          USE_KQUEUE \
-                         USE_LEAKFINDER \
                          USE_LIBCAP \
                          USE_LOADABLE_MODULES \
                          USE_MIT_KRB5 \
diff --git a/src/LeakFinder.cc b/src/LeakFinder.cc
deleted file mode 100644 (file)
index 92a3072..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
- *
- * Squid software is distributed under GPLv2+ license and includes
- * contributions from numerous individuals and organizations.
- * Please see the COPYING and CONTRIBUTORS files for details.
- */
-
-/* DEBUG: section 45    Callback Data Registry */
-
-/*
- * Use these to find memory leaks
- */
-
-#include "squid.h"
-
-#if USE_LEAKFINDER
-
-#include "LeakFinder.h"
-#include "SquidTime.h"
-#include "Store.h"
-
-/* ========================================================================= */
-
-LeakFinderPtr::LeakFinderPtr(void *p, const char *f, const int l) :
-    file(f),
-    line(l),
-    when(squid_curtime)
-{
-    // XXX: these bits should be done by hash_link()
-    key = p;
-    next = NULL;
-}
-
-/* ========================================================================= */
-
-LeakFinder::LeakFinder() :
-    count(0),
-    last_dump(0)
-{
-    debugs(45, 3, "LeakFinder constructed");
-    table = hash_create(cmp, 1 << 8, hash);
-#if 0
-    /* if this is desired to reinstate, add a
-     * RegisterWithCacheManager method
-     */
-    cachemgrRegister("leaks",
-                     "Memory Leak Tracking",
-                     cachemgr_dump, 0, 1);
-#endif
-}
-
-void *
-LeakFinder::addSome(void *p, const char *file, int line)
-{
-    assert(hash_lookup(table, p) == NULL);
-    LeakFinderPtr *c = new LeakFinderPtr(p, file, line);
-    hash_join(table, c);
-    ++count;
-    return p;
-}
-
-void *
-LeakFinder::touch(void *p, const char *file, int line)
-{
-    assert(p);
-    LeakFinderPtr *c = (LeakFinderPtr *) hash_lookup(table, p);
-    assert(c);
-    c->file = file;
-    c->line = line;
-    c->when = squid_curtime;
-    return p;
-}
-
-void *
-LeakFinder::freeSome(void *p, const char *file, int line)
-{
-    assert(p);
-    LeakFinderPtr *c = (LeakFinderPtr *) hash_lookup(table, p);
-    assert(c);
-    hash_remove_link(table, c);
-    --count;
-    delete c;
-    dump();
-    return p;
-}
-
-/* ========================================================================= */
-
-int
-LeakFinder::cmp(const void *p1, const void *p2)
-{
-    return (char *) p1 - (char *) p2;
-}
-
-unsigned int
-LeakFinder::hash(const void *p, unsigned int mod)
-{
-    return ((unsigned long) p >> 8) % mod;
-}
-
-void
-LeakFinder::dump()
-{
-    if (0 == count)
-        return;
-
-    if (squid_curtime == last_dump)
-        return;
-
-    last_dump = squid_curtime;
-
-    debugs(45, DBG_IMPORTANT, "Tracking " << count << " pointers");
-
-    hash_first(table);
-
-    LeakFinderPtr *c;
-
-    while ((c = (LeakFinderPtr *)hash_next(table))) {
-        debugs(45, DBG_IMPORTANT, std::setw(20) << c->key << " last used " << std::setw(9) << (squid_curtime - c->when) <<
-               " seconds ago by " << c->file << ":" << c->line);
-    }
-}
-
-#endif /* USE_LEAKFINDER */
-
diff --git a/src/LeakFinder.h b/src/LeakFinder.h
deleted file mode 100644 (file)
index b9b0b33..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
- *
- * Squid software is distributed under GPLv2+ license and includes
- * contributions from numerous individuals and organizations.
- * Please see the COPYING and CONTRIBUTORS files for details.
- */
-
-#ifndef SQUID_LEAKFINDER_H
-#define SQUID_LEAKFINDER_H
-
-#if USE_LEAKFINDER
-
-#include "hash.h"
-
-#define leakAdd(p,l) if (l) l->addSome(p,__FILE__,__LINE__)
-#define leakTouch(p,l) if (l) l->touch(p,__FILE__,__LINE__)
-#define leakFree(p,l) if (l) l->freeSome(p,__FILE__,__LINE__)
-
-class LeakFinderPtr : public hash_link
-{
-
-public:
-    LeakFinderPtr(void *, const char *, const int);
-    const char *file;
-    int line;
-    time_t when;
-};
-
-class LeakFinder
-{
-
-public:
-    LeakFinder();
-    ~LeakFinder();
-
-    void *addSome(void *, const char *, const int);
-
-    void *touch(void *, const char *, const int);
-
-    void *freeSome(void *, const char *, const int);
-
-    void dump();
-
-private:
-    static HASHCMP cmp;
-
-    static HASHHASH hash;
-
-    hash_table *table;
-
-    int count;
-
-    time_t last_dump;
-
-};
-
-#else /* USE_LEAKFINDER */
-
-class LeakFinder {};
-
-#define leakAdd(p,l) (void)0
-#define leakTouch(p,l) (void)0
-#define leakFree(p,l) (void)0
-#endif /* USE_LEAKFINDER */
-
-#endif /* SQUID_LEAKFINDER_H */
-
index c3ed4d642d4840230467c4d3c983a9549176e095..a547eab1e000b6a5f4ccb713f90fa9d021f8ed68 100644 (file)
@@ -134,12 +134,6 @@ if ENABLE_HTCP
 HTCPSOURCE = htcp.cc htcp.h
 endif
 
-if ENABLE_LEAKFINDER
-LEAKFINDERSOURCE =  LeakFinder.cc
-else
-LEAKFINDERSOURCE =
-endif
-
 if ENABLE_UNLINKD
 UNLINKDSOURCE = unlinkd.h unlinkd.cc
 UNLINKD = unlinkd
@@ -364,7 +358,6 @@ squid_SOURCES = \
        $(IPC_SOURCE) \
        ipcache.cc \
        ipcache.h \
-       $(LEAKFINDERSOURCE) \
        LogTags.cc \
        LogTags.h \
        lookup_t.h \
@@ -505,8 +498,6 @@ EXTRA_squid_SOURCES = \
        ipc.cc \
        ipc_win32.cc \
        ProfStats.cc \
-       LeakFinder.cc \
-       LeakFinder.h \
        $(SNMP_ALL_SOURCE) \
        $(UNLINKDSOURCE) \
        $(WIN32_ALL_SOURCE) \
index 9500215b56cb5647baf8a63b59297607ebc751ae..ec321a2b08ba78f6cc84594e2e98b2cf333ce18d 100644 (file)
@@ -17,7 +17,6 @@
 #include "Debug.h"
 #include "Icmp4.h"
 #include "IcmpPinger.h"
-#include "leakcheck.h"
 #include "SquidTime.h"
 
 static const char *
index e9160a2cc6c2c561b810c070605ca7912a25eef1..c7bc8bb45f67b4b3235314bd465989d123a2cf30 100644 (file)
@@ -17,7 +17,6 @@
 #include "Debug.h"
 #include "Icmp6.h"
 #include "IcmpPinger.h"
-#include "leakcheck.h"
 #include "SquidTime.h"
 
 // Some system headers are only neeed internally here.
index aa6430ce50a2e47625a4eb18ac533863f8209caa..5ee2364ce8c44be8b159d048962516e9c44af9d3 100644 (file)
@@ -73,7 +73,6 @@ DISTCHECK_CONFIGURE_FLAGS=" \
        --disable-pf-transparent \
        --disable-linux-netfilter \
        --disable-linux-tproxy \
-       --disable-leakfinder \
        --disable-follow-x-forwarded-for \
        --disable-ident-lookups \
        --disable-default-hostsfile \
index a45d680d4c39f51a966e03e5867ce27395b52a32..cbbef31b7d97244e028e9419a073757c5f1211ed 100644 (file)
@@ -79,7 +79,6 @@ DISTCHECK_CONFIGURE_FLAGS=" \
        --enable-select \
        --enable-http-violations \
        --enable-ipfw-transparent \
-       --enable-leakfinder \
        --enable-follow-x-forwarded-for \
        --enable-ident-lookups \
        --enable-default-hostsfile=/etc/hosts \
index 737932bd88889f7e8fbb6898c718470a922470be..a61a597892848c6c2c307c803f0ef4943b8a3324 100644 (file)
@@ -80,7 +80,6 @@ DISTCHECK_CONFIGURE_FLAGS=" \
        --enable-select \
        --enable-http-violations \
        --enable-ipfw-transparent \
-       --enable-leakfinder \
        --enable-follow-x-forwarded-for \
        --enable-ident-lookups \
        --enable-internal-dns \