[multiple] rename status_counter -> plugin_stats

master
Glenn Strauss 7 months ago
parent 6669846947
commit 2a7d3a2751
  1. 2
      src/Makefile.am
  2. 6
      src/gw_backend.c
  3. 3
      src/mod_ajp13.c
  4. 3
      src/mod_fastcgi.c
  5. 34
      src/mod_magnet.c
  6. 5
      src/mod_proxy.c
  7. 3
      src/mod_scgi.c
  8. 3
      src/mod_sockproxy.c
  9. 20
      src/plugin_config.h
  10. 43
      src/status_counter.h

@ -421,7 +421,7 @@ hdr = base64.h buffer.h burl.h network.h log.h http_kv.h keyvalue.h \
sys-crypto.h sys-crypto-md.h \
sys-endian.h sys-mmap.h sys-setjmp.h \
sys-socket.h sys-strings.h sys-time.h \
sock_addr.h status_counter.h \
sock_addr.h \
mod_auth_api.h \
mod_magnet_cache.h \
mod_vhostdb_api.h \

@ -40,8 +40,6 @@
#include "status_counter.h"
__attribute_noinline__
static int * gw_status_get_counter(gw_host *host, gw_proc *proc, const char *tag, size_t tlen) {
/*(At the cost of some memory, could prepare strings for host and for proc
@ -70,7 +68,7 @@ static int * gw_status_get_counter(gw_host *host, gw_proc *proc, const char *tag
llen += tlen;
label[llen] = '\0';
return status_counter_get_counter(label, llen);
return plugin_stats_get_ptr(label, llen);
}
static void gw_proc_tag_inc(gw_host *host, gw_proc *proc, const char *tag, size_t len) {
@ -117,7 +115,7 @@ static void gw_status_init_host(gw_host *host) {
gw_status_get_counter(host, NULL, CONST_STR_LEN(".load"));
*host->stats_load = 0;
host->stats_global_active =
status_counter_get_counter(CONST_STR_LEN("gw.active-requests"));
plugin_stats_get_ptr("gw.active-requests",sizeof("gw.active-requests")-1);
}

@ -29,7 +29,6 @@ typedef gw_handler_ctx handler_ctx;
#include "http_header.h"
#include "http_kv.h"
#include "log.h"
#include "status_counter.h"
#define AJP13_MAX_PACKET_SIZE 8192
@ -644,7 +643,7 @@ ajp13_create_env (handler_ctx * const hctx)
ajp13_stdin_append_n(hctx, AJP13_MAX_PACKET_SIZE-4);
hctx->request_id = 0; /* overloaded value; see ajp13_stdin_append_n() */
status_counter_inc(CONST_STR_LEN("ajp13.requests"));
plugin_stats_inc("ajp13.requests");
return HANDLER_GO_ON;
} while (0);

@ -15,7 +15,6 @@ typedef gw_handler_ctx handler_ctx;
#include "http_chunk.h"
#include "log.h"
#include "request.h"
#include "status_counter.h"
#include "compat/fastcgi.h"
@ -296,7 +295,7 @@ static handler_t fcgi_create_env(handler_ctx *hctx) {
}
fcgi_stdin_append(hctx);
status_counter_inc(CONST_STR_LEN("fastcgi.requests"));
plugin_stats_inc("fastcgi.requests");
return HANDLER_GO_ON;
}

