Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,255 +0,0 @@
1
-/*
2
- *
3
- * Copyright (C) 2001-2003 FhG Fokus
4
- *
5
- * This file is part of Kamailio, a free SIP server.
6
- *
7
- * Kamailio is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version
11
- *
12
- * Kamailio is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License 
18
- * along with this program; if not, write to the Free Software 
19
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
- */
21
-
22
-
23
-#include "defs.h"
24
-
25
-
26
-#include <stdio.h>
27
-#include "t_stats.h"
28
-#include "../../mem/shm_mem.h"
29
-#include "../../dprint.h"
30
-#include "../../config.h"
31
-#include "../../pt.h"
32
-#ifdef TM_HASH_STATS
33
-#include "h_table.h"
34
-#endif
35
-
36
-union t_stats *tm_stats=0;
37
-
38
-int init_tm_stats(void)
39
-{
40
-	     /* Delay initialization of tm_stats  to
41
-	      * init_tm_stats_child which gets called from child_init,
42
-	      * in mod_init function other modules can increase the value of
43
-	      * estimated_process_count and thus we do not know about processes created
44
-	      * from modules which get loaded after tm and thus their mod_init
45
-	      * functions will be called after tm mod_init function finishes
46
-	      */
47
-	return 0;
48
-}
49
-
50
-
51
-int init_tm_stats_child(void)
52
-{
53
-	int size;
54
-
55
-	/* We are called from child_init, estimated_process_count has definitive
56
-	 * value now and thus we can safely allocate the variables
57
-	 */
58
-	if (tm_stats==0){
59
-		size=sizeof(*tm_stats) * get_max_procs();
60
-		tm_stats=shm_malloc(size);
61
-		if (tm_stats == 0) {
62
-			ERR("No mem for stats\n");
63
-			goto error;
64
-		}
65
-		memset(tm_stats, 0, size);
66
-	}
67
-	
68
-	return 0;
69
-error:
70
-	return -1;
71
-}
72
-
73
-
74
-
75
-void free_tm_stats()
76
-{
77
-	if (tm_stats == 0) return;
78
-	shm_free(tm_stats);
79
-	tm_stats=0;
80
-}
81
-
82
-
83
-
84
-/* res=s1+s2 */
85
-#define tm_proc_stats_add_base(res, s1, s2) \
86
-	do{\
87
-		(res)->waiting=(s1)->waiting+(s2)->waiting; \
88
-		(res)->transactions=(s1)->transactions+(s2)->transactions; \
89
-		(res)->client_transactions=(s1)->client_transactions+\
90
-									(s2)->client_transactions; \
91
-		(res)->completed_3xx=(s1)->completed_3xx+(s2)->completed_3xx; \
92
-		(res)->completed_4xx=(s1)->completed_4xx+(s2)->completed_4xx; \
93
-		(res)->completed_5xx=(s1)->completed_5xx+(s2)->completed_5xx; \
94
-		(res)->completed_6xx=(s1)->completed_6xx+(s2)->completed_6xx; \
95
-		(res)->completed_2xx=(s1)->completed_2xx+(s2)->completed_2xx; \
96
-		(res)->rpl_received=(s1)->rpl_received+(s2)->rpl_received; \
97
-		(res)->rpl_generated=(s1)->rpl_generated+(s2)->rpl_generated; \
98
-		(res)->rpl_sent=(s1)->rpl_sent+(s2)->rpl_sent; \
99
-		(res)->deleted=(s1)->deleted+(s2)->deleted; \
100
-	}while(0)
101
-
102
-
103
-#ifdef TM_MORE_STATS
104
-#define tm_proc_stats_add(res, s1, s2) \
105
-	do{\
106
-		tm_proc_stats_add_base(res, s1, s2); \
107
-		(res)->t_created=(s1)->t_created+(s2)->t_created; \
108
-		(res)->t_freed=(s1)->t_freed+(s2)->t_freed; \
109
-		(res)->delayed_free=(s1)->delayed_free+(s2)->delayed_free; \
110
-	}while(0)
111
-#else
112
-#define tm_proc_stats_add(res, s1, s2) tm_proc_stats_add_base(res, s1, s2)
113
-#endif
114
-
115
-
116
-
117
-/* we don't worry about locking data during reads (unlike
118
- * setting values which always happens from some locks) 
119
- */
120
-void tm_rpc_stats(rpc_t* rpc, void* c)
121
-{
122
-	void* st;
123
-	unsigned long current, waiting;
124
-	struct t_proc_stats all;
125
-	int i, pno;
126
-
127
-	pno = get_max_procs();
128
-	memset(&all, 0, sizeof(all));
129
-	for(i = 0;i < pno; i++) {
130
-		tm_proc_stats_add(&all, &all, &tm_stats[i].s);
131
-	}
132
-	current = all.transactions - all.deleted;
133
-	waiting = all.waiting - all.deleted;
134
-
135
-	if (rpc->add(c, "{", &st) < 0) return;
136
-
137
-	rpc->struct_add(st, "dd", "current", (unsigned) current, "waiting",
138
-										 (unsigned) waiting);
139
-	rpc->struct_add(st, "d", "total", (unsigned) all.transactions);
140
-	rpc->struct_add(st, "d", "total_local", (unsigned)all.client_transactions);
141
-	rpc->struct_add(st, "d", "rpl_received", (unsigned)all.rpl_received);
142
-	rpc->struct_add(st, "d", "rpl_generated", (unsigned)all.rpl_generated);
143
-	rpc->struct_add(st, "d", "rpl_sent", (unsigned)all.rpl_sent);
144
-	rpc->struct_add(st, "ddddd", 
145
-			"6xx", (unsigned int)all.completed_6xx,
146
-			"5xx", (unsigned int)all.completed_5xx,
147
-			"4xx", (unsigned int)all.completed_4xx,
148
-			"3xx", (unsigned int)all.completed_3xx,
149
-			"2xx", (unsigned int)all.completed_2xx);
150
-#ifdef TM_MORE_STATS 
151
-	rpc->struct_add(st, "dd", "created", (unsigned int)all.t_created, "freed",
152
-						(unsigned int)all.t_freed);
153
-	rpc->struct_add(st, "d", "delayed_free", (unsigned int)all.delayed_free);
154
-#endif
155
-	/* rpc->fault(c, 100, "Trying"); */
156
-}
157
-
158
-int tm_get_stats(struct t_proc_stats *all)
159
-{
160
-	int i, pno;
161
-	if(all==NULL)
162
-		return -1;
163
-
164
-	pno = get_max_procs();
165
-	memset(all, 0, sizeof(struct t_proc_stats));
166
-	for(i = 0; i < pno; i++) {
167
-		tm_proc_stats_add(all, all, &tm_stats[i].s);
168
-	}
169
-	return 0;
170
-}
171
-
172
-
173
-/*  hash statistics */
174
-void tm_rpc_hash_stats(rpc_t* rpc, void* c)
175
-{
176
-#ifdef TM_HASH_STATS
177
-	void* st;
178
-	unsigned long acc_min, acc_max, acc_zeroes, acc_dev_no;
179
-	unsigned long crt_min, crt_max, crt_zeroes, crt_dev_no;
180
-	unsigned long crt_count, acc_count;
181
-	double acc_average, acc_dev, acc_d;
182
-	double crt_average, crt_dev, crt_d;
183
-	unsigned long acc, crt;
184
-	int r;
185
-	
186
-	acc_count=0;
187
-	acc_min=(unsigned long)(-1);
188
-	acc_max=0;
189
-	acc_zeroes=0;
190
-	acc_dev_no=0;
191
-	acc_dev=0;
192
-	crt_count=0;
193
-	crt_min=(unsigned long)(-1);
194
-	crt_max=0;
195
-	crt_zeroes=0;
196
-	crt_dev_no=0;
197
-	crt_dev=0;
198
-	for (r=0; r<TABLE_ENTRIES; r++){
199
-		acc=_tm_table->entries[r].acc_entries;
200
-		crt=_tm_table->entries[r].cur_entries;
201
-		
202
-		acc_count+=acc;
203
-		if (acc<acc_min) acc_min=acc;
204
-		if (acc>acc_max) acc_max=acc;
205
-		if (acc==0) acc_zeroes++;
206
-		
207
-		crt_count+=crt;
208
-		if (crt<crt_min) crt_min=crt;
209
-		if (crt>crt_max) crt_max=crt;
210
-		if (crt==0) crt_zeroes++;
211
-	}
212
-	acc_average=acc_count/(double)TABLE_ENTRIES;
213
-	crt_average=crt_count/(double)TABLE_ENTRIES;
214
-	
215
-	for (r=0; r<TABLE_ENTRIES; r++){
216
-		acc=_tm_table->entries[r].acc_entries;
217
-		crt=_tm_table->entries[r].cur_entries;
218
-		
219
-		acc_d=acc-acc_average;
220
-		/* instead of fabs() which requires -lm */
221
-		if (acc_d<0) acc_d=-acc_d;
222
-		if (acc_d>1) acc_dev_no++;
223
-		acc_dev+=acc_d*acc_d;
224
-		crt_d=crt-crt_average;
225
-		/* instead of fabs() which requires -lm */
226
-		if (crt_d<0) crt_d=-crt_d;
227
-		if (crt_d>1) crt_dev_no++;
228
-		crt_dev+=crt_d*crt_d;
229
-	}
230
-	
231
-	if (rpc->add(c, "{", &st) < 0) return;
232
-	rpc->struct_add(st, "d", "hash_size", (unsigned) TABLE_ENTRIES);
233
-	rpc->struct_add(st, "d", "crt_transactions", (unsigned)crt_count);
234
-	rpc->struct_add(st, "f", "crt_target_per_cell", crt_average);
235
-	rpc->struct_add(st, "dd", "crt_min", (unsigned)crt_min,
236
-							  "crt_max", (unsigned) crt_max);
237
-	rpc->struct_add(st, "d", "crt_worst_case_extra_cells", 
238
-							(unsigned)(crt_max-(unsigned)crt_average));
239
-	rpc->struct_add(st, "d", "crt_no_zero_cells", (unsigned)crt_zeroes);
240
-	rpc->struct_add(st, "d", "crt_no_deviating_cells", crt_dev_no);
241
-	rpc->struct_add(st, "f", "crt_deviation_sq_sum", crt_dev);
242
-	rpc->struct_add(st, "d", "acc_transactions", (unsigned)acc_count);
243
-	rpc->struct_add(st, "f", "acc_target_per_cell", acc_average);
244
-	rpc->struct_add(st, "dd", "acc_min", (unsigned)acc_min,
245
-							  "acc_max", (unsigned) acc_max);
246
-	rpc->struct_add(st, "d", "acc_worst_case_extra_cells", 
247
-							(unsigned)(acc_max-(unsigned)acc_average));
248
-	rpc->struct_add(st, "d", "acc_no_zero_cells", (unsigned)acc_zeroes);
249
-	rpc->struct_add(st, "d", "acc_no_deviating_cells", acc_dev_no);
250
-	rpc->struct_add(st, "f", "acc_deviation_sq_sum", acc_dev);
251
-#else /* TM_HASH_STATS */
252
-	rpc->fault(c, 500, "Hash statistics not supported (try"
253
-				"recompiling with -DTM_HASH_STATS)");
254
-#endif /* TM_HASH_STATS */
255
-}
Browse code

