]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- patch from Dag-Erling Smorgrav that removes code that relies
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 22 Nov 2016 15:50:07 +0000 (15:50 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 22 Nov 2016 15:50:07 +0000 (15:50 +0000)
  on sbrk().

git-svn-id: file:///svn/unbound/trunk@3934 be551aaa-1e26-0410-a405-d3ace91eadb9

config.h.in
configure
configure.ac
contrib/unbound_munin_
daemon/remote.c
daemon/unbound.c
daemon/worker.c
doc/Changelog
doc/unbound-control.8.in
testcode/memstats.c

index 64d1c797a0e07a99cb954770f71db4fdfbda6af2..cee0b1252a96c5171f032469b4b4541f911add60 100644 (file)
 /* Define to 1 if you have the `recvmsg' function. */
 #undef HAVE_RECVMSG
 
-/* define if you have the sbrk() call */
-#undef HAVE_SBRK
-
 /* Define to 1 if you have the `sendmsg' function. */
 #undef HAVE_SENDMSG
 
index 5716f4995a2953481f96fcfbeb821b94d4e1e8ae..67cbd538c9cacb769c7fc3a2708162a727332530 100755 (executable)
--- a/configure
+++ b/configure
 done
 
 
-for ac_func in sbrk
-do :
-  ac_fn_c_check_func "$LINENO" "sbrk" "ac_cv_func_sbrk"
-if test "x$ac_cv_func_sbrk" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_SBRK 1
-_ACEOF
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if sbrk is not deprecated" >&5
-$as_echo_n "checking if sbrk is not deprecated... " >&6; }
-# catch the warning of deprecated sbrk
-old_cflags="$CFLAGS"
-CFLAGS="$CFLAGS -Werror"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-
-int main(void) { void* cur = sbrk(0); printf("%u\n", (unsigned)(size_t)((char*)cur - (char*)sbrk(0))); return 0; }
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-$as_echo "#define HAVE_SBRK 1" >>confdefs.h
-
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-CFLAGS="$old_cflags"
-
-fi
-done
-
-
 # check if setreuid en setregid fail, on MacOSX10.4(darwin8).
 if echo $build_os | grep darwin8 > /dev/null; then
 
index 9ccde4d3dc7aea0a3900d11c8506e80256098fb8..d96d64a4d2c0170cd6cfdb0072f32918736b4b8a 100644 (file)
@@ -1147,21 +1147,6 @@ AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam endpwent getrlimit setrlimit se
 AC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])])
 AC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])])
 
-AC_CHECK_FUNCS([sbrk],[
-AC_MSG_CHECKING([if sbrk is not deprecated])
-# catch the warning of deprecated sbrk
-old_cflags="$CFLAGS"
-CFLAGS="$CFLAGS -Werror"
-AC_COMPILE_IFELSE([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT
-[[
-int main(void) { void* cur = sbrk(0); printf("%u\n", (unsigned)(size_t)((char*)cur - (char*)sbrk(0))); return 0; }
-]])], [
-       AC_MSG_RESULT(yes)
-       AC_DEFINE(HAVE_SBRK, 1, [define if you have the sbrk() call])
-    ], [AC_MSG_RESULT(no)])
-CFLAGS="$old_cflags"
-])
-
 # check if setreuid en setregid fail, on MacOSX10.4(darwin8).
 if echo $build_os | grep darwin8 > /dev/null; then
        AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work])
index df76a9fcf995c6ad129b31eb203d6e0586e69b62..5d3dff8e813e5fa1b53fed8fc0f5102d6e605969 100755 (executable)
@@ -266,7 +266,6 @@ if test "$1" = "config" ; then
                echo "graph_args --base 1024 -l 0"
                echo "graph_vlabel memory used in bytes"
                echo "graph_category DNS"
-               p_config "mem.total.sbrk" "Total memory" "GAUGE"
                p_config "mem.cache.rrset" "RRset cache memory" "GAUGE"
                p_config "mem.cache.message" "Message cache memory" "GAUGE"
                p_config "mem.mod.iterator" "Iterator module memory" "GAUGE"
@@ -458,20 +457,6 @@ queue)
        done
        ;;
 memory)
-       mn=`echo mem.total.sbrk | sed $ABBREV | tr . _`
-       get_value 'mem.total.sbrk'
-       if test $value -eq 0; then
-               chk=`echo $ctrl | sed -e 's/-control$/-checkconf/'`
-               pidf=`$chk -o pidfile $conf 2>&1`
-               pid=`cat $pidf 2>&1`
-               value=`ps -p "$pid" -o rss= 2>&1`
-               if test "`expr $value + 1 - 1 2>&1`" -eq "$value" 2>&1; then
-                       value=`expr $value \* 1024` 
-               else
-                       value=0
-               fi
-       fi
-       echo "$mn.value" $value
        for x in mem.cache.rrset mem.cache.message mem.mod.iterator \
                mem.mod.validator msg.cache.count rrset.cache.count \
                infra.cache.count key.cache.count; do
