Module: sip-router
Branch: master
Commit: c191f7b603a67f609cb9fe8adf0fc91f99bf9e33
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c191f7b603a67f609cb9fe8adf0fc91f99bf9e33

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date:   Fri Aug 26 09:32:51 2011 +0200

core:mem: short status dumping

- patch by Andrade Ricardo, on Aug 1, 2011

---

 cfg_core.c                        |    7 ++++---
 doc/cfg_list/docbook/cfg_core.xml |    6 ++++--
 mem/f_malloc.c                    |    5 +++++
 mem/ll_malloc.c                   |    5 +++++
 mem/q_malloc.c                    |    5 ++++-
 5 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/cfg_core.c b/cfg_core.c
index 03605ee..27a55b3 100644
--- a/cfg_core.c
+++ b/cfg_core.c
@@ -120,7 +120,7 @@ struct cfg_group_core default_core_cfg = {
        0,  /*!< force_rport */
        L_DBG, /*!< memlog */
        3, /*!< mem_summary -flags: 0 off, 1 pkg_status, 2 shm_status,
-               4 pkg_sums, 8 shm_sums */
+               4 pkg_sums, 8 shm_sums, 16 short_status */
        L_ERR /*!< corelog */
 };
 
@@ -301,13 +301,14 @@ cfg_def_t core_cfg_def[] = {
                "force rport for all the received messages" },
        {"memlog",              CFG_VAR_INT|CFG_ATOMIC, 0, 0, 0, 0,
                "log level for memory status/summary information"},
-       {"mem_summary", CFG_VAR_INT|CFG_ATOMIC, 0, 15, 0, 0,
+       {"mem_summary", CFG_VAR_INT|CFG_ATOMIC, 0, 31, 0, 0,
                "memory debugging information displayed on exit (flags): "
                " 0 - off,"
                " 1 - dump all the pkg used blocks (status),"
                " 2 - dump all the shm used blocks (status),"
                " 4 - summary of pkg used blocks,"
-               " 8 - summary of shm used blocks" },
+               " 8 - summary of shm used blocks,"
+               " 16 - short status instead of dump" },
        {"corelog",             CFG_VAR_INT|CFG_ATOMIC, 0, 0, 0, 0,
                "log level for non-critical core error messages"},
        {0, 0, 0, 0, 0, 0}
diff --git a/doc/cfg_list/docbook/cfg_core.xml 
b/doc/cfg_list/docbook/cfg_core.xml
index c2ed233..04b5c7c 100644
--- a/doc/cfg_list/docbook/cfg_core.xml
+++ b/doc/cfg_list/docbook/cfg_core.xml
@@ -511,10 +511,12 @@
         memory debugging information displayed on exit (flags):  0 -
         off, 1 - dump all the pkg used blocks (status), 2 - dump all
         the shm used blocks (status), 4 - summary of pkg used blocks, 8
-        - summary of shm used blocks.
+        - summary of shm used blocks, 16 - show only summary of used
+       blocks instead of full dump (to use in conjuntion with flags 1
+       and 2).
     </para>
     <para>Default value: 3.</para>
-    <para>Range: 0 - 15.</para>
+    <para>Range: 0 - 31.</para>
     <para>Type: integer.</para>
     <para>
     </para>
diff --git a/mem/f_malloc.c b/mem/f_malloc.c
index be25546..7beb3e2 100644
--- a/mem/f_malloc.c
+++ b/mem/f_malloc.c
@@ -667,8 +667,10 @@ void fm_status(struct fm_block* qm)
        int unused;
        unsigned long size;
        int memlog;
+       int mem_summary;
 
        memlog=cfg_get(core, core_cfg, memlog);
+       mem_summary=cfg_get(core, core_cfg, mem_summary);
        LOG_(DEFAULT_FACILITY, memlog, "fm_status: ", "fm_status (%p):\n", qm);
        if (!qm) return;
 
@@ -681,6 +683,9 @@ void fm_status(struct fm_block* qm)
        LOG_(DEFAULT_FACILITY, memlog, "fm_status: ",
                        " max used (+overhead)= %lu\n", qm->max_real_used);
 #endif
+
+       if (mem_summary & 16) return;
+
        /*
        LOG_(DEFAULT_FACILITY, memlog, "fm_status: ", "dumping all 
fragments:\n");
        for (f=qm->first_frag, i=0;((char*)f<(char*)qm->last_frag) && (i<10);
diff --git a/mem/ll_malloc.c b/mem/ll_malloc.c
index 11c8800..2a46c8a 100644
--- a/mem/ll_malloc.c
+++ b/mem/ll_malloc.c
@@ -971,14 +971,19 @@ void sfm_status(struct sfm_block* qm)
        unsigned long size;
        int k;
        int memlog;
+       int mem_summary;
 
 #warning "ll_status doesn't work (might crash if used)"
 
        memlog=cfg_get(core, core_cfg, memlog);
+       mem_summary=cfg_get(core, core_cfg, mem_summary);
        LOG(memlog, "sfm_status (%p):\n", qm);
        if (!qm) return;
 
        LOG(memlog, " heap size= %ld\n", qm->size);
+
+       if (mem_summary & 16) return;
+
        LOG(memlog, "dumping free list:\n");
        for(h=0,i=0,size=0;h<=sfm_max_hash;h++){
                SFM_MAIN_HASH_LOCK(qm, h);
diff --git a/mem/q_malloc.c b/mem/q_malloc.c
index 895cbfc..76bf938 100644
--- a/mem/q_malloc.c
+++ b/mem/q_malloc.c
@@ -716,9 +716,10 @@ void qm_status(struct qm_block* qm)
        int h;
        int unused;
        int memlog;
-
+       int mem_summary;
 
        memlog=cfg_get(core, core_cfg, memlog);
+       mem_summary=cfg_get(core, core_cfg, mem_summary);
        LOG_(DEFAULT_FACILITY, memlog, "qm_status: ", "(%p):\n", qm);
        if (!qm) return;
 
@@ -730,6 +731,8 @@ void qm_status(struct qm_block* qm)
        LOG_(DEFAULT_FACILITY, memlog, "qm_status: ",
                        "max used (+overhead)= %lu\n", qm->max_real_used);
        
+       if (mem_summary & 16) return;
+
        LOG_(DEFAULT_FACILITY, memlog, "qm_status: ",
                        "dumping all alloc'ed. fragments:\n");
        for (f=qm->first_frag, 
i=0;(char*)f<(char*)qm->last_frag_end;f=FRAG_NEXT(f)


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to