Sfoglia il codice sorgente

core: added function to check if counters have been initialized

Daniel-Constantin Mierla 11 anni fa
parent
commit
8161152b32
2 ha cambiato i file con 10 aggiunte e 1 eliminazioni
  1. 9 1
      counters.c
  2. 1 0
      counters.h

+ 9 - 1
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.

+ 1 - 0
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);