tmx: Consistent naming of counters

Simplify the names of the tmx counters to "rpl_*".

Stefan Mititelu authored on 14/12/2015 15:32:02
Showing 1 changed files
... ...
@@ -93,9 +93,9 @@ void free_tm_stats()
93 93
 		(res)->completed_5xx=(s1)->completed_5xx+(s2)->completed_5xx; \
94 94
 		(res)->completed_6xx=(s1)->completed_6xx+(s2)->completed_6xx; \
95 95
 		(res)->completed_2xx=(s1)->completed_2xx+(s2)->completed_2xx; \
96
-		(res)->received_replies=(s1)->received_replies+(s2)->received_replies; \
97
-		(res)->relayed_locally=(s1)->relayed_locally+(s2)->relayed_locally; \
98
-		(res)->relayed_total=(s1)->relayed_total+(s2)->relayed_total; \
96
+		(res)->rpl_received=(s1)->rpl_received+(s2)->rpl_received; \
97
+		(res)->rpl_generated=(s1)->rpl_generated+(s2)->rpl_generated; \
98
+		(res)->rpl_sent=(s1)->rpl_sent+(s2)->rpl_sent; \
99 99
 		(res)->deleted=(s1)->deleted+(s2)->deleted; \
100 100
 	}while(0)
101 101
 
