Module: sip-router
Branch: 4.0
Commit: 1208d0ac3890539f06ad6372cd11d5048cf572dd
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1208d0a…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Tue Dec 3 23:38:08 2013 +0100
core: added function to check if counters have been initialized
(cherry picked from commit 8161152b320f3b430523ea08e86a56f79405c2f4)
(cherry picked from commit a165fa668378da5c312a0c268aaf158ff583127f)
---
counters.c | 10 +++++++++-
counters.h | 1 +
2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/counters.c b/counters.c
index 6e5ffbb..3bfe542 100644
--- a/counters.c
+++ b/counters.c
@@ -89,12 +89,20 @@ static int grp_no; /* number of groups */
/** counters array. a[proc_no][counter_id] =>
_cnst_vals[proc_no*cnts_no+counter_id] */
-counter_array_t* _cnts_vals;
+counter_array_t* _cnts_vals = 0;
int _cnts_row_len; /* number of elements per row */
static int cnts_no; /* number of registered counters */
static int cnts_max_rows; /* set to 0 if not yet fully init */
+int counters_initialized(void)
+{
+ if (unlikely(_cnts_vals == 0)) {
+ /* not init yet */
+ return 0;
+ }
+ return 1;
+}
/** init the coutner hash table(s).
* @return 0 on success, -1 on error.
diff --git a/counters.h b/counters.h
index ea16e28..9fd7c32 100644
--- a/counters.h
+++ b/counters.h
@@ -87,6 +87,7 @@ extern int _cnts_row_len; /* number of elements per row */
+int counters_initialized(void);
int init_counters(void);
void destroy_counters(void);
int counters_prefork_init(int max_process_no);