Browse code

kcore stats: rewrote in terms of the counters api

Most of the original kamailio statistics functions and data types are now
wrappers over sr counters.
The only important usage difference is that sr counters are
uniquely identified by group and name (one can have counters with
the same name if they are in different groups), while kamailio
stats vars had unique names. This means that when using the
kamailio get_stat(name) the first counter matching that name will
be returned (in the future this kind of usage should be
obsoleted).

Removed functions (not needed):
get_stats_collector()
destroy_stats_collector()
Removed data types:
stats_collector
module_stats
New functions:
stats_support() - partially replaces get_stats_collector().
get_stat_name() - returns the name of a stat_var.
get_stat_module() - returns the module of a stat_var.

Andrei Pelinescu-Onciul authored on 08/08/2010 17:36:48
Showing 4 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,105 @@
1
+/* 
2
+ * $Id$
3
+ * 
4
+ * Copyright (C) 2010 iptelorg GmbH
5
+ *
6
+ * Permission to use, copy, modify, and distribute this software for any
7
+ * purpose with or without fee is hereby granted, provided that the above
8
+ * copyright notice and this permission notice appear in all copies.
9
+ *
10
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
+ */
18
+/** k compatible statistics implemented in terms of sr counters.
19
+ * @file kstats_wrapper.h
20
+ * @ingroup: libkcore
21
+ */
22
+/*
23
+ * History:
24
+ * --------
25
+ *  2010-08-08  initial version (andrei)
26
+*/
27
+
28
+#include "kstats_wrapper.h"
29
+
30
+#ifdef STATISTICS
31
+
32
+
33
+/** internal wrapper for kamailio type stat callbacks.
34
+ * sr counter callbacks are different from the kamailio type stat callbacks.
35
+ * This function is meant as a sr counter callback that will call
36
+ * k stat callback passed as parameter.
37
+ * @param h - not used.
38
+ * @param param - k stat callback function pointer (stat_function).
39
+ * @return result of calling the passed k stat_function.
40
+ */
41
+static counter_val_t cnt_cbk_wrapper(counter_handle_t h, void* param)
42
+{
43
+	stat_function k_stat_f;
44
+	
45
+	k_stat_f = param;
46
+	return k_stat_f();
47
+}
48
+
49
+
50
+
51
+int register_stat( char *module, char *name, stat_var **pvar, int flags)
52
+{
53
+	int cnt_flags;
54
+	counter_handle_t h;
55
+	int ret;
56
+	
57
+	if (module == 0 || name == 0 || pvar == 0) {
58
+		BUG("invalid parameters (%p, %p, %p)\n", module, name, pvar);
59
+		return -1;
60
+	}
61
+	/* translate kamailio stat flags into sr counter flags */
62
+	cnt_flags = (flags & STAT_NO_RESET) ? CNT_F_NO_RESET : 0;
63
+	if (flags & STAT_IS_FUNC)
64
+		ret = counter_register(&h, module, name, cnt_flags,
65
+					cnt_cbk_wrapper,(stat_function)pvar , 0);
66
+	else
67
+		ret = counter_register(&h, module, name, cnt_flags, 0, 0, 0);
68
+	if (ret < 0) {
69
+		if (ret == -2)
70
+			ERR("counter %s.%s already registered\n", module, name);
71
+		goto error;
72
+	}
73
+	if (!(flags & STAT_IS_FUNC))
74
+		*pvar = (void*)(unsigned long)h.id;
75
+	return 0;
76
+error:
77
+	if (!(flags & STAT_IS_FUNC))
78
+		*pvar = 0;
79
+	return -1;
80
+}
81
+
82
+
83
+
84
+int register_module_stats(char *module, stat_export_t *stats)
85
+{
86
+	if (module == 0 || *module == 0) {
87
+		BUG("null or empty module name\n");
88
+		goto error;
89
+	}
90
+	if (stats == 0 || stats[0].name == 0)
91
+		/* empty stats */
92
+		return 0;
93
+	for (; stats->name; stats++)
94
+		if (register_stat(module, stats->name, stats->stat_pointer,
95
+							stats->flags) < 0 ){
96
+			ERR("failed to add statistic %s.%s\n", module, stats->name);
97
+			goto error;
98
+		}
99
+	return 0;
100
+error:
101
+	return -1;
102
+}
103
+
104
+#endif /* STATISTICS */
105
+/* vi: set ts=4 sw=4 tw=79:ai:cindent: */
0 106
new file mode 100644
... ...
@@ -0,0 +1,171 @@
1
+/* 
2
+ * $Id$
3
+ * 
4
+ * Copyright (C) 2010 iptelorg GmbH
5
+ *
6
+ * Permission to use, copy, modify, and distribute this software for any
7
+ * purpose with or without fee is hereby granted, provided that the above
8
+ * copyright notice and this permission notice appear in all copies.
9
+ *
10
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
+ */
18
+/** k compatible statistics implemented in terms of sr counters.
19
+ * New functions:
20
+ *  stats_support() - partially replaces get_stats_collector().
21
+ *    Returns 1 if statistics support is compiled, 0 otherwise.
22
+ *  get_stat_name() - returns the name of a stat_var.
23
+ *  get_stat_module() - returns the module of a stat_var.
24
+ * Removed functions:
25
+ *  get_stats_collector()
26
+ *  destroy_stats_collector()
27
+ * Removed variables/structures:
28
+ *   stats_collector
29
+ *   module_stats
30
+ *
31
+ * @file kstats_wrapper.h
32
+ * @ingroup: libkcore
33
+ */
34
+/*
35
+ * History:
36
+ * --------
37
+ *  2010-08-08  initial version (andrei)
38
+*/
39
+
40
+#ifndef __kstats_wrapper_h
41
+#define __kstats_wrapper_h
42
+
43
+#include "../../counters.h"
44
+
45
+/* k stat flags */
46
+#define STAT_NO_RESET	1  /* used in dialog(k), nat_traversal(k),
47
+							  registrar(k), statistics(k), usrloc(k) */
48
+/* #define STAT_NO_SYN	2  -- not used */
49
+#define STAT_SHM_NAME	4 /* used only from usrloc(k) */
50
+#define STAT_IS_FUNC	8
51
+
52
+/* types */
53
+
54
+typedef counter_val_t    stat_val;
55
+/* stat_var is always used as a pointer in k, we missuse
56
+   stat_var* for holding out counter id */
57
+typedef void stat_var;
58
+/* get val callback
59
+ * TODO: change it to counter_cbk_f compatible callback?
60
+ */
61
+typedef counter_val_t (*stat_function)(void);
62
+
63
+/* statistic module interface */
64
+struct stat_export_s {
65
+	char* name;
66
+	int flags;
67
+	stat_var** stat_pointer; /* pointer to the memory location
68
+								(where a counter handle will be stored)
69
+								Note: it's a double pointer because of
70
+								the original k version which needed it
71
+								allocated in shm. This version
72
+								will store the counter id at *stat_pointer.
73
+							  */
74
+};
75
+
76
+typedef struct stat_export_s stat_export_t;
77
+
78
+#ifdef STATISTICS
79
+
80
+/* statistics support check */
81
+#define stats_support() 1
82
+
83
+int register_stat( char *module, char *name, stat_var **pvar, int flags);
84
+int register_module_stats(char *module, stat_export_t *stats);
85
+
86
+inline static stat_var* get_stat(str *name)
87
+{
88
+	counter_handle_t h;
89
+	str grp;
90
+	
91
+	grp.s = 0;
92
+	grp.len = 0;
93
+	if (counter_lookup_str(&h, &grp, name) < 0)
94
+		return 0;
95
+	return (void*)(unsigned long)h.id;
96
+}
97
+
98
+
99
+
100
+inline static unsigned int get_stat_val(stat_var *v)
101
+{
102
+	counter_handle_t h;
103
+	h.id = (unsigned short)(unsigned long)v;
104
+	return counter_get_val(h);
105
+}
106
+
107
+
108
+
109
+inline static char* get_stat_name(stat_var *v)
110
+{
111
+	counter_handle_t h;
112
+	h.id = (unsigned short)(unsigned long)v;
113
+	return counter_get_name(h);
114
+}
115
+
116
+
117
+
118
+inline static char* get_stat_module(stat_var *v)
119
+{
120
+	counter_handle_t h;
121
+	h.id = (unsigned short)(unsigned long)v;
122
+	return counter_get_group(h);
123
+}
124
+
125
+
126
+
127
+inline static void update_stat(stat_var* v, int n)
128
+{
129
+	counter_handle_t h;
130
+	h.id = (unsigned short)(unsigned long)v;
131
+	counter_add(h, n);
132
+}
133
+
134
+
135
+
136
+inline static void reset_stat(stat_var* v)
137
+{
138
+	counter_handle_t h;
139
+	h.id = (unsigned short)(unsigned long)v;
140
+	counter_reset(h);
141
+}
142
+
143
+
144
+#define if_update_stat(c, var, n) \
145
+	do{ \
146
+		if ((c)) update_stat((var), (n)); \
147
+	}while(0)
148
+
149
+#define if_reset_stat(c, var) \
150
+	do{ \
151
+		if ((c)) reset_stat((var)); \
152
+	}while(0)
153
+
154
+#else /* STATISTICS */
155
+
156
+/* statistics support check */
157
+#define stats_support() 0
158
+#define register_module_stats(mod, stats) 0
159
+#define register_stat(mod, name, var, flags) 0
160
+#define get_stat(name)  0
161
+#define get_stat_val(var) 0
162
+#define update_stat(v, n)
163
+#define reset_stat(v)
164
+#define if_update_stat(c, v, n)
165
+#define if_reset_stat(c, v)
166
+
167
+#endif /* STATISTICS */
168
+
169
+#endif /*__kstats_wrapper_h*/
170
+
171
+/* vi: set ts=4 sw=4 tw=79:ai:cindent: */
... ...
@@ -25,6 +25,7 @@
25 25
  *  2006-01-16  first version (bogdan)