... ...
@@ -138,9 +138,9 @@ void tm_rpc_stats(rpc_t* rpc, void* c)
138 138
 										 (unsigned) waiting);
139 139
 	rpc->struct_add(st, "d", "total", (unsigned) all.transactions);
140 140
 	rpc->struct_add(st, "d", "total_local", (unsigned)all.client_transactions);
141
-	rpc->struct_add(st, "d", "received_replies", (unsigned)all.received_replies);
142
-	rpc->struct_add(st, "d", "relayed_locally", (unsigned)all.relayed_locally);
143
-	rpc->struct_add(st, "d", "relayed_total", (unsigned)all.relayed_total);
141
+	rpc->struct_add(st, "d", "rpl_received", (unsigned)all.rpl_received);
142
+	rpc->struct_add(st, "d", "rpl_generated", (unsigned)all.rpl_generated);
143
+	rpc->struct_add(st, "d", "rpl_sent", (unsigned)all.rpl_sent);
144 144
 	rpc->struct_add(st, "ddddd", 
145 145
 			"6xx", (unsigned int)all.completed_6xx,
146 146
 			"5xx", (unsigned int)all.completed_5xx,
Browse code

tmx: refactor counters

Focus on:
- received_replies
- received_replies_absorbed (in cfX cases)

- relayed_locally
- relayed_received
- relayed_total

Stefan Mititelu authored on 27/11/2015 16:18:14
Showing 1 changed files
... ...
@@ -93,8 +93,9 @@ void free_tm_stats()
93 93
 		(res)->completed_5xx=(s1)->completed_5xx+(s2)->completed_5xx; \
94 94
 		(res)->completed_6xx=(s1)->completed_6xx+(s2)->completed_6xx; \
95 95
 		(res)->completed_2xx=(s1)->completed_2xx+(s2)->completed_2xx; \
96
-		(res)->replied_locally=(s1)->replied_locally+(s2)->replied_locally; \
97
-		(res)->replied_total=(s1)->replied_total+(s2)->replied_total; \
96
+		(res)->received_replies=(s1)->received_replies+(s2)->received_replies; \
97
+		(res)->relayed_locally=(s1)->relayed_locally+(s2)->relayed_locally; \
98
+		(res)->relayed_total=(s1)->relayed_total+(s2)->relayed_total; \
98 99
 		(res)->deleted=(s1)->deleted+(s2)->deleted; \
99 100
 	}while(0)
100 101
 
... ...
@@ -137,7 +138,9 @@ void tm_rpc_stats(rpc_t* rpc, void* c)
137 138
 										 (unsigned) waiting);
138 139
 	rpc->struct_add(st, "d", "total", (unsigned) all.transactions);
139 140
 	rpc->struct_add(st, "d", "total_local", (unsigned)all.client_transactions);
140
-	rpc->struct_add(st, "d", "replied_locally", (unsigned)all.replied_locally);
141
+	rpc->struct_add(st, "d", "received_replies", (unsigned)all.received_replies);
142
+	rpc->struct_add(st, "d", "relayed_locally", (unsigned)all.relayed_locally);
143
+	rpc->struct_add(st, "d", "relayed_total", (unsigned)all.relayed_total);
141 144
 	rpc->struct_add(st, "ddddd", 
142 145
 			"6xx", (unsigned int)all.completed_6xx,
143 146
 			"5xx", (unsigned int)all.completed_5xx,
Browse code

tmx: Fix relayed_replies counter

In the current implementation, for simple call timeout scenarios,
we get 2 x local_replies(100 + 408) and have only 1 x completed
6xx/5xx/4xx/3xx/2xx(408). The relayed_replies were computed by substracting
completed - local_replies(1 - 2), resulting in the max ulong.

Fix the above by counting the relayed_total(which include also the 1xx)
and substracting the relayed_local.

Stefan Mititelu authored on 26/11/2015 10:24:10
Showing 1 changed files
... ...
@@ -94,6 +94,7 @@ void free_tm_stats()
94 94
 		(res)->completed_6xx=(s1)->completed_6xx+(s2)->completed_6xx; \
95 95
 		(res)->completed_2xx=(s1)->completed_2xx+(s2)->completed_2xx; \
96 96
 		(res)->replied_locally=(s1)->replied_locally+(s2)->replied_locally; \
97
+		(res)->replied_total=(s1)->replied_total+(s2)->replied_total; \
97 98
 		(res)->deleted=(s1)->deleted+(s2)->deleted; \
98 99
 	}while(0)
99 100
 
Browse code

tm Remove svn ID, remove history, rename "ser" to "kamailio"