@ -21,7 +21,6 @@
#include "mod_magnet_cache.h"
#include "sock_addr.h"
#include "stat_cache.h"
#include "status_counter.h"
#include <dirent.h>
#include <stdlib.h>
@ -1689,27 +1688,20 @@ static int magnet_resphdr_pairs(lua_State *L) {
return magnet_array_pairs(L, &r->resp_headers);
}
static int magnet_status_get(lua_State *L) {
/* __index: param 1 is the (empty) table the value was not found in */
const_buffer key = magnet_checkconstbuffer(L, 2);
int *i = status_counter_get_counter(key.ptr, key.len);
lua_pushinteger(L, (lua_Integer)*i);
return 1;
static int magnet_plugin_stats_get(lua_State *L) {
const_buffer k = magnet_checkconstbuffer(L, 2);
lua_pushinteger(L, (lua_Integer)*plugin_stats_get_ptr(k.ptr, k.len));
return 1;
}
static int magnet_status_set(lua_State *L) {
/* __newindex: param 1 is the (empty) table the value is supposed to be set in */
const_buffer key = magnet_checkconstbuffer(L, 2);
int counter = (int) luaL_checkinteger(L, 3);
status_counter_set(key.ptr, key.len, counter);
return 0;
static int magnet_plugin_stats_set(lua_State *L) {
const_buffer k = magnet_checkconstbuffer(L, 2);
plugin_stats_set(k.ptr, k.len, luaL_checkinteger(L, 3));
return 0;
}
static int magnet_status_pairs(lua_State *L) {
return magnet_array_pairs(L, &plugin_stats);
static int magnet_plugin_stats_pairs(lua_State *L) {
return magnet_array_pairs(L, &plugin_stats);
}
@ -2831,11 +2823,11 @@ magnet_plugin_stats_table (lua_State * const L)
{
lua_createtable(L, 0, 0); /* {} (sp += 1) */
lua_createtable(L, 0, 4); /* metatable for plugin_stats (sp += 1) */
lua_pushcfunction(L, magnet_status_get); /* (sp += 1) */
lua_pushcfunction(L, magnet_plugin_stats_get); /* (sp += 1) */
lua_setfield(L, -2, "__index"); /* (sp -= 1) */
lua_pushcfunction(L, magnet_status_set); /* (sp += 1) */
lua_pushcfunction(L, magnet_plugin_stats_set); /* (sp += 1) */
lua_setfield(L, -2, "__newindex"); /* (sp -= 1) */
lua_pushcfunction(L, magnet_status_pairs); /* (sp += 1) */
lua_pushcfunction(L, magnet_plugin_stats_pairs); /* (sp += 1) */
lua_setfield(L, -2, "__pairs"); /* (sp -= 1) */
lua_pushboolean(L, 0); /* (sp += 1) */
lua_setfield(L, -2, "__metatable"); /* protect metatable (sp -= 1) */

@ -12,7 +12,6 @@
#include "http_header.h"
#include "log.h"
#include "sock_addr.h"
#include "status_counter.h"
/**
*
@ -1036,7 +1035,7 @@ static handler_t proxy_create_env(gw_handler_ctx *gwhctx) {
chunkqueue_append_chunkqueue(&hctx->gw.wb, &r->reqbody_queue);
}
status_counter_inc(CONST_STR_LEN("proxy.requests"));
plugin_stats_inc("proxy.requests");
return HANDLER_GO_ON;
}
@ -1049,7 +1048,7 @@ static handler_t proxy_create_env_connect(gw_handler_ctx *gwhctx) {
gw_set_transparent(&hctx->gw);
http_response_upgrade_read_body_unknown(r);
status_counter_inc(CONST_STR_LEN("proxy.requests"));
plugin_stats_inc("proxy.requests");
return HANDLER_GO_ON;
}

@ -14,7 +14,6 @@ typedef gw_handler_ctx handler_ctx;
#include "buffer.h"
#include "http_cgi.h"
#include "log.h"
#include "status_counter.h"
enum { LI_PROTOCOL_SCGI, LI_PROTOCOL_UWSGI };
@ -245,7 +244,7 @@ static handler_t scgi_create_env(handler_ctx *hctx) {
hctx->wb_reqlen = -hctx->wb_reqlen;
}
status_counter_inc(CONST_STR_LEN("scgi.requests"));
plugin_stats_inc("scgi.requests");
return HANDLER_GO_ON;
}

@ -18,7 +18,6 @@ typedef gw_handler_ctx handler_ctx;
#include "array.h"
#include "buffer.h"
#include "log.h"
#include "status_counter.h"
/**
*
@ -136,7 +135,7 @@ static handler_t sockproxy_create_env_connect(handler_ctx *hctx) {
gw_set_transparent(hctx);
http_response_upgrade_read_body_unknown(r);
status_counter_inc(CONST_STR_LEN("sockproxy.requests"));
plugin_stats_inc("sockproxy.requests");
return HANDLER_GO_ON;
}

@ -193,9 +193,8 @@ int32_t config_feature_int (const server *srv, const char *feature, int32_t defa
/**
* 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
* plugin statistics
* convention: key is <module-prefix>.<name>, value is counter
*
* example:
* fastcgi.backends = 10
@ -207,5 +206,20 @@ int32_t config_feature_int (const server *srv, const char *feature, int32_t defa
*/
extern array plugin_stats;
#define plugin_stats_get_ptr(s, len) \
array_get_int_ptr(&plugin_stats, (s), (len))
#define plugin_stats_incr(s, len) \
(++(*array_get_int_ptr(&plugin_stats, (s), (len))))
#define plugin_stats_inc(s) \
plugin_stats_incr((s), sizeof(s)-1)
#define plugin_stats_decr(s, len) \
(--(*array_get_int_ptr(&plugin_stats, (s), (len))))
#define plugin_stats_set(s, len, val) \
(*array_get_int_ptr(&plugin_stats, (s), (len)) = (val))
#endif

@ -1,43 +0,0 @@
#ifndef _STATUS_COUNTER_H_
#define _STATUS_COUNTER_H_
#include "first.h"
#include "base_decls.h"
__attribute_returns_nonnull__
static inline
int *status_counter_get_counter(const char *s, size_t len);
static inline
void status_counter_inc(const char *s, size_t len);
static inline
void status_counter_dec(const char *s, size_t len);
static inline
void status_counter_set(const char *s, size_t len, int val);
/* inline status counter routines */
#include "array.h"
#include "plugin_config.h"
static inline
int *status_counter_get_counter(const char *s, size_t len) {
return array_get_int_ptr(&plugin_stats, s, len);
}
static inline
void status_counter_inc(const char *s, size_t len) {
++(*array_get_int_ptr(&plugin_stats, s, len));
}
static inline
void status_counter_dec(const char *s, size_t len) {
--(*array_get_int_ptr(&plugin_stats, s, len));
}
static inline
void status_counter_set(const char *s, size_t len, int val) {
*array_get_int_ptr(&plugin_stats, s, len) = val;
}
#endif
Loading…
Cancel
Save