26 26
  *  2006-11-28  added get_stat_var_from_num_code() (Jeffrey Magder -
27 27
  *              SOMA Networks)
28
+ *  2010-08-08  removed all the parts emulated by kstats_wrapper.[ch] (andrei)
28 29
  */
29 30
 
30 31
 /*!
... ...
@@ -37,26 +38,14 @@
37 38
 #include <stdio.h>
38 39
 #include <stdlib.h>
39 40
 
40
-#include "../../mem/shm_mem.h"
41 41
 #include "../../ut.h"
42 42
 #include "../../dprint.h"
43
-#include "../../locking.h"
44 43
 #include "../../socket_info.h"
45 44
 #include "km_ut.h"
46
-#include "hash_func.h"
47 45
 #include "statistics.h"
48 46
 
49 47
 #ifdef STATISTICS
50 48
 
51
-static stats_collector *collector = NULL;
52
-
53
-
54
-#define stat_hash(_s) core_hash( _s, 0, STATS_HASH_SIZE)
55
-
56
-stats_collector* get_stats_collector(void)
57
-{
58
-	return collector;
59
-}
60 49
 
61 50
 /*! \brief
62 51
  * Returns the statistic associated with 'numerical_code' and 'out_codes'.
... ...
@@ -89,244 +78,6 @@ stat_var *get_stat_var_from_num_code(unsigned int numerical_code, int out_codes)
89 78
 }
90 79
 
91 80
 
92
-
93
-int init_stats_collector(void)
94
-{
95
-	if(collector != NULL) /* already initialized */
96
-		return 0;
97
-	/* init the collector */
98
-	collector = (stats_collector*)shm_malloc(sizeof(stats_collector));
99
-	if (collector==0) {
100
-		LM_ERR("no more shm mem\n");
101
-		goto error;
102
-	}
103
-	memset( collector, 0 , sizeof(stats_collector));
104
-
105
-	LM_DBG("statistics manager successfully initialized\n");
106
-
107
-	return 0;
108
-error:
109
-	return -1;
110
-}
111
-
112
-
113
-void destroy_stats_collector(void)
114
-{
115
-	stat_var *stat;
116
-	stat_var *tmp_stat;
117
-	int i;
118
-
119
-	if (collector) {
120
-		/* destroy hash table */
121
-		for( i=0 ; i<STATS_HASH_SIZE ; i++ ) {
122
-			for( stat=collector->hstats[i] ; stat ; ) {
123
-				tmp_stat = stat;
124
-				stat = stat->hnext;
125
-				if ((tmp_stat->flags&STAT_IS_FUNC)==0 && tmp_stat->u.val)
126
-					shm_free(tmp_stat->u.val);
127
-				if ( (tmp_stat->flags&STAT_SHM_NAME) && tmp_stat->name.s)
128
-					shm_free(tmp_stat->name.s);
129
-				shm_free(tmp_stat);
130
-			}
131
-		}
132
-
133
-		/* destroy sts_module array */
134
-		if (collector->amodules)
135
-			shm_free(collector->amodules);
136
-
137
-		/* destroy the collector */
138
-		shm_free(collector);
139
-		collector = NULL;
140
-	}
141
-
142
-	return;
143
-}
144
-
145
-
146
-module_stats* get_stat_module(str *module)
147
-{
148
-	int i;
149
-
150
-	if ( (module==0) || module->s==0 || module->len==0 )
151
-		return 0;
152
-
153
-	for( i=0 ; i<collector->mod_no ; i++ ) {
154
-		if ( (collector->amodules[i].name.len == module->len) &&
155
-		(strncasecmp(collector->amodules[i].name.s,module->s,module->len)==0) )
156
-			return &collector->amodules[i];
157
-	}
158
-
159
-	return 0;
160
-}
161
-
162
-
163
-static inline module_stats* add_stat_module( char *module)
164
-{
165
-	module_stats *amods;
166
-	module_stats *mods;
167
-	int len;
168
-
169
-	if ( (module==0) || ((len = strlen(module))==0 ) )
170
-		return 0;
171
-	if(init_stats_collector()!=0)
172
-		return 0;
173
-
174
-	amods = (module_stats*)shm_realloc( collector->amodules,
175
-			(collector->mod_no+1)*sizeof(module_stats) );
176
-	if (amods==0) {
177
-		LM_ERR("no more shm memory\n");
178
-		return 0;
179
-	}
180
-
181
-	collector->amodules = amods;
182
-	collector->mod_no++;
183
-
184
-	mods = &amods[collector->mod_no-1];
185
-	memset( mods, 0, sizeof(module_stats) );
186
-
187
-	mods->name.s = module;
188
-	mods->name.len = len;
189
-
190
-	return mods;
191
-}
192
-
193
-
194
-int register_stat( char *module, char *name, stat_var **pvar, int flags)
195
-{
196
-	module_stats* mods;
197
-	stat_var *stat;
198
-	stat_var *it;
199
-	str smodule;
200
-	int hash;
201
-
202
-	if (module==0 || name==0 || pvar==0) {
203
-		LM_ERR("invalid parameters module=%p, name=%p, pvar=%p \n", 
204
-				module, name, pvar);
205
-		goto error;
206
-	}
207
-
208
-	if(init_stats_collector()!=0)
209
-		return -1;
210
-
211
-	stat = (stat_var*)shm_malloc(sizeof(stat_var));
212
-	if (stat==0) {
213
-		LM_ERR("no more shm memory\n");
214
-		goto error;
215
-	}
216
-	memset( stat, 0, sizeof(stat_var));
217
-
218
-	if ( (flags&STAT_IS_FUNC)==0 ) {
219
-		stat->u.val = (stat_val*)shm_malloc(sizeof(stat_val));
220
-		if (stat->u.val==0) {
221
-			LM_ERR("no more shm memory\n");
222
-			goto error1;
223
-		}
224
-		atomic_set(stat->u.val,0);
225
-		*pvar = stat;
226
-	} else {
227
-		stat->u.f = (stat_function)(pvar);
228
-	}
229
-
230
-	/* is the module already recorded? */
231
-	smodule.s = module;
232
-	smodule.len = strlen(module);
233
-	mods = get_stat_module(&smodule);
234
-	if (mods==0) {
235
-		mods = add_stat_module(module);
236
-		if (mods==0) {
237
-			LM_ERR("failed to add new module\n");
238
-			goto error2;
239
-		}
240
-	}
241
-
242
-	/* fill the stat record */
243
-	stat->mod_idx = collector->mod_no-1;
244
-
245
-	stat->name.s = name;
246
-	stat->name.len = strlen(name);
247
-	stat->flags = flags;
248
-
249
-
250
-	/* compute the hash by name */
251
-	hash = stat_hash( &stat->name );
252
-
253
-	/* link it */
254
-	if (collector->hstats[hash]==0) {
255
-		collector->hstats[hash] = stat;
256
-	} else {
257
-		it = collector->hstats[hash];
258
-		while(it->hnext)
259
-			it = it->hnext;
260
-		it->hnext = stat;
261
-	}
262
-	collector->stats_no++;
263
-
264
-	/* add the statistic also to the module statistic list */
265
-	if (mods->tail) {
266
-		mods->tail->lnext = stat;
267
-	} else {
268
-		mods->head = stat;
269
-	}
270
-	mods->tail = stat;
271
-	mods->no++;
272
-
273
-	return 0;
274
-error2:
275
-	if ( (flags&STAT_IS_FUNC)==0 ) {
276
-		shm_free(*pvar);
277
-		*pvar = 0;
278
-	}
279
-error1:
280
-	shm_free(stat);
281
-error:
282
-	*pvar = 0;
283
-	return -1;
284
-}
285
-
286
-
287
-
288
-int register_module_stats(char *module, stat_export_t *stats)
289
-{
290
-	int ret;
291
-
292
-	if (module==0 || module[0]==0 || !stats || !stats[0].name)
293
-		return 0;
294
-
295
-	for( ; stats->name ; stats++) {
296
-		ret = register_stat( module, stats->name, stats->stat_pointer,
297
-			stats->flags);
298
-		if (ret!=0) {
299
-			LM_CRIT("failed to add statistic\n");
300
-			return -1;
301
-		}
302
-	}
303
-
304
-	return 0;
305
-}
306
-
307
-
308
-
309
-stat_var* get_stat( str *name )
310
-{
311
-	stat_var *stat;
312
-	int hash;
313
-
314
-	if (name==0 || name->s==0 || name->len==0)
315
-		return 0;
316
-
317
-	/* compute the hash by name */
318
-	hash = stat_hash( name );
319
-
320
-	/* and look for it */
321
-	for( stat=collector->hstats[hash] ; stat ; stat=stat->hnext ) {
322
-		if ( (stat->name.len==name->len) &&
323
-		(strncasecmp( stat->name.s, name->s, name->len)==0) )
324
-			return stat;
325
-	}
326
-
327
-	return 0;
328
-}
329
-
330 81
 #endif /*STATISTICS*/