Olle E. Johansson authored on 03/01/2015 15:48:29
Showing 1 changed files
... ...
@@ -1,23 +1,15 @@
1 1
 /*
2
- *
3
- * $Id$
4
- *
5 2
  *
6 3
  * Copyright (C) 2001-2003 FhG Fokus
7 4
  *
8
- * This file is part of ser, a free SIP server.
5
+ * This file is part of Kamailio, a free SIP server.
9 6
  *
10
- * ser is free software; you can redistribute it and/or modify
7
+ * Kamailio is free software; you can redistribute it and/or modify
11 8
  * it under the terms of the GNU General Public License as published by
12 9
  * the Free Software Foundation; either version 2 of the License, or
13 10
  * (at your option) any later version
14 11
  *
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,
12
+ * Kamailio is distributed in the hope that it will be useful,
21 13
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 14
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 15
  * GNU General Public License for more details.
... ...
@@ -26,11 +18,6 @@
26 18
  * along with this program; if not, write to the Free Software 
27 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
28 20
  */
29
-/*
30
- * History:
31
- * --------
32
- *  2003-06-27  tm_stats & friends freed on exit only if non-null (andrei)
33
- */
34 21
 
35 22
 
36 23
 #include "defs.h"
Browse code

all: updated FSF address in GPL text

Anthony Messina authored on 04/07/2014 09:36:37 • Daniel-Constantin Mierla committed on 04/07/2014 09:37:36
Showing 1 changed files
... ...
@@ -24,7 +24,7 @@
24 24
  *
25 25
  * You should have received a copy of the GNU General Public License 
26 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
27
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
28 28
  */
29 29
 /*
30 30
  * History:
Browse code

tm: rpc doc strings moved to tm.c

Moved all the rpc doc strings into tm.c, close to the rpc exports
declaration. This will also allow automatic documentation
generation for the rpcs (the script that generates the rpc docs,
parses C code and cannot "resolve" symbols defined in other
files).

Andrei Pelinescu-Onciul authored on 07/03/2010 11:52:27
Showing 1 changed files
... ...
@@ -94,17 +94,6 @@ void free_tm_stats()
94 94
 
95 95
 
96 96
 
97
-const char* tm_rpc_stats_doc[2] = {
98
-	"Print transaction statistics.",
99
-	0
100
-};
101
-
102
-const char* tm_rpc_hash_stats_doc[2] = {
103
-	"Prints hash table statistics (can be used only if tm is compiled"
104
-		" with -DTM_HASH_STATS).",
105
-	0
106
-};
107
-
108 97
 /* res=s1+s2 */
109 98
 #define tm_proc_stats_add_base(res, s1, s2) \
110 99
 	do{\
Browse code

tm: small wrapper to get TM stats via API

- used for K style statistics

Daniel-Constantin Mierla authored on 23/06/2009 10:44:39
Showing 1 changed files
... ...
@@ -175,6 +175,19 @@ void tm_rpc_stats(rpc_t* rpc, void* c)
175 175
 	/* rpc->fault(c, 100, "Trying"); */
176 176
 }
177 177
 
178
+int tm_get_stats(struct t_proc_stats *all)
179
+{
180
+	int i, pno;
181
+	if(all==NULL)
182
+		return -1;
183
+
184
+	pno = get_max_procs();
185
+	memset(all, 0, sizeof(struct t_proc_stats));
186
+	for(i = 0; i < pno; i++) {
187
+		tm_proc_stats_add(all, all, &tm_stats[i].s);
188
+	}
189
+	return 0;
190
+}
178 191
 
179 192
 
180 193
 /*  hash statistics */
Browse code

- hash statistics rpc for hash algo. debugging (only if tm compiled with -DTM_HASH_STATS)

Andrei Pelinescu-Onciul authored on 27/06/2007 21:11:33
Showing 1 changed files
... ...
@@ -42,6 +42,9 @@
42 42
 #include "../../dprint.h"
43 43
 #include "../../config.h"
44 44
 #include "../../pt.h"
45
+#ifdef TM_HASH_STATS
46
+#include "h_table.h"
47
+#endif
45 48
 
46 49
 union t_stats *tm_stats=0;
47 50
 
... ...
@@ -96,6 +99,11 @@ const char* tm_rpc_stats_doc[2] = {
96 99
 	0
97 100
 };
98 101
 
102
+const char* tm_rpc_hash_stats_doc[2] = {
103
+	"Prints hash table statistics (can be used only if tm is compiled"
104
+		" with -DTM_HASH_STATS).",
105
+	0
106
+};
99 107
 
100 108
 /* res=s1+s2 */
101 109
 #define tm_proc_stats_add_base(res, s1, s2) \
... ...
@@ -166,3 +174,89 @@ void tm_rpc_stats(rpc_t* rpc, void* c)
166 174
 #endif
167 175
 	/* rpc->fault(c, 100, "Trying"); */
168 176
 }
