[sr-dev] git:master:8e2d45cb: core: added mem_status_mode parameter

Daniel-Constantin Mierla miconda at gmail.com
Mon Jul 11 16:03:57 CEST 2016


Module: kamailio
Branch: master
Commit: 8e2d45cb1cd71ec81852a5c0e329c9b3e9d141c5
URL: https://github.com/kamailio/kamailio/commit/8e2d45cb1cd71ec81852a5c0e329c9b3e9d141c5

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2016-07-11T16:03:07+02:00

core: added mem_status_mode parameter

- if set to 1, qm allocator dumps used fragments in memory status

---

Modified: cfg.lex
Modified: cfg.y
Modified: cfg_core.c
Modified: cfg_core.h
Modified: mem/q_malloc.c

---

Diff:  https://github.com/kamailio/kamailio/commit/8e2d45cb1cd71ec81852a5c0e329c9b3e9d141c5.diff
Patch: https://github.com/kamailio/kamailio/commit/8e2d45cb1cd71ec81852a5c0e329c9b3e9d141c5.patch

---

diff --git a/cfg.lex b/cfg.lex
index 3783c00..731d00e 100644
--- a/cfg.lex
+++ b/cfg.lex
@@ -353,6 +353,7 @@ MEMDBG		"memdbg"|"mem_dbg"
 MEMSUM		"mem_summary"
 MEMSAFETY	"mem_safety"
 MEMJOIN		"mem_join"
+MEMSTATUSMODE		"mem_status_mode"
 CORELOG		"corelog"|"core_log"
 SIP_WARNING sip_warning
 SERVER_SIGNATURE server_signature
@@ -770,6 +771,7 @@ IMPORTFILE      "import_file"
 <INITIAL>{MEMSUM}	{ count(); yylval.strval=yytext; return MEMSUM; }
 <INITIAL>{MEMSAFETY}	{ count(); yylval.strval=yytext; return MEMSAFETY; }
 <INITIAL>{MEMJOIN}	{ count(); yylval.strval=yytext; return MEMJOIN; }
+<INITIAL>{MEMSTATUSMODE}	{ count(); yylval.strval=yytext; return MEMSTATUSMODE; }
 <INITIAL>{CORELOG}	{ count(); yylval.strval=yytext; return CORELOG; }
 <INITIAL>{SIP_WARNING}	{ count(); yylval.strval=yytext; return SIP_WARNING; }
 <INITIAL>{USER}		{ count(); yylval.strval=yytext; return USER; }
diff --git a/cfg.y b/cfg.y
index 9f25173..0820970 100644
--- a/cfg.y
+++ b/cfg.y
@@ -382,6 +382,7 @@ extern char *default_routename;
 %token MEMSUM
 %token MEMSAFETY
 %token MEMJOIN
+%token MEMSTATUSMODE
 %token CORELOG
 %token SIP_WARNING
 %token SERVER_SIGNATURE
@@ -907,6 +908,8 @@ assign_stm:
 	| MEMSAFETY EQUAL error { yyerror("int value expected"); }
 	| MEMJOIN EQUAL intno { default_core_cfg.mem_join=$3; }
 	| MEMJOIN EQUAL error { yyerror("int value expected"); }
+	| MEMSTATUSMODE EQUAL intno { default_core_cfg.mem_status_mode=$3; }
+	| MEMSTATUSMODE EQUAL error { yyerror("int value expected"); }
 	| CORELOG EQUAL intno { default_core_cfg.corelog=$3; }
 	| CORELOG EQUAL error { yyerror("int value expected"); }
 	| SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
diff --git a/cfg_core.c b/cfg_core.c
index cd65c3a..5f7f2d7 100644
--- a/cfg_core.c
+++ b/cfg_core.c
@@ -115,7 +115,7 @@ struct cfg_group_core default_core_cfg = {
 		4 pkg_sums, 8 shm_sums, 16 short_status */
 	0, /*!< mem_safety - 0 disabled */
 	0, /*!< mem_join - 0 disabled */
-	0, /*!< mem_status_all - 0 only free fragments, 1 all fragements */
+	0, /*!< mem_status_mode - 0 only free fragments, 1 all fragements */
 	L_ERR, /*!< corelog */
 	L_DBG, /*!< latency cfg log */
 	L_ERR, /*!< latency log */
@@ -314,7 +314,7 @@ cfg_def_t core_cfg_def[] = {
 		"safety level for memory operations"},
 	{"mem_join",		CFG_VAR_INT|CFG_ATOMIC,	0, 0, 0, 0,
 		"join free memory fragments"},
-	{"mem_status_all",		CFG_VAR_INT|CFG_ATOMIC,	0, 0, 0, 0,
+	{"mem_status_mode",		CFG_VAR_INT|CFG_ATOMIC,	0, 0, 0, 0,
 		"print status for free or all memory fragments"},
 	{"corelog",		CFG_VAR_INT|CFG_ATOMIC,	0, 0, 0, 0,
 		"log level for non-critical core error messages"},
diff --git a/cfg_core.h b/cfg_core.h
index 0487b35..3a96f47 100644
--- a/cfg_core.h
+++ b/cfg_core.h
@@ -103,7 +103,7 @@ struct cfg_group_core {
 	int mem_summary; /*!< display memory status/summary info on exit */
 	int mem_safety; /*!< memory safety control option */
 	int mem_join; /*!< memory free fragments join option */
-	int mem_status_all; /*!< memory status printed for free/all fragments */
+	int mem_status_mode; /*!< memory status printed for free/all fragments */
 	int corelog; /*!< log level for non-critcal core error messages */
 	int latency_cfg_log; /*!< log level for printing latency of routing blocks */
 	int latency_log; /*!< log level for latency limits messages */
diff --git a/mem/q_malloc.c b/mem/q_malloc.c
index 8918411..0c24ef2 100644
--- a/mem/q_malloc.c
+++ b/mem/q_malloc.c
@@ -793,7 +793,7 @@ void qm_status(void* qmp)
 			"dumping all alloc'ed. fragments:\n");
 	for (f=qm->first_frag, i=0;(char*)f<(char*)qm->last_frag_end;f=FRAG_NEXT(f)
 			,i++){
-		if ((! f->u.is_free) || (cfg_get(core, core_cfg, mem_status_all)!=0)){
+		if ((! f->u.is_free) || (cfg_get(core, core_cfg, mem_status_mode)!=0)){
 			LOG_(DEFAULT_FACILITY, memlog, "qm_status: ",
 					"   %3d. %c  address=%p frag=%p size=%lu used=%d\n",
 				i,




More information about the sr-dev mailing list