331 82
 
332 83
 #define MAX_PROC_BUFFER 256
... ...
@@ -24,6 +24,7 @@
24 24
  *  2006-01-16  first version (bogdan)
25 25
  *  2006-11-28  added get_stat_var_from_num_code() (Jeffrey Magder -
26 26
  *              SOMA Networks)
27
+ *  2010-08-08  removed all the parts emulated by kstats_wrapper.[ch] (andrei)
27 28
  */
28 29
 
29 30
 /*!
... ...
@@ -35,73 +36,13 @@
35 36
 #ifndef _KSTATISTICS_H_
36 37
 #define _KSTATISTICS_H_
37 38
 
38
-#include <string.h>
39
-#include "../../str.h"
40
-#include "../../atomic_ops.h"
39
+#include "kstats_wrapper.h"
41 40
 
42
-#define STATS_HASH_POWER   8
43
-#define STATS_HASH_SIZE    (1<<(STATS_HASH_POWER))
44 41
 
45 42
 #define NUM_IP_OCTETS 4
46 43
 
47
-#define STAT_NO_RESET  (1<<0)
48
-#define STAT_NO_SYNC   (1<<1)
49
-#define STAT_SHM_NAME  (1<<2)
50
-#define STAT_IS_FUNC   (1<<3)
51
-
52
-typedef atomic_t stat_val;
53
-
54
-typedef unsigned long (*stat_function)(void);
55
-
56
-struct module_stats_;
57
-
58
-typedef struct stat_var_{
59
-	unsigned int mod_idx;
60
-	str name;
61
-	int flags;
62
-	union{
63
-		stat_val *val;
64
-		stat_function f;
65
-	}u;
66
-	struct stat_var_ *hnext;
67
-	struct stat_var_ *lnext;
68
-} stat_var;
69
-
70
-typedef struct module_stats_ {
71
-	str name;
72
-	int no;
73
-	stat_var *head;
74
-	stat_var *tail;
75
-} module_stats;
76
-
77
-typedef struct stats_collector_ {
78
-	int stats_no;
79
-	int mod_no;
80
-	stat_var* hstats[STATS_HASH_SIZE];
81
-	module_stats *amodules;
82
-}stats_collector;
83
-
84
-typedef struct stat_export_ {
85
-	char* name;                /* null terminated statistic name */
86
-	int flags;                 /* flags */
87
-	stat_var** stat_pointer;   /* pointer to the variable's mem location *
88
-	                            * NOTE - it's in shm mem */
89
-} stat_export_t;
90
-
91 44
 