177
+
178
+
179
+
180
+/*  hash statistics */
181
+void tm_rpc_hash_stats(rpc_t* rpc, void* c)
182
+{
183
+#ifdef TM_HASH_STATS
184
+	void* st;
185
+	unsigned long acc_min, acc_max, acc_zeroes, acc_dev_no;
186
+	unsigned long crt_min, crt_max, crt_zeroes, crt_dev_no;
187
+	unsigned long crt_count, acc_count;
188
+	double acc_average, acc_dev, acc_d;
189
+	double crt_average, crt_dev, crt_d;
190
+	unsigned long acc, crt;
191
+	int r;
192
+	
193
+	acc_count=0;
194
+	acc_min=(unsigned long)(-1);
195
+	acc_max=0;
196
+	acc_zeroes=0;
197
+	acc_dev_no=0;
198
+	acc_dev=0;
199
+	crt_count=0;
200
+	crt_min=(unsigned long)(-1);
201
+	crt_max=0;
202
+	crt_zeroes=0;
203
+	crt_dev_no=0;
204
+	crt_dev=0;
205
+	for (r=0; r<TABLE_ENTRIES; r++){
206
+		acc=_tm_table->entries[r].acc_entries;
207
+		crt=_tm_table->entries[r].cur_entries;
208
+		
209
+		acc_count+=acc;
210
+		if (acc<acc_min) acc_min=acc;
211
+		if (acc>acc_max) acc_max=acc;
212
+		if (acc==0) acc_zeroes++;
213
+		
214
+		crt_count+=crt;
215
+		if (crt<crt_min) crt_min=crt;
216
+		if (crt>crt_max) crt_max=crt;
217
+		if (crt==0) crt_zeroes++;
218
+	}
219
+	acc_average=acc_count/(double)TABLE_ENTRIES;
220
+	crt_average=crt_count/(double)TABLE_ENTRIES;
221
+	
222
+	for (r=0; r<TABLE_ENTRIES; r++){
223
+		acc=_tm_table->entries[r].acc_entries;
224
+		crt=_tm_table->entries[r].cur_entries;
225
+		
226
+		acc_d=acc-acc_average;
227
+		/* instead of fabs() which requires -lm */
228
+		if (acc_d<0) acc_d=-acc_d;
229
+		if (acc_d>1) acc_dev_no++;
230
+		acc_dev+=acc_d*acc_d;
231
+		crt_d=crt-crt_average;
232
+		/* instead of fabs() which requires -lm */
233
+		if (crt_d<0) crt_d=-crt_d;
234
+		if (crt_d>1) crt_dev_no++;
235
+		crt_dev+=crt_d*crt_d;
236
+	}
237
+	
238
+	if (rpc->add(c, "{", &st) < 0) return;
239
+	rpc->struct_add(st, "d", "hash_size", (unsigned) TABLE_ENTRIES);
240
+	rpc->struct_add(st, "d", "crt_transactions", (unsigned)crt_count);
241
+	rpc->struct_add(st, "f", "crt_target_per_cell", crt_average);
242
+	rpc->struct_add(st, "dd", "crt_min", (unsigned)crt_min,
243
+							  "crt_max", (unsigned) crt_max);
244
+	rpc->struct_add(st, "d", "crt_worst_case_extra_cells", 
245
+							(unsigned)(crt_max-(unsigned)crt_average));
246
+	rpc->struct_add(st, "d", "crt_no_zero_cells", (unsigned)crt_zeroes);
247
+	rpc->struct_add(st, "d", "crt_no_deviating_cells", crt_dev_no);
248
+	rpc->struct_add(st, "f", "crt_deviation_sq_sum", crt_dev);
249
+	rpc->struct_add(st, "d", "acc_transactions", (unsigned)acc_count);
250
+	rpc->struct_add(st, "f", "acc_target_per_cell", acc_average);
251
+	rpc->struct_add(st, "dd", "acc_min", (unsigned)acc_min,
252
+							  "acc_max", (unsigned) acc_max);
253
+	rpc->struct_add(st, "d", "acc_worst_case_extra_cells", 
254
+							(unsigned)(acc_max-(unsigned)acc_average));
255
+	rpc->struct_add(st, "d", "acc_no_zero_cells", (unsigned)acc_zeroes);
256
+	rpc->struct_add(st, "d", "acc_no_deviating_cells", acc_dev_no);
257
+	rpc->struct_add(st, "f", "acc_deviation_sq_sum", acc_dev);
258
+#else /* TM_HASH_STATS */
259
+	rpc->fault(c, 500, "Hash statistics not supported (try"
260
+				"recompiling with -DTM_HASH_STATS)");
261
+#endif /* TM_HASH_STATS */
262
+}
Browse code

- tm stats changes: cleaner & faster - updated to the new PROC_INIT stuff (fixes a tm bug)

Andrei Pelinescu-Onciul authored on 07/06/2007 21:45:56
Showing 1 changed files
... ...
@@ -43,19 +43,11 @@
43 43
 #include "../../config.h"
44 44
 #include "../../pt.h"
45 45
 
46
-struct t_stats *tm_stats=0;
46
+union t_stats *tm_stats=0;
47 47
 
48 48
 int init_tm_stats(void)