index faee2f88169c56f4f6ce0839249abd1353e39733..417c6a24ad35f09064a17fae282b07d7e92799ca 100644 (file)
@@ -823,12 +823,6 @@ print_mem(SSL* ssl, struct worker* worker, struct daemon* daemon)
 {
        int m;
        size_t msg, rrset, val, iter;
-#ifdef HAVE_SBRK
-       extern void* unbound_start_brk;
-       void* cur = sbrk(0);
-       if(!print_longnum(ssl, "mem.total.sbrk"SQ, 
-               (size_t)((char*)cur - (char*)unbound_start_brk))) return 0;
-#endif /* HAVE_SBRK */
        msg = slabhash_get_mem(daemon->env->msg_cache);
        rrset = slabhash_get_mem(&daemon->env->rrset_cache->table);
        val=0;
index d1fc6eb9e0e60d7a27e3d593020d9a98fc4250c7..971ccc47de2b2e5a79b6e61f000ac9b7baa05124 100644 (file)
 #  include "nss.h"
 #endif
 
-#ifdef HAVE_SBRK
-/** global debug value to keep track of heap memory allocation */
-void* unbound_start_brk = 0;
-#endif
-
 /** print usage. */
 static void usage(void)
 {
@@ -686,11 +681,6 @@ main(int argc, char* argv[])
        int cmdline_cfg = 0;
 #endif
 
-#ifdef HAVE_SBRK
-       /* take debug snapshot of heap */
-       unbound_start_brk = sbrk(0);
-#endif
-
        log_init(NULL, 0, NULL);
        log_ident_default = strrchr(argv[0],'/')?strrchr(argv[0],'/')+1:argv[0];
        log_ident_set(log_ident_default);
index 5e49011ac36fb948820773b71082b54d882e5cd5..94f636b657466b212e3d1931bc016b7eed0940df 100644 (file)
  */
 #define PREFETCH_EXPIRY_ADD 60
 
-#ifdef UNBOUND_ALLOC_STATS
-/** measure memory leakage */
-static void
-debug_memleak(size_t accounted, size_t heap, 
-       size_t total_alloc, size_t total_free)
-{
-       static int init = 0;
-       static size_t base_heap, base_accounted, base_alloc, base_free;
-       size_t base_af, cur_af, grow_af, grow_acc;
-       if(!init) {
-               init = 1;
-               base_heap = heap;
-               base_accounted = accounted;
-               base_alloc = total_alloc;
-               base_free = total_free;
-       }
-       base_af = base_alloc - base_free;
-       cur_af = total_alloc - total_free;
-       grow_af = cur_af - base_af;
-       grow_acc = accounted - base_accounted;
-       log_info("Leakage: %d leaked. growth: %u use, %u acc, %u heap",
-               (int)(grow_af - grow_acc), (unsigned)grow_af, 
-               (unsigned)grow_acc, (unsigned)(heap - base_heap));
-}
-
-/** give debug heap size indication */
-static void
-debug_total_mem(size_t calctotal)
-{
-#ifdef HAVE_SBRK
-       extern void* unbound_start_brk;
-       extern size_t unbound_mem_alloc, unbound_mem_freed;
-       void* cur = sbrk(0);
-       int total = cur-unbound_start_brk;
-       log_info("Total heap memory estimate: %u  total-alloc: %u  "
-               "total-free: %u", (unsigned)total, 
-               (unsigned)unbound_mem_alloc, (unsigned)unbound_mem_freed);
-       debug_memleak(calctotal, (size_t)total, 
-               unbound_mem_alloc, unbound_mem_freed);
-#else
-       (void)calctotal;
-#endif /* HAVE_SBRK */
-}
-#endif /* UNBOUND_ALLOC_STATS */
-
 /** Report on memory usage by this thread and global */
 static void
 worker_mem_report(struct worker* ATTR_UNUSED(worker), 
        struct serviced_query* ATTR_UNUSED(cur_serv))
 {
 #ifdef UNBOUND_ALLOC_STATS
+       /* measure memory leakage */
+       extern size_t unbound_mem_alloc, unbound_mem_freed;
        /* debug func in validator module */
        size_t total, front, back, mesh, msg, rrset, infra, ac, superac;
        size_t me, iter, val, anch;
@@ -199,7 +156,9 @@ worker_mem_report(struct worker* ATTR_UNUSED(worker),
                (unsigned)mesh, (unsigned)msg, (unsigned)rrset, 
                (unsigned)infra, (unsigned)iter, (unsigned)val, (unsigned)anch,
                (unsigned)ac, (unsigned)superac, (unsigned)me);
-       debug_total_mem(total);
+       log_info("Total heap memory estimate: %u  total-alloc: %u  "
+               "total-free: %u", (unsigned)total, 
+               (unsigned)unbound_mem_alloc, (unsigned)unbound_mem_freed);
 #else /* no UNBOUND_ALLOC_STATS */
        size_t val = 0;
        int i;
index 814b494a8e0121e4bfd693ad692a3aa07fdd8120..7c90fb30c2456a729630919b83daf739a249aede 100644 (file)
@@ -11,6 +11,8 @@
 22 November 2016: Wouter
        - iana portlist update.
        - Fix unit tests for DS hash processing for fake-dsa test option.
+       - patch from Dag-Erling Smorgrav that removes code that relies
+         on sbrk().
 
 21 November 2016: Wouter
        - Fix #1158: reference RFC 8020 "NXDOMAIN: There Really Is Nothing
index 5a0bff682dda53b6758f86b3ef18f46126692d54..f5e36df2c768098547c3715b66f6257e9b993c23 100644 (file)
@@ -405,9 +405,6 @@ uptime since server boot in seconds.
 time since last statistics printout, in seconds.
 .SH EXTENDED STATISTICS
 .TP
-.I mem.total.sbrk
-If sbrk(2) is available, an estimate of the heap size of the program in number of bytes. Close to the total memory used by the program, as reported by top and ps.  Could be wrong if the OS allocates memory non\-contiguously.
-.TP
 .I mem.cache.rrset
 Memory in bytes in use by the RRset cache.
 .TP
index 1cca02e74dcfc865ce9ccf4852f1c75cd179da58..e837bbf3b49d95b18d70daa870f7158c7e8d0ee0 100644 (file)
@@ -236,6 +236,7 @@ printstats(rbtree_t* tree)
 int main(int argc, const char* argv[])
 {
        rbtree_t* tree = 0;
+       log_init(NULL, 0, 0);
        if(argc != 2) {
                usage();
        }