92 45
 #ifdef STATISTICS
93
-int init_stats_collector(void);
94
-
95
-void destroy_stats_collector(void);
96
-
97
-int register_stat( char *module, char *name, stat_var **pvar, int flags);
98
-
99
-int register_module_stats(char *module, stat_export_t *stats);
100
-
101
-stat_var* get_stat( str *name );
102
-
103
-unsigned int get_stat_val( stat_var *var );
104
-
105 46
 /*! \brief
106 47
  * Returns the statistic associated with 'numerical_code' and 'is_a_reply'.
107 48
  * Specifically:
... ...
@@ -113,52 +54,11 @@ unsigned int get_stat_val( stat_var *var );
113 54
  */
114 55
 stat_var *get_stat_var_from_num_code(unsigned int numerical_code, int in_codes);
115 56
 
116
-stats_collector* get_stats_collector(void);
117
-module_stats* get_stat_module(str *module);
118
-
119 57
 #else
120
-	#define init_stats_collector()  0
121
-	#define destroy_stats_collector()
122
-	#define register_module_stats(_mod,_stats) 0
123
-	#define register_stat( _mod, _name, _pvar, _flags) 0
124
-	#define get_stat( _name )  0
125
-	#define get_stat_val( _var ) 0
126 58
 	#define get_stat_var_from_num_code( _n_code, _in_code) NULL