49 49
 {
50
-
51
-	tm_stats = shm_malloc(sizeof(struct t_stats));
52
-	if (tm_stats==0) {
53
-		ERR("No mem for stats\n");
54
-		return -1;
55
-	}
56
-	memset(tm_stats, 0, sizeof(struct t_stats) );
57
-
58
-	     /* Delay initialization of tm_stats structures to
50
+	     /* Delay initialization of tm_stats  to
59 51
 	      * init_tm_stats_child which gets called from child_init,
60 52
 	      * in mod_init function other modules can increase the value of
61 53
 	      * estimated_process_count and thus we do not know about processes created
... ...
@@ -70,149 +62,107 @@ int init_tm_stats_child(void)
70 62
 {
71 63
 	int size;
72 64
 
73
-	     /* We are called from child_init, estimated_process_count has definitive
74
-	      * value now and thus we can safely allocate the variables
75
-	      */
76
-	size = sizeof(stat_counter) * get_max_procs();
77
-	tm_stats->s_waiting = shm_malloc(size);
78
-	if (tm_stats->s_waiting == 0) {
79
-		ERR("No mem for stats\n");
80
-		goto error1;
65
+	/* We are called from child_init, estimated_process_count has definitive
66
+	 * value now and thus we can safely allocate the variables
67
+	 */
68
+	if (tm_stats==0){
69
+		size=sizeof(*tm_stats) * get_max_procs();
70
+		tm_stats=shm_malloc(size);
71
+		if (tm_stats == 0) {
72
+			ERR("No mem for stats\n");
73
+			goto error;
74
+		}
75
+		memset(tm_stats, 0, size);
81 76
 	}
82
-	memset(tm_stats->s_waiting, 0, size);
83
-
84
-	tm_stats->s_transactions = shm_malloc(size);
85
-	if (tm_stats->s_transactions == 0) {
86
-		ERR("No mem for stats\n");
87
-		goto error2;
88
-	}
89
-	memset(tm_stats->s_transactions, 0, size);
90
-
91
-	tm_stats->s_client_transactions = shm_malloc(size);
92
-	if (tm_stats->s_client_transactions == 0) {
93
-		ERR("No mem for stats\n");
94
-		goto error3;
95
-	}
96
-	memset(tm_stats->s_client_transactions, 0, size);
97
-
98
-#ifdef TM_MORE_STATS 
99
-	tm_stats->t_created = shm_malloc(size);
100
-	if (tm_stats->t_created == 0) {
101
-		ERR("No mem for stats\n");
102
-		goto error4;
103
-	}
104
-	memset(tm_stats->t_created, 0, size);
105
-
106
-	tm_stats->t_freed = shm_malloc(size);
107
-	if (tm_stats->t_freed == 0) {
108
-		ERR("No mem for stats\n");
109
-		goto error5;
110
-	}
111
-	memset(tm_stats->t_freed, 0, size);
112
-
113
-	tm_stats->delayed_free = shm_malloc(size);
114
-	if (tm_stats->delayed_free == 0) {
115
-		ERR("No mem for stats\n");
116
-		goto error6;
117
-	}
118
-	memset(tm_stats->delayed_free, 0, size);
119
-#endif /* TM_MORE_STATS  */
120
-
121
-
77
+	
122 78
 	return 0;
123
-#ifdef TM_MORE_STATS 
124
- error6:
125
-	shm_free(tm_stats->t_freed);
126
-	tm_stats->t_freed = 0;
127
- error5:
128
-	shm_free(tm_stats->t_created);
129
-	tm_stats->t_created = 0;
130
- error4:
131
-	shm_free(tm_stats->s_client_transactions);
132
-	tm_stats->s_client_transactions = 0;
133
-#endif /* TM_MORE_STATS */
134
- error3:
135
-	shm_free(tm_stats->s_transactions);
136
-	tm_stats->s_transactions = 0;
137
- error2:
138
-	shm_free(tm_stats->s_waiting);
139
-	tm_stats->s_waiting = 0;
140
- error1:
141
-	shm_free(tm_stats);
79
+error:
142 80
 	return -1;
143 81
 }
144 82
 
145 83
 
84
+
146 85
 void free_tm_stats()
147 86
 {
148 87
 	if (tm_stats == 0) return;
149
-#ifdef TM_MORE_STATS 
150
-	if (tm_stats->delayed_free)
151
-		shm_free(tm_stats->delayed_free);
152
-	if (tm_stats->t_freed)
153
-		shm_free(tm_stats->t_freed);
154
-	if (tm_stats->t_created)
155
-		shm_free(tm_stats->t_created);
156
-#endif
157
-	if (tm_stats->s_client_transactions) 
158
-		shm_free(tm_stats->s_client_transactions);
159
-	if (tm_stats->s_transactions)
160
-		shm_free(tm_stats->s_transactions);
161
-	if (tm_stats->s_waiting)
162
-		shm_free(tm_stats->s_waiting);
163 88
 	shm_free(tm_stats);
89
+	tm_stats=0;
164 90
 }
165 91
 
166 92
 
93
+
167 94
 const char* tm_rpc_stats_doc[2] = {
168 95
 	"Print transaction statistics.",
169 96
 	0
170 97
 };
171 98
 
99
+
100
+/* res=s1+s2 */
101
+#define tm_proc_stats_add_base(res, s1, s2) \
102
+	do{\
103
+		(res)->waiting=(s1)->waiting+(s2)->waiting; \
104
+		(res)->transactions=(s1)->transactions+(s2)->transactions; \
105
+		(res)->client_transactions=(s1)->client_transactions+\
106
+									(s2)->client_transactions; \
107
+		(res)->completed_3xx=(s1)->completed_3xx+(s2)->completed_3xx; \
108
+		(res)->completed_4xx=(s1)->completed_4xx+(s2)->completed_4xx; \
109
+		(res)->completed_5xx=(s1)->completed_5xx+(s2)->completed_5xx; \
110
+		(res)->completed_6xx=(s1)->completed_6xx+(s2)->completed_6xx; \
111
+		(res)->completed_2xx=(s1)->completed_2xx+(s2)->completed_2xx; \
112
+		(res)->replied_locally=(s1)->replied_locally+(s2)->replied_locally; \
113
+		(res)->deleted=(s1)->deleted+(s2)->deleted; \
114
+	}while(0)
115
+
116
+
117
+#ifdef TM_MORE_STATS
118
+#define tm_proc_stats_add(res, s1, s2) \
119
+	do{\
120
+		tm_proc_stats_add_base(res, s1, s2); \
121
+		(res)->t_created=(s1)->t_created+(s2)->t_created; \
122
+		(res)->t_freed=(s1)->t_freed+(s2)->t_freed; \
123
+		(res)->delayed_free=(s1)->delayed_free+(s2)->delayed_free; \
124
+	}while(0)
125
+#else
126
+#define tm_proc_stats_add(res, s1, s2) tm_proc_stats_add_base(res, s1, s2)
127
+#endif
128
+
129
+
130
+
172 131
 /* we don't worry about locking data during reads (unlike
173 132
  * setting values which always happens from some locks) 
174 133
  */
175 134
 void tm_rpc_stats(rpc_t* rpc, void* c)
176 135
 {
177 136
 	void* st;
178
-	unsigned long total, current, waiting, total_local;
179
-#ifdef TM_MORE_STATS 
180
-	unsigned long created, freed, delayed_free;
181
-#endif
137
+	unsigned long current, waiting;
138
+	struct t_proc_stats all;
182 139
 	int i, pno;
183 140
 
184 141
 	pno = get_max_procs();
185
-#ifdef TM_MORE_STATS 
186
-	created=freed=delayed_free=0;
187
-#endif
188
-	for(i = 0, total = 0, waiting = 0, total_local = 0; i < pno; i++) {
189
-		total += tm_stats->s_transactions[i];
190
-		waiting += tm_stats->s_waiting[i];
191
-		total_local += tm_stats->s_client_transactions[i];
192
-#ifdef TM_MORE_STATS 
193
-		created+= tm_stats->t_created[i];
194
-		freed+= tm_stats->t_freed[i];
195
-		delayed_free+=tm_stats->delayed_free[i];
196
-#endif
142
+	memset(&all, 0, sizeof(all));
143
+	for(i = 0;i < pno; i++) {
144
+		tm_proc_stats_add(&all, &all, &tm_stats[i].s);
197 145
 	}
198
-	current = total - tm_stats->deleted;
199
-	waiting -= tm_stats->deleted;
146
+	current = all.transactions - all.deleted;
147
+	waiting = all.waiting - all.deleted;
200 148
 
201 149
 	if (rpc->add(c, "{", &st) < 0) return;
202 150
 
203
-	rpc->struct_add(st, "dd", "current", current, "waiting", waiting);
204
-	rpc->struct_add(st, "d", "total", total);
205
-	rpc->struct_add(st, "d", "total_local", total_local);
206
-	rpc->struct_add(st, "d", "replied_localy", tm_stats->replied_localy);
151
+	rpc->struct_add(st, "dd", "current", (unsigned) current, "waiting",
152
+										 (unsigned) waiting);
153
+	rpc->struct_add(st, "d", "total", (unsigned) all.transactions);
154
+	rpc->struct_add(st, "d", "total_local", (unsigned)all.client_transactions);
155
+	rpc->struct_add(st, "d", "replied_locally", (unsigned)all.replied_locally);
207 156
 	rpc->struct_add(st, "ddddd", 
208
-			"6xx", tm_stats->completed_6xx,
209
-			"5xx", tm_stats->completed_5xx,
210
-			"4xx", tm_stats->completed_4xx,
211
-			"3xx", tm_stats->completed_3xx,
212
-			"2xx", tm_stats->completed_2xx);
157
+			"6xx", (unsigned int)all.completed_6xx,
158
+			"5xx", (unsigned int)all.completed_5xx,
159
+			"4xx", (unsigned int)all.completed_4xx,
160
+			"3xx", (unsigned int)all.completed_3xx,
161
+			"2xx", (unsigned int)all.completed_2xx);
213 162
 #ifdef TM_MORE_STATS 
214
-	rpc->struct_add(st, "dd", "created", created, "freed", freed);
215
-	rpc->struct_add(st, "d", "delayed_free", delayed_free);
163
+	rpc->struct_add(st, "dd", "created", (unsigned int)all.t_created, "freed",
164
+						(unsigned int)all.t_freed);
165
+	rpc->struct_add(st, "d", "delayed_free", (unsigned int)all.delayed_free);
216 166
 #endif
217 167
 	/* rpc->fault(c, 100, "Trying"); */
218 168
 }
Browse code

- even more tm statistics (usefull for debugging)

Andrei Pelinescu-Onciul authored on 05/06/2007 21:21:06
Showing 1 changed files
... ...
@@ -94,8 +94,43 @@ int init_tm_stats_child(void)
94 94
 		goto error3;
95 95
 	}
