3 #include "status_counter.h"
8 * The status array can carry all the status information you want
9 * the key to the array is <module-prefix>.<name>
10 * and the values are counters
13 * fastcgi.backends = 10
14 * fastcgi.active-backends = 6
15 * fastcgi.backend.<key>.load = 24
16 * fastcgi.backend.<key>....
18 * fastcgi.backend.<key>.disconnects = ...
21 data_integer
*status_counter_get_counter(server
*srv
, const char *s
, size_t len
) {
24 if (NULL
== (di
= (data_integer
*)array_get_element(srv
->status
, s
))) {
25 /* not found, create it */
27 if (NULL
== (di
= (data_integer
*)array_get_unused_element(srv
->status
, TYPE_INTEGER
))) {
28 di
= data_integer_init();
30 buffer_copy_string_len(di
->key
, s
, len
);
33 array_insert_unique(srv
->status
, (data_unset
*)di
);
38 /* dummies of the statistic framework functions
39 * they will be moved to a statistics.c later */
40 int status_counter_inc(server
*srv
, const char *s
, size_t len
) {
41 data_integer
*di
= status_counter_get_counter(srv
, s
, len
);
48 int status_counter_dec(server
*srv
, const char *s
, size_t len
) {
49 data_integer
*di
= status_counter_get_counter(srv
, s
, len
);
51 if (di
->value
> 0) di
->value
--;
56 int status_counter_set(server
*srv
, const char *s
, size_t len
, int val
) {
57 data_integer
*di
= status_counter_get_counter(srv
, s
, len
);