3
#include "status_counter.h"
5
* The status array can carry all the status information you want
6
* the key to the array is <module-prefix>.<name>
7
* and the values are counters
10
* fastcgi.backends = 10
11
* fastcgi.active-backends = 6
12
* fastcgi.backend.<key>.load = 24
13
* fastcgi.backend.<key>....
15
* fastcgi.backend.<key>.disconnects = ...
18
data_integer *status_counter_get_counter(server *srv, const char *s, size_t len) {
21
if (NULL == (di = (data_integer *)array_get_element(srv->status, s))) {
22
/* not found, create it */
24
if (NULL == (di = (data_integer *)array_get_unused_element(srv->status, TYPE_INTEGER))) {
25
di = data_integer_init();
27
buffer_copy_string_len(di->key, s, len);
30
array_insert_unique(srv->status, (data_unset *)di);
35
/* dummies of the statistic framework functions
36
* they will be moved to a statistics.c later */
37
int status_counter_inc(server *srv, const char *s, size_t len) {
38
data_integer *di = status_counter_get_counter(srv, s, len);
45
int status_counter_dec(server *srv, const char *s, size_t len) {
46
data_integer *di = status_counter_get_counter(srv, s, len);
48
if (di->value > 0) di->value--;
53
int status_counter_set(server *srv, const char *s, size_t len, int val) {
54
data_integer *di = status_counter_get_counter(srv, s, len);