96 96
 	memset(tm_stats->s_client_transactions, 0, size);
97
-	return 0;
98 97
 
98
+#ifdef TM_MORE_STATS 
99
+	tm_stats->t_created = shm_malloc(size);
100
+	if (tm_stats->t_created == 0) {
101
+		ERR("No mem for stats\n");
102
+		goto error4;
103
+	}
104
+	memset(tm_stats->t_created, 0, size);
105
+
106
+	tm_stats->t_freed = shm_malloc(size);
107
+	if (tm_stats->t_freed == 0) {
108
+		ERR("No mem for stats\n");
109
+		goto error5;
110
+	}
111
+	memset(tm_stats->t_freed, 0, size);
112
+
113
+	tm_stats->delayed_free = shm_malloc(size);
114
+	if (tm_stats->delayed_free == 0) {
115
+		ERR("No mem for stats\n");
116
+		goto error6;
117
+	}
118
+	memset(tm_stats->delayed_free, 0, size);
119
+#endif /* TM_MORE_STATS  */
120
+
121
+
122
+	return 0;
123
+#ifdef TM_MORE_STATS 
124
+ error6:
125
+	shm_free(tm_stats->t_freed);
126
+	tm_stats->t_freed = 0;
127
+ error5:
128
+	shm_free(tm_stats->t_created);
129
+	tm_stats->t_created = 0;
130
+ error4:
131
+	shm_free(tm_stats->s_client_transactions);
132
+	tm_stats->s_client_transactions = 0;
133
+#endif /* TM_MORE_STATS */
99 134
  error3:
100 135
 	shm_free(tm_stats->s_transactions);
101 136
 	tm_stats->s_transactions = 0;
... ...
@@ -111,6 +146,14 @@ int init_tm_stats_child(void)
111 146
 void free_tm_stats()