127
-	#define get_stats_collector() NULL
128
-	#define get_stat_module(_module) NULL
129 59
 #endif
130 60
 
131 61
 
132
-#ifdef STATISTICS
133
-	#define update_stat( _var, _n) \
134
-		do { \
135
-			if ( !((_var)->flags&STAT_IS_FUNC) ) {\
136
-				atomic_add((_var)->u.val, _n);\
137
-			}\
138
-		}while(0)
139
-	#define reset_stat( _var) \
140
-		do { \
141
-			if ( ((_var)->flags&(STAT_NO_RESET|STAT_IS_FUNC))==0 ) {\
142
-				atomic_set( (_var)->u.val, 0);\
143
-			}\
144
-		}while(0)
145
-	#define get_stat_val( _var ) ((unsigned long)\
146
-		((_var)->flags&STAT_IS_FUNC)?(_var)->u.f():(_var)->u.val->val)
147
-
148
-	#define if_update_stat(_c, _var, _n) \
149
-		do { \
150
-			if (_c) update_stat( _var, _n); \
151
-		}while(0)
152
-	#define if_reset_stat(_c, _var) \
153
-		do { \
154
-			if (_c) reset_stat( _var); \
155
-		}while(0)
156
-#else
157
-	#define update_stat( _var, _n)
158
-	#define reset_stat( _var)
159
-	#define if_update_stat( _c, _var, _n)
160
-	#define if_reset_stat( _c, _var)
161
-#endif /*STATISTICS*/
162 62
 
163 63
 /*!
164 64
  * This function will retrieve a list of all ip addresses and ports that OpenSER