Browse code

core: mem dbg options updates + cleanups

- memlog and memdbg can now be changed at runtime
- double define warning fix for fm_malloc (when compiled with -DF_MALLOC)
- nicer qm_status() & qm_sums() output
- BSD licence for mem/*

Andrei Pelinescu-Onciul authored on 29/09/2009 13:25:50
Showing 18 changed files
... ...
@@ -860,9 +860,9 @@ assign_stm:
860 860
 	| PHONE2TEL EQUAL error { yyerror("boolean value expected"); }
861 861
 	| SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
862 862
 	| SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
863
-	| MEMLOG EQUAL intno { memlog=$3; }
863
+	| MEMLOG EQUAL intno { default_core_cfg.memlog=$3; }
864 864
 	| MEMLOG EQUAL error { yyerror("int value expected"); }
865
-	| MEMDBG EQUAL intno { memdbg=$3; }
865
+	| MEMDBG EQUAL intno { default_core_cfg.memdbg=$3; }
866 866
 	| MEMDBG EQUAL error { yyerror("int value expected"); }
867 867
 	| MEMSUM EQUAL intno { default_core_cfg.mem_summary=$3; }
868 868
 	| MEMSUM EQUAL error { yyerror("int value expected"); }
... ...
@@ -48,6 +48,7 @@
48 48
 struct cfg_group_core default_core_cfg = {
49 49
 	L_WARN, 	/*  print only msg. < L_WARN */
50 50
 	LOG_DAEMON,	/* log_facility -- see syslog(3) */
51
+	L_DBG,  /* memdbg */
51 52
 #ifdef USE_DST_BLACKLIST
52 53
 	/* blacklist */
53 54
 	0, /* dst blacklist is disabled by default */
... ...
@@ -93,6 +94,7 @@ struct cfg_group_core default_core_cfg = {
93 93
 	0, /* udp_mtu (disabled by default) */
94 94
 	0, /* udp_mtu_try_proto -> default disabled */
95 95
 	0,  /* force_rport */
96
+	L_DBG, /* memlog */
96 97
 	1 /* mem_summary -flags: 0 off, 1 shm/pkg_status, 2 shm/pkg_sums */
97 98
 };
98 99
 
... ...
@@ -103,6 +105,8 @@ cfg_def_t core_cfg_def[] = {
103 103
 		"debug level"},
104 104
 	{"log_facility",	CFG_VAR_INT|CFG_INPUT_STRING,	0, 0, log_facility_fixup, 0,
105 105
 		"syslog facility, see \"man 3 syslog\""},
106
+	{"memdbg",		CFG_VAR_INT|CFG_ATOMIC,	0, 0, 0, 0,
107
+		"log level for memory debugging messages"},
106 108
 #ifdef USE_DST_BLACKLIST
107 109
 	/* blacklist */
108 110
 	{"use_dst_blacklist",	CFG_VAR_INT,	0, 1, use_dst_blacklist_fixup, 0,
... ...
@@ -192,8 +196,11 @@ cfg_def_t core_cfg_def[] = {
192 192
 		"if send size > udp_mtu use proto (1 udp, 2 tcp, 3 tls, 4 sctp)"},
193 193
 	{"force_rport",     CFG_VAR_INT, 0, 1,  0, fix_global_req_flags,
194 194
 		"force rport for all the received messages" },
195
+	{"memlog",		CFG_VAR_INT|CFG_ATOMIC,	0, 0, 0, 0,
196
+		"log level for memory status/summary information"},
195 197
 	{"mem_summary",	CFG_VAR_INT|CFG_ATOMIC,	0, 3, 0, 0,
196 198
 		"memory debugging information displayed on exit (flags): "
197
-		" 0 - off, 1 - dump all used blocks, 2 - summary of used blocks" },
199
+		" 0 - off, 1 - dump all the used blocks (status),"
200
+		" 2 - summary of used blocks" },
198 201
 	{0, 0, 0, 0, 0, 0}
199 202
 };