112 147
 {
113 148
 	if (tm_stats == 0) return;
149
+#ifdef TM_MORE_STATS 
150
+	if (tm_stats->delayed_free)
151
+		shm_free(tm_stats->delayed_free);
152
+	if (tm_stats->t_freed)
153
+		shm_free(tm_stats->t_freed);
154
+	if (tm_stats->t_created)
155
+		shm_free(tm_stats->t_created);
156
+#endif
114 157
 	if (tm_stats->s_client_transactions) 
115 158
 		shm_free(tm_stats->s_client_transactions);
116 159
 	if (tm_stats->s_transactions)
... ...
@@ -133,13 +176,24 @@ void tm_rpc_stats(rpc_t* rpc, void* c)
133 176
 {
134 177
 	void* st;
135 178
 	unsigned long total, current, waiting, total_local;
179
+#ifdef TM_MORE_STATS 
180
+	unsigned long created, freed, delayed_free;
181
+#endif
136 182
 	int i, pno;
137 183
 
138 184
 	pno = get_max_procs();
185
+#ifdef TM_MORE_STATS 
186
+	created=freed=delayed_free=0;
187
+#endif
139 188
 	for(i = 0, total = 0, waiting = 0, total_local = 0; i < pno; i++) {
140 189
 		total += tm_stats->s_transactions[i];
141 190
 		waiting += tm_stats->s_waiting[i];
142 191
 		total_local += tm_stats->s_client_transactions[i];
192
+#ifdef TM_MORE_STATS 
193
+		created+= tm_stats->t_created[i];
194
+		freed+= tm_stats->t_freed[i];
195
+		delayed_free+=tm_stats->delayed_free[i];
196
+#endif
143 197
 	}
144 198
 	current = total - tm_stats->deleted;
145 199
 	waiting -= tm_stats->deleted;
... ...
@@ -156,5 +210,9 @@ void tm_rpc_stats(rpc_t* rpc, void* c)
156 210
 			"4xx", tm_stats->completed_4xx,
157 211
 			"3xx", tm_stats->completed_3xx,
158 212
 			"2xx", tm_stats->completed_2xx);
213
+#ifdef TM_MORE_STATS 
214
+	rpc->struct_add(st, "dd", "created", created, "freed", freed);
215
+	rpc->struct_add(st, "d", "delayed_free", delayed_free);
216
+#endif
159 217
 	/* rpc->fault(c, 100, "Trying"); */
160 218
 }
Browse code

- dns failover when a 503 reply is received (if the dns name resolves to more ips/srvs try the next one) - if the final reply is a relayed 503 replace it with a 500 (generate a "fake" 500). If the 503 is locally generated, let it pass. - tm_rpc_stats: removed duplicate "waiting" stats

Andrei Pelinescu-Onciul authored on 12/10/2006 19:15:33
Showing 1 changed files
... ...
@@ -147,7 +147,7 @@ void tm_rpc_stats(rpc_t* rpc, void* c)
147 147
 	if (rpc->add(c, "{", &st) < 0) return;
148 148
 
149 149
 	rpc->struct_add(st, "dd", "current", current, "waiting", waiting);
150
-	rpc->struct_add(st, "dd", "waiting", waiting, "total", total);
150
+	rpc->struct_add(st, "d", "total", total);
151 151
 	rpc->struct_add(st, "d", "total_local", total_local);
152 152
 	rpc->struct_add(st, "d", "replied_localy", tm_stats->replied_localy);
153 153
 	rpc->struct_add(st, "ddddd", 
Browse code

- applied patch from Dragos Vingarzan <vingarzan@fokus.fraunhofer.de> which moves all the forking part into 2 functions in pt.c (fork_process and fork_tcp_process). - added PROC_NOCHLDINIT rank value for Dragos's fork_process (if this value is used as child_id/rank_value the mod_child functions will not be called) - added register_procs(processes_no), used from mod_init when a module knows that it will fork some children (replaces the old process_count++ / the patch's estimated_process_count++) - added get_max_procs(): returns the maximum (estimated) number of processes

Andrei Pelinescu-Onciul authored on 19/09/2006 16:13:27
Showing 1 changed files
... ...
@@ -58,7 +58,7 @@ int init_tm_stats(void)
58 58
 	     /* Delay initialization of tm_stats structures to
59 59
 	      * init_tm_stats_child which gets called from child_init,
60 60
 	      * in mod_init function other modules can increase the value of
61
-	      * process_count and thus we do not know about processes created
61
+	      * estimated_process_count and thus we do not know about processes created
62 62
 	      * from modules which get loaded after tm and thus their mod_init
63 63
 	      * functions will be called after tm mod_init function finishes
64 64
 	      */
... ...
@@ -70,10 +70,10 @@ int init_tm_stats_child(void)
70 70
 {
71 71
 	int size;
72 72
 
73
-	     /* We are called from child_init, process_count has definitive
73
+	     /* We are called from child_init, estimated_process_count has definitive
74 74
 	      * value now and thus we can safely allocate the variables
75 75
 	      */
76
-	size = sizeof(stat_counter) * process_count;
76
+	size = sizeof(stat_counter) * get_max_procs();
77 77
 	tm_stats->s_waiting = shm_malloc(size);
78 78
 	if (tm_stats->s_waiting == 0) {
79 79
 		ERR("No mem for stats\n");
... ...
@@ -135,7 +135,7 @@ void tm_rpc_stats(rpc_t* rpc, void* c)
135 135
 	unsigned long total, current, waiting, total_local;
136 136
 	int i, pno;
137 137
 
138
-	pno = process_count;
138
+	pno = get_max_procs();
139 139
 	for(i = 0, total = 0, waiting = 0, total_local = 0; i < pno; i++) {
140 140
 		total += tm_stats->s_transactions[i];
141 141
 		waiting += tm_stats->s_waiting[i];
Browse code

- tcp accounting: connections_no decreased on error - parse_uri: missing break for r2 - tm: enabled tm stats

Andrei Pelinescu-Onciul authored on 24/02/2006 18:35:35
Showing 1 changed files
... ...
@@ -156,5 +156,5 @@ void tm_rpc_stats(rpc_t* rpc, void* c)
156 156
 			"4xx", tm_stats->completed_4xx,
157 157
 			"3xx", tm_stats->completed_3xx,
158 158
 			"2xx", tm_stats->completed_2xx);
159
-	rpc->fault(c, 100, "Trying");
</