Browse Source

[core] inline status_counter routines

personal/stbuehler/fix-fdevent
Glenn Strauss 3 years ago
parent
commit
2dbcfc9266
  1. 2
      src/CMakeLists.txt
  2. 2
      src/Makefile.am
  3. 2
      src/SConscript
  4. 1
      src/meson.build
  5. 38
      src/status_counter.c
  6. 30
      src/status_counter.h

2
src/CMakeLists.txt

@ -583,7 +583,7 @@ set(COMMON_SRC
sock_addr.c
splaytree.c
rand.c
status_counter.c safe_memclear.c
safe_memclear.c
)
if(WIN32)

2
src/Makefile.am

@ -86,7 +86,7 @@ common_src=base64.c buffer.c burl.c log.c \
rand.c \
request.c \
sock_addr.c \
splaytree.c status_counter.c \
splaytree.c \
safe_memclear.c
src = server.c response.c connections.c \

2
src/SConscript

@ -76,7 +76,7 @@ common_src = Split("base64.c buffer.c burl.c log.c \
sock_addr.c \
splaytree.c \
rand.c \
status_counter.c safe_memclear.c \
safe_memclear.c \
")
src = Split("server.c response.c connections.c \

1
src/meson.build

@ -589,7 +589,6 @@ common_src = [
'sock_addr.c',
'splaytree.c',
'stat_cache.c',
'status_counter.c',
'stream.c',
'vector.c',
]

38
src/status_counter.c

@ -1,38 +0,0 @@
#include "first.h"
#include "status_counter.h"
#include "base.h"
/**
* The status array can carry all the status information you want
* the key to the array is <module-prefix>.<name>
* and the values are counters
*
* example:
* fastcgi.backends = 10
* fastcgi.active-backends = 6
* fastcgi.backend.<key>.load = 24
* fastcgi.backend.<key>....
*
* fastcgi.backend.<key>.disconnects = ...
*/
int *status_counter_get_counter(server *srv, const char *s, size_t len) {
return array_get_int_ptr(srv->status, s, len);
}
/* dummies of the statistic framework functions
* they will be moved to a statistics.c later */
void status_counter_inc(server *srv, const char *s, size_t len) {
++(*status_counter_get_counter(srv, s, len));
}
void status_counter_dec(server *srv, const char *s, size_t len) {
int *i = status_counter_get_counter(srv, s, len);
if (*i > 0) --(*i);
}
void status_counter_set(server *srv, const char *s, size_t len, int val) {
*status_counter_get_counter(srv, s, len) = val;
}

30
src/status_counter.h

@ -4,9 +4,39 @@
#include "base_decls.h"
static inline
int *status_counter_get_counter(server *srv, const char *s, size_t len);
static inline
void status_counter_inc(server *srv, const char *s, size_t len);
static inline
void status_counter_dec(server *srv, const char *s, size_t len);
static inline
void status_counter_set(server *srv, const char *s, size_t len, int val);
/* inline status counter routines */
#include "base.h" /* (srv->status) */
#include "array.h"
static inline
int *status_counter_get_counter(server *srv, const char *s, size_t len) {
return array_get_int_ptr(srv->status, s, len);
}
static inline
void status_counter_inc(server *srv, const char *s, size_t len) {
++(*array_get_int_ptr(srv->status, s, len));
}
static inline
void status_counter_dec(server *srv, const char *s, size_t len) {
--(*array_get_int_ptr(srv->status, s, len));
}
static inline
void status_counter_set(server *srv, const char *s, size_t len, int val) {
*array_get_int_ptr(srv->status, s, len) = val;
}
#endif

Loading…
Cancel
Save