... ...
@@ -47,6 +47,7 @@ extern void	*core_cfg;
47 47
 struct cfg_group_core {
48 48
 	int	debug;
49 49
 	int	log_facility;
50
+	int memdbg; /** < log level for memory debugging messages */
50 51
 #ifdef USE_DST_BLACKLIST
51 52
 	/* blacklist */
52 53
 	int	use_dst_blacklist; /* 1 if blacklist is enabled */
... ...
@@ -89,6 +90,7 @@ struct cfg_group_core {
89 89
 	int udp_mtu; /**< maximum send size for udp, if > try another protocol*/
90 90
 	int udp_mtu_try_proto; /**< if packet> udp_mtu, try proto (e.g. TCP) */
91 91
 	int force_rport; /**< if set rport will always be forced*/
92
+	int memlog; /** < log level for memory status/summary info */
92 93
 	int mem_summary; /**< display memory status/summary info on exit */
93 94
 };
94 95
 
... ...
@@ -331,10 +331,6 @@ int check_via =  0;
331 331
 int phone2tel = 1;
332 332
 /* shall use stateful synonym branches? faster but not reboot-safe */
333 333
 int syn_branch = 1;
334
-/* debugging level for memory stats */
335
-int memlog = L_DBG;
336
-/* debugging level for the malloc debug messages */
337
-int memdbg = L_DBG;
338 334
 /* debugging level for timer debugging */
339 335
 int timerlog = L_WARN;
340 336
 /* should replies include extensive warnings? by default yes,
... ...
@@ -494,6 +490,8 @@ char* pgid_file = 0;
494 494
 /* call it before exiting; if show_status==1, mem status is displayed */
495 495
 void cleanup(show_status)
496 496
 {
497
+	int memlog;
498
+	
497 499
 	/*clean-up*/
498 500
 #ifndef SHM_SAFE_MALLOC
499 501
 	if (mem_lock)
... ...
@@ -528,6 +526,7 @@ void cleanup(show_status)
528 528
 	destroy_nonsip_hooks();
529 529
 	destroy_routes();
530 530
 	destroy_atomic_ops();
531
+	memlog=cfg_get(core, core_cfg, memlog);
531 532
 #ifdef PKG_MALLOC
532 533
 	if (show_status && memlog <= cfg_get(core, core_cfg, debug)){
533 534
 		if (cfg_get(core, core_cfg, mem_summary) & 1) {
... ...
@@ -645,6 +644,7 @@ void handle_sigs()
645 645
 {
646 646
 	pid_t	chld;
647 647
 	int	chld_status;
648
+	int memlog;
648 649
 
649 650
 	switch(sig_flag){
650 651
 		case 0: break; /* do nothing*/
... ...
@@ -671,6 +671,7 @@ void handle_sigs()
671 671
 #ifdef STATS
672 672
 			dump_all_statistic();
673 673
 #endif
674
+		memlog=cfg_get(core, core_cfg, memlog);
674 675
 #ifdef PKG_MALLOC
675 676
 		if (memlog <= cfg_get(core, core_cfg, debug)){
676 677
 			if (cfg_get(core, core_cfg, mem_summary) & 1) {
... ...
@@ -748,6 +749,9 @@ void handle_sigs()
748 748
 void sig_usr(int signo)
749 749
 {
750 750
 
751
+#ifdef PKG_MALLOC
752
+	int memlog;
753
+#endif
751 754
 
752 755
 	if (is_main){
753 756
 		if (sig_flag==0) sig_flag=signo;
... ...
@@ -771,6 +775,7 @@ void sig_usr(int signo)
771 771
 					LOG(L_INFO, "INFO: signal %d received\n", signo);
772 772
 					/* print memory stats for non-main too */
773 773
 					#ifdef PKG_MALLOC
774
+					memlog=cfg_get(core, core_cfg, memlog);
774 775
 					if (memlog <= cfg_get(core, core_cfg, debug)){
775 776
 						if (cfg_get(core, core_cfg, mem_summary) & 1) {
776 777
 							LOG(memlog, "Memory status (pkg):\n");
... ...
@@ -3,26 +3,19 @@
3 3
  *
4 4
  * Copyright (C) 2001-2003 FhG Fokus
5 5
  *
6
- * This file is part of ser, a free SIP server.
6
+ * This file is part of sip-router, a free SIP server.
7 7
  *
8
- * ser is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version
8
+ * Permission to use, copy, modify, and distribute this software for any
9
+ * purpose with or without fee is hereby granted, provided that the above
10
+ * copyright notice and this permission notice appear in all copies.
12 11
  *
13
- * For a license to use the ser software under conditions
14
- * other than those described here, or to purchase support for this
15
- * software, please contact iptel.org by e-mail at the following addresses:
16
- *    info@iptel.org
17
- *
18
- * ser is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
- * GNU General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU General Public License 
24
- * along with this program; if not, write to the Free Software 
25
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
12
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26 19
  */
27 20
 /*
28 21
  * History:
... ...
@@ -55,6 +48,7 @@
55 55
 #include "../compiler_opt.h"
56 56
 #include "memdbg.h"
57 57
 #include "../bit_scan.h"
58
+#include "../cfg/cfg.h" /* memlog */
58 59
 
59 60
 
60 61
 /*useful macros*/
... ...
@@ -586,7 +580,9 @@ void fm_status(struct fm_block* qm)
586 586
 	int h;
587 587
 	int unused;
588 588
 	unsigned long size;
589
+	int memlog;
589 590
 
591
+	memlog=cfg_get(core, core_cfg, memlog);
590 592
 	LOG(memlog, "fm_status (%p):\n", qm);
591 593
 	if (!qm) return;
592 594
 
... ...
@@ -753,11 +749,13 @@ void fm_sums(struct fm_block* qm)
753 753
 	struct fm_frag* f;
754 754
 	struct fm_frag* free_frag;
755 755
 	int i, hash;
756
+	int memlog;
756 757
 	mem_counter *root,*x;
757 758
 	
758 759
 	root=0;
759 760
 	if (!qm) return;
760 761
 
762
+	memlog=cfg_get(core, core_cfg, memlog);
761 763
 	LOG(memlog, "summarizing all alloc'ed. fragments:\n");
762 764
 	
763 765
 	for (f=qm->first_frag, i=0; (char*)f<(char*)qm->last_frag;
... ...
@@ -4,26 +4,19 @@
4 4
  *
5 5
  * Copyright (C) 2001-2003 FhG Fokus
6 6
  *
7
- * This file is part of ser, a free SIP server.
7
+ * This file is part of sip-router, a free SIP server.
8 8
  *
9
- * ser is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version
9
+ * Permission to use, copy, modify, and distribute this software for any
10
+ * purpose with or without fee is hereby granted, provided that the above
11
+ * copyright notice and this permission notice appear in all copies.
13 12
  *
14
- * For a license to use the ser software under conditions
15
- * other than those described here, or to purchase support for this
16
- * software, please contact iptel.org by e-mail at the following addresses:
17
- *    info@iptel.org
18
- *
19
- * ser is distributed in the hope that it will be useful,
20
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
- * GNU General Public License for more details.
23
- *
24
- * You should have received a copy of the GNU General Public License 
25
- * along with this program; if not, write to the Free Software 
26
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
13
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 20
  */
28 21
 /*
29 22
  * History:
... ...
@@ -41,8 +34,10 @@
41 41
 #define f_malloc_h
42 42
 
43 43
 #ifdef DBG_QM_MALLOC
44
-#define DBG_F_MALLOC
45
-#endif
44
+#ifndef DBG_F_MALLOC
45
+	#define DBG_F_MALLOC
46
+#endif /* DBG_F_MALLOC */
47
+#endif /* DBG_QM_MALLOC */
46 48
 
47 49
 #include "meminfo.h"
48 50
 
... ...
@@ -46,6 +46,7 @@
46 46
 #include "../dprint.h"
47 47
 #include "../globals.h"
48 48
 #include "memdbg.h"
49
+#include "../cfg/cfg.h" /* memlog */
49 50
 
50 51
 #define MAX_POOL_FRAGS 10000 /* max fragments per pool hash bucket */
51 52
 #define MIN_POOL_FRAGS 10    /* min fragments per pool hash bucket */
... ...
@@ -969,9 +970,11 @@ void sfm_status(struct sfm_block* qm)
969 969
 	int unused;
970 970
 	unsigned long size;
971 971
 	int k;
972
+	int memlog;
972 973
 
973 974
 #warning "ll_status doesn't work (might crash if used)"
974 975
 
976
+	memlog=cfg_get(core, core_cfg, memlog);
975 977
 	LOG(memlog, "sfm_status (%p):\n", qm);
976 978
 	if (!qm) return;
977 979
 
... ...
@@ -3,26 +3,19 @@
3 3
  *
4 4
  * Copyright (C) 2001-2003 FhG Fokus
5 5
  *
6
- * This file is part of ser, a free SIP server.
6
+ * This file is part of sip-router, a free SIP server.
7 7
  *
8
- * ser is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version
8
+ * Permission to use, copy, modify, and distribute this software for any
9
+ * purpose with or without fee is hereby granted, provided that the above
10
+ * copyright notice and this permission notice appear in all copies.
12 11
  *
13
- * For a license to use the ser software under conditions
14
- * other than those described here, or to purchase support for this
15
- * software, please contact iptel.org by e-mail at the following addresses:
16
- *    info@iptel.org
17
- *
18
- * ser is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
- * GNU General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU General Public License 
24
- * along with this program; if not, write to the Free Software 
25
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
12
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26 19
  *
27 20
  *
28 21
  * History:
... ...
@@ -5,26 +5,19 @@
5 5
  *
6 6
  * Copyright (C) 2001-2003 FhG Fokus
7 7
  *
8
- * This file is part of ser, a free SIP server.
8
+ * This file is part of sip-router, a free SIP server.
9 9
  *
10
- * ser is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version
10
+ * Permission to use, copy, modify, and distribute this software for any
11
+ * purpose with or without fee is hereby granted, provided that the above
12
+ * copyright notice and this permission notice appear in all copies.
14 13
  *
15
- * For a license to use the ser software under conditions
16
- * other than those described here, or to purchase support for this
17
- * software, please contact iptel.org by e-mail at the following addresses:
18
- *    info@iptel.org
19
- *
20
- * ser is distributed in the hope that it will be useful,
21
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
- * GNU General Public License for more details.
24
- *
25
- * You should have received a copy of the GNU General Public License 
26
- * along with this program; if not, write to the Free Software 
27
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
14
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
28 21
  */
29 22
 /*
30 23
  * History:
... ...
@@ -25,6 +25,8 @@
25 25
 #ifndef _memdbg_h
26 26
 #define _memdbg_h
27 27
 
28
+#include "../cfg/cfg.h" /* memdbg*/
29
+
28 30
 extern int memdbg;
29 31
 
30 32
 #ifdef NO_DEBUG
... ...
@@ -35,9 +37,10 @@ extern int memdbg;
35 35
 	#endif
36 36
 #else /* NO_DEBUG */
37 37
 	#ifdef __SUNPRO_C
38
-		#define MDBG(...) LOG(memdbg, __VA_ARGS__)
38
+		#define MDBG(...) LOG(cfg_get(core, core_cfg, memdbg), __VA_ARGS__)
39 39
 	#else
40
-		#define MDBG(fmt, args...) LOG(memdbg, fmt,  ## args)
40
+		#define MDBG(fmt, args...) \
41
+			LOG(cfg_get(core, core_cfg, memdbg), fmt,  ## args)
41 42
 	#endif
42 43
 #endif /* NO_DEBUG */
43 44
 
... ...
@@ -4,26 +4,19 @@
4 4
  *
5 5
  * Copyright (C) 2001-2003 FhG Fokus
6 6
  *
7
- * This file is part of ser, a free SIP server.
7
+ * This file is part of sip-router, a free SIP server.
8 8
  *
9
- * ser is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version
9
+ * Permission to use, copy, modify, and distribute this software for any
10
+ * purpose with or without fee is hereby granted, provided that the above
11
+ * copyright notice and this permission notice appear in all copies.
13 12
  *
14
- * For a license to use the ser software under conditions
15
- * other than those described here, or to purchase support for this
16
- * software, please contact iptel.org by e-mail at the following addresses:
17
- *    info@iptel.org
18
- *
19
- * ser is distributed in the hope that it will be useful,
20
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
- * GNU General Public License for more details.
23
- *
24
- * You should have received a copy of the GNU General Public License 
25
- * along with this program; if not, write to the Free Software 
26
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
13
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 20
  */
28 21
 /*
29 22
  * History:
... ...
@@ -3,26 +3,19 @@
3 3
  *
4 4
  * Copyright (C) 2001-2003 FhG Fokus
5 5
  *
6
- * This file is part of ser, a free SIP server.
6
+ * This file is part of sip-router, a free SIP server.
7 7
  *
8
- * ser is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version
8
+ * Permission to use, copy, modify, and distribute this software for any
9
+ * purpose with or without fee is hereby granted, provided that the above
10
+ * copyright notice and this permission notice appear in all copies.
12 11
  *
13
- * For a license to use the ser software under conditions
14
- * other than those described here, or to purchase support for this
15
- * software, please contact iptel.org by e-mail at the following addresses:
16
- *    info@iptel.org
17
- *
18
- * ser is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
- * GNU General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU General Public License 
24
- * along with this program; if not, write to the Free Software 
25
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
12
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26 19
  */
27 20
 
28 21
 
... ...
@@ -3,26 +3,19 @@
3 3
  *
4 4
  * Copyright (C) 2001-2003 FhG Fokus
5 5
  *
6
- * This file is part of ser, a free SIP server.
6
+ * This file is part of sip-router, a free SIP server.
7 7
  *
8
- * ser is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version
8
+ * Permission to use, copy, modify, and distribute this software for any
9
+ * purpose with or without fee is hereby granted, provided that the above
10
+ * copyright notice and this permission notice appear in all copies.
12 11
  *
13
- * For a license to use the ser software under conditions
14
- * other than those described here, or to purchase support for this
15
- * software, please contact iptel.org by e-mail at the following addresses:
16
- *    info@iptel.org
17
- *
18
- * ser is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
- * GNU General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU General Public License 
24
- * along with this program; if not, write to the Free Software 
25
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
12
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26 19
  */
27 20
 /*
28 21
  * History:
... ...
@@ -54,6 +47,7 @@
54 54
 #include "../dprint.h"
55 55
 #include "../globals.h"
56 56
 #include "memdbg.h"
57
+#include "../cfg/cfg.h" /* memlog */
57 58
 
58 59
 
59 60
 /*useful macros*/
... ...
@@ -637,7 +631,9 @@ void qm_check(struct qm_block* qm)
637 637
 {
638 638
 	struct qm_frag* f;
639 639
 	long fcount = 0;
640
+	int memlog;
640 641
 	
642
+	memlog=cfg_get(core, core_cfg, memlog);
641 643
 	LOG(memlog, "DEBUG: qm_check()\n");
642 644
 	f = qm->first_frag;
643 645
 	while ((char*)f < (char*)qm->last_frag_end) {
... ...
@@ -693,32 +689,43 @@ void qm_status(struct qm_block* qm)
693 693
 	int i,j;
694 694
 	int h;
695 695
 	int unused;
696
+	int memlog;
697
+
696 698
 
697
-	LOG(memlog, "qm_status (%p):\n", qm);
699
+	memlog=cfg_get(core, core_cfg, memlog);
700
+	LOG_(DEFAULT_FACILITY, memlog, "qm_status: ", "(%p):\n", qm);
698 701
 	if (!qm) return;
699 702
 
700
-	LOG(memlog, " heap size= %lu\n", qm->size);
701
-	LOG(memlog, " used= %lu, used+overhead=%lu, free=%lu\n",
703
+	LOG_(DEFAULT_FACILITY, memlog, "qm_status: ", "heap size= %lu\n",
704
+			qm->size);
705
+	LOG_(DEFAULT_FACILITY, memlog, "qm_status: ",
706
+			"used= %lu, used+overhead=%lu, free=%lu\n",
702 707
 			qm->used, qm->real_used, qm->size-qm->real_used);
703
-	LOG(memlog, " max used (+overhead)= %lu\n", qm->max_real_used);
708
+	LOG_(DEFAULT_FACILITY, memlog, "qm_status: ",
709
+			"max used (+overhead)= %lu\n", qm->max_real_used);
704 710
 	
705
-	LOG(memlog, "dumping all alloc'ed. fragments:\n");
711
+	LOG_(DEFAULT_FACILITY, memlog, "qm_status: ",
712
+			"dumping all alloc'ed. fragments:\n");
706 713
 	for (f=qm->first_frag, i=0;(char*)f<(char*)qm->last_frag_end;f=FRAG_NEXT(f)
707 714
 			,i++){
708 715
 		if (! f->u.is_free){
709
-			LOG(memlog, "    %3d. %c  address=%p frag=%p size=%lu used=%d\n",
710
-				i, 
716
+			LOG_(DEFAULT_FACILITY, memlog, "qm_status: ",
717
+					"   %3d. %c  address=%p frag=%p size=%lu used=%d\n",
718
+				i,
711 719
 				(f->u.is_free)?'a':'N',
712 720
 				(char*)f+sizeof(struct qm_frag), f, f->size, FRAG_WAS_USED(f));
713 721
 #ifdef DBG_QM_MALLOC
714
-			LOG(memlog, "            %s from %s: %s(%ld)\n",
722
+			LOG_(DEFAULT_FACILITY, memlog, "qm_status: ",
723
+					"          %s from %s: %s(%ld)\n",
715 724
 				(f->u.is_free)?"freed":"alloc'd", f->file, f->func, f->line);
716
-			LOG(memlog, "        start check=%lx, end check= %lx, %lx\n",
725
+			LOG_(DEFAULT_FACILITY, memlog, "qm_status: ",
726
+					"         start check=%lx, end check= %lx, %lx\n",
717 727
 				f->check, FRAG_END(f)->check1, FRAG_END(f)->check2);
718 728
 #endif
719 729
 		}
720 730
 	}
721
-	LOG(memlog, "dumping free list stats :\n");
731
+	LOG_(DEFAULT_FACILITY, memlog, "qm_status: ",
732
+			"dumping free list stats :\n");
722 733
 	for(h=0,i=0;h<QM_HASH_SIZE;h++){
723 734
 		unused=0;
724 735
 		for (f=qm->free_hash[h].head.u.nxt_free,j=0; 
... ...
@@ -726,7 +733,8 @@ void qm_status(struct qm_block* qm)
726 726
 				if (!FRAG_WAS_USED(f)){
727 727
 					unused++;
728 728
 #ifdef DBG_QM_MALLOC
729
-					LOG(memlog, "unused fragm.: hash = %3d, fragment %p,"
729
+					LOG_(DEFAULT_FACILITY, memlog, "qm_status: ",
730
+						"unused fragm.: hash = %3d, fragment %p,"
730 731
 						" address %p size %lu, created from %s: %s(%lu)\n",
731 732
 					    h, f, (char*)f+sizeof(struct qm_frag), f->size,
732 733
 						f->file, f->func, f->line);
... ...
@@ -734,7 +742,8 @@ void qm_status(struct qm_block* qm)
734 734
 				}
735 735
 		}
736 736
 
737
-		if (j) LOG(memlog, "hash= %3d. fragments no.: %5d, unused: %5d\n"
737
+		if (j) LOG_(DEFAULT_FACILITY, memlog, "qm_status: ",
738
+				"hash= %3d. fragments no.: %5d, unused: %5d\n"
738 739
 					"\t\t bucket size: %9lu - %9ld (first %9lu)\n",
739 740
 					h, j, unused, UN_HASH(h),
740 741
 					((h<=QM_MALLOC_OPTIMIZE/ROUNDTO)?1:2)*UN_HASH(h),
... ...
@@ -746,7 +755,8 @@ void qm_status(struct qm_block* qm)
746 746
 		}
747 747
 
748 748
 	}
749
-	LOG(memlog, "-----------------------------\n");
749
+	LOG_(DEFAULT_FACILITY, memlog, "qm_status: ",
750
+			"-----------------------------\n");
750 751
 }
751 752
 
752 753
 
... ...
@@ -820,11 +830,14 @@ void qm_sums(struct qm_block* qm)
820 820
 	struct qm_frag* f;
821 821
 	int i;
822 822
 	mem_counter *root, *x;
823
+	int memlog;
823 824
 	
824 825
 	root=0;
825 826
 	if (!qm) return;
826 827
 	
827
-	LOG(memlog, "summarizing all alloc'ed. fragments:\n");
828
+	memlog=cfg_get(core, core_cfg, memlog);
829
+	LOG_(DEFAULT_FACILITY, memlog, "qm_sums: ",
830
+			"summarizing all alloc'ed. fragments:\n");
828 831
 	
829 832
 	for (f=qm->first_frag, i=0;(char*)f<(char*)qm->last_frag_end;
830 833
 			f=FRAG_NEXT(f),i++){
... ...
@@ -836,7 +849,8 @@ void qm_sums(struct qm_block* qm)
836 836
 	}
837 837
 	x = root;
838 838
 	while(x){
839
-		LOG(memlog, " count=%6d size=%10lu bytes from %s: %s(%ld)\n",
839
+		LOG_(DEFAULT_FACILITY, memlog, "qm_sums: ",
840
+				" count=%6d size=%10lu bytes from %s: %s(%ld)\n",
840 841
 			x->count,x->size,
841 842
 			x->file, x->func, x->line
842 843
 			);
... ...
@@ -844,7 +858,8 @@ void qm_sums(struct qm_block* qm)
844 844
 		free(x);
845 845
 		x = root;
846 846
 	}
847
-	LOG(memlog, "-----------------------------\n");
847
+	LOG_(DEFAULT_FACILITY, memlog, "qm_sums: ",
848
+			"-----------------------------\n");
848 849
 }
849 850
 #endif /* DBG_QM_MALLOC */
850 851
 
... ...
@@ -4,26 +4,19 @@
4 4
  *
5 5
  * Copyright (C) 2001-2003 FhG Fokus
6 6
  *
7
- * This file is part of ser, a free SIP server.
7
+ * This file is part of sip-router, a free SIP server.
8 8
  *
9
- * ser is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version
9
+ * Permission to use, copy, modify, and distribute this software for any
10
+ * purpose with or without fee is hereby granted, provided that the above
11
+ * copyright notice and this permission notice appear in all copies.
13 12
  *
14
- * For a license to use the ser software under conditions
15
- * other than those described here, or to purchase support for this
16
- * software, please contact iptel.org by e-mail at the following addresses:
17
- *    info@iptel.org
18
- *
19
- * ser is distributed in the hope that it will be useful,
20
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
- * GNU General Public License for more details.
23
- *
24
- * You should have received a copy of the GNU General Public License 
25
- * along with this program; if not, write to the Free Software 
26
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
13
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 20
  */
28 21
 /*
29 22
  * History:
... ...
@@ -44,6 +44,7 @@
44 44
 #include "../dprint.h"
45 45
 #include "../globals.h"
46 46
 #include "memdbg.h"
47
+#include "../cfg/cfg.h" /* memlog */
47 48
 
48 49
 #define MAX_POOL_FRAGS 10000 /* max fragments per pool hash bucket */
49 50
 #define MIN_POOL_FRAGS 10    /* min fragments per pool hash bucket */
... ...
@@ -990,7 +991,9 @@ void sfm_status(struct sfm_block* qm)
990 990
 	int unused;
991 991
 	unsigned long size;
992 992
 	int k;
993
+	int memlog;
993 994
 
995
+	memlog=cfg_get(core, core_cfg, memlog);
994 996
 	LOG(memlog, "sfm_status (%p):\n", qm);
995 997
 	if (!qm) return;
996 998
 
... ...
@@ -4,26 +4,19 @@
4 4
  *
5 5
  * Copyright (C) 2001-2003 FhG Fokus
6 6
  *
7
- * This file is part of ser, a free SIP server.
7
+ * This file is part of sip-router, a free SIP server.
8 8
  *
9
- * ser is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version
9
+ * Permission to use, copy, modify, and distribute this software for any
10
+ * purpose with or without fee is hereby granted, provided that the above
11
+ * copyright notice and this permission notice appear in all copies.
13 12
  *
14
- * For a license to use the ser software under conditions
15
- * other than those described here, or to purchase support for this
16
- * software, please contact iptel.org by e-mail at the following addresses:
17
- *    info@iptel.org
18
- *
19
- * ser is distributed in the hope that it will be useful,
20
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
- * GNU General Public License for more details.
23
- *
24
- * You should have received a copy of the GNU General Public License 
25
- * along with this program; if not, write to the Free Software 
26
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
13
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 20
  */
28 21
 /*
29 22
  * History:
... ...
@@ -4,26 +4,19 @@
4 4
  *
5 5
  * Copyright (C) 2001-2003 FhG Fokus
6 6
  *
7
- * This file is part of ser, a free SIP server.
7
+ * This file is part of sip-router, a free SIP server.
8 8
  *
9
- * ser is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version
9
+ * Permission to use, copy, modify, and distribute this software for any
10
+ * purpose with or without fee is hereby granted, provided that the above
11
+ * copyright notice and this permission notice appear in all copies.
13 12
  *
14
- * For a license to use the ser software under conditions
15
- * other than those described here, or to purchase support for this
16
- * software, please contact iptel.org by e-mail at the following addresses:
17
- *    info@iptel.org
18
- *
19
- * ser is distributed in the hope that it will be useful,
20
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
- * GNU General Public License for more details.
23
- *
24
- * You should have received a copy of the GNU General Public License 
25
- * along with this program; if not, write to the Free Software 
26
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
13
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 20
  */
28 21
 /*
29 22
  * History:
... ...
@@ -525,17 +525,21 @@ end:
525 525
 void mem_dump_pkg_cb(str *gname, str *name)
526 526
 {
527 527
 	int	old_memlog;
528
+	int memlog;
528 529
 
529 530
 	if (cfg_get(core, core_cfg, mem_dump_pkg) == my_pid()) {
530 531
 		/* set memlog to ALERT level to force
531 532
 		printing the log messages */
532
-		old_memlog = memlog;
533
+		old_memlog = cfg_get(core, core_cfg, memlog);
533 534
 		memlog = L_ALERT;
535
+		/* ugly hack to temporarily switch memlog to something visible,
536
+		   possible race with a parallel cfg_set */
537
+		((struct cfg_group_core*)core_cfg)->memlog=memlog;
534 538
 
535 539
 		LOG(memlog, "Memory status (pkg) of process %d:\n", my_pid());
536 540
 		pkg_status();
537 541
 
538
-		memlog = old_memlog;
542
+		((struct cfg_group_core*)core_cfg)->memlog=old_memlog;
539 543
 	}
540 544
 }
541 545
 #endif
... ...
@@ -548,17 +552,21 @@ void mem_dump_pkg_cb(str *gname, str *name)
548 548
 int mem_dump_shm_fixup(void *handle, str *gname, str *name, void **val)
549 549
 {
550 550
 	int	old_memlog;
551
+	int memlog;
551 552
 
552 553
 	if ((long)(void*)(*val)) {
553 554
 		/* set memlog to ALERT level to force
554 555
 		printing the log messages */
555
-		old_memlog = memlog;
556
+		old_memlog = cfg_get(core, core_cfg, memlog);
556 557
 		memlog = L_ALERT;
558
+		/* ugly hack to temporarily switch memlog to something visible,
559
+		   possible race with a parallel cfg_set */
560
+		((struct cfg_group_core*)core_cfg)->memlog=memlog;
557 561
 
558 562
 		LOG(memlog, "Memory status (shm)\n");
559 563
 		shm_status();
560 564
 
561
-		memlog = old_memlog;
565
+		((struct cfg_group_core*)core_cfg)->memlog=old_memlog;
562 566
 		*val = (void*)(long)0;
563 567
 	}
564 568
 	return 0;