mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-21 13:16:57 +00:00
MINOR: stream-int: rename ->applet to ->appctx
Since this is the applet context, call it ->appctx to avoid the confusion with the pointer to the applet. Many places were changed but it's only a renaming.
This commit is contained in:
parent
0788f47cc1
commit
9b6c2c721e
@ -169,7 +169,7 @@ struct stream_interface {
|
||||
/* struct members below are the "remote" part, as seen from the buffer side */
|
||||
int conn_retries; /* number of connect retries left */
|
||||
int send_proxy_ofs; /* <0 = offset to (re)send from the end, >0 = send all */
|
||||
struct appctx applet; /* context of the running applet if any */
|
||||
struct appctx appctx; /* context of the running applet if any */
|
||||
};
|
||||
|
||||
/* An applet designed to run in a stream interface */
|
||||
|
930
src/dumpstats.c
930
src/dumpstats.c
File diff suppressed because it is too large
Load Diff
158
src/peers.c
158
src/peers.c
@ -184,10 +184,10 @@ static int peer_prepare_datamsg(struct stksess *ts, struct peer_session *ps, cha
|
||||
static void peer_session_release(struct stream_interface *si)
|
||||
{
|
||||
struct session *s = session_from_task(si->owner);
|
||||
struct peer_session *ps = (struct peer_session *)si->applet.ctx.peers.ptr;
|
||||
struct peer_session *ps = (struct peer_session *)si->appctx.ctx.peers.ptr;
|
||||
|
||||
/* si->applet.ctx.peers.ptr is not a peer session */
|
||||
if (si->applet.st0 < PEER_SESSION_SENDSUCCESS)
|
||||
/* si->appctx.ctx.peers.ptr is not a peer session */
|
||||
if (si->appctx.st0 < PEER_SESSION_SENDSUCCESS)
|
||||
return;
|
||||
|
||||
/* peer session identified */
|
||||
@ -223,21 +223,21 @@ static void peer_io_handler(struct stream_interface *si)
|
||||
|
||||
while (1) {
|
||||
switchstate:
|
||||
switch(si->applet.st0) {
|
||||
switch(si->appctx.st0) {
|
||||
case PEER_SESSION_ACCEPT:
|
||||
si->applet.ctx.peers.ptr = NULL;
|
||||
si->applet.st0 = PEER_SESSION_GETVERSION;
|
||||
si->appctx.ctx.peers.ptr = NULL;
|
||||
si->appctx.st0 = PEER_SESSION_GETVERSION;
|
||||
/* fall through */
|
||||
case PEER_SESSION_GETVERSION:
|
||||
reql = bo_getline(si->ob, trash.str, trash.size);
|
||||
if (reql <= 0) { /* closed or EOL not found */
|
||||
if (reql == 0)
|
||||
goto out;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
if (trash.str[reql-1] != '\n') {
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
else if (reql > 1 && (trash.str[reql-2] == '\r'))
|
||||
@ -249,26 +249,26 @@ switchstate:
|
||||
|
||||
/* test version */
|
||||
if (strcmp(PEER_SESSION_PROTO_NAME " 1.0", trash.str) != 0) {
|
||||
si->applet.st0 = PEER_SESSION_EXIT;
|
||||
si->applet.st1 = PEER_SESSION_ERRVERSION;
|
||||
si->appctx.st0 = PEER_SESSION_EXIT;
|
||||
si->appctx.st1 = PEER_SESSION_ERRVERSION;
|
||||
/* test protocol */
|
||||
if (strncmp(PEER_SESSION_PROTO_NAME " ", trash.str, strlen(PEER_SESSION_PROTO_NAME)+1) != 0)
|
||||
si->applet.st1 = PEER_SESSION_ERRPROTO;
|
||||
si->appctx.st1 = PEER_SESSION_ERRPROTO;
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
si->applet.st0 = PEER_SESSION_GETHOST;
|
||||
si->appctx.st0 = PEER_SESSION_GETHOST;
|
||||
/* fall through */
|
||||
case PEER_SESSION_GETHOST:
|
||||
reql = bo_getline(si->ob, trash.str, trash.size);
|
||||
if (reql <= 0) { /* closed or EOL not found */
|
||||
if (reql == 0)
|
||||
goto out;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
if (trash.str[reql-1] != '\n') {
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
else if (reql > 1 && (trash.str[reql-2] == '\r'))
|
||||
@ -280,12 +280,12 @@ switchstate:
|
||||
|
||||
/* test hostname match */
|
||||
if (strcmp(localpeer, trash.str) != 0) {
|
||||
si->applet.st0 = PEER_SESSION_EXIT;
|
||||
si->applet.st1 = PEER_SESSION_ERRHOST;
|
||||
si->appctx.st0 = PEER_SESSION_EXIT;
|
||||
si->appctx.st1 = PEER_SESSION_ERRHOST;
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
si->applet.st0 = PEER_SESSION_GETPEER;
|
||||
si->appctx.st0 = PEER_SESSION_GETPEER;
|
||||
/* fall through */
|
||||
case PEER_SESSION_GETPEER: {
|
||||
struct peer *curpeer;
|
||||
@ -294,12 +294,12 @@ switchstate:
|
||||
if (reql <= 0) { /* closed or EOL not found */
|
||||
if (reql == 0)
|
||||
goto out;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
if (trash.str[reql-1] != '\n') {
|
||||
/* Incomplete line, we quit */
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
else if (reql > 1 && (trash.str[reql-2] == '\r'))
|
||||
@ -312,8 +312,8 @@ switchstate:
|
||||
/* parse line "<peer name> <pid>" */
|
||||
p = strchr(trash.str, ' ');
|
||||
if (!p) {
|
||||
si->applet.st0 = PEER_SESSION_EXIT;
|
||||
si->applet.st1 = PEER_SESSION_ERRPROTO;
|
||||
si->appctx.st0 = PEER_SESSION_EXIT;
|
||||
si->appctx.st1 = PEER_SESSION_ERRPROTO;
|
||||
goto switchstate;
|
||||
}
|
||||
*p = 0;
|
||||
@ -326,17 +326,17 @@ switchstate:
|
||||
|
||||
/* if unknown peer */
|
||||
if (!curpeer) {
|
||||
si->applet.st0 = PEER_SESSION_EXIT;
|
||||
si->applet.st1 = PEER_SESSION_ERRPEER;
|
||||
si->appctx.st0 = PEER_SESSION_EXIT;
|
||||
si->appctx.st1 = PEER_SESSION_ERRPEER;
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
si->applet.ctx.peers.ptr = curpeer;
|
||||
si->applet.st0 = PEER_SESSION_GETTABLE;
|
||||
si->appctx.ctx.peers.ptr = curpeer;
|
||||
si->appctx.st0 = PEER_SESSION_GETTABLE;
|
||||
/* fall through */
|
||||
}
|
||||
case PEER_SESSION_GETTABLE: {
|
||||
struct peer *curpeer = (struct peer *)si->applet.ctx.peers.ptr;
|
||||
struct peer *curpeer = (struct peer *)si->appctx.ctx.peers.ptr;
|
||||
struct shared_table *st;
|
||||
struct peer_session *ps = NULL;
|
||||
unsigned long key_type;
|
||||
@ -347,16 +347,16 @@ switchstate:
|
||||
if (reql <= 0) { /* closed or EOL not found */
|
||||
if (reql == 0)
|
||||
goto out;
|
||||
si->applet.ctx.peers.ptr = NULL;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.ctx.peers.ptr = NULL;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
/* Re init si->applet.ctx.peers.ptr to null, to handle correctly a release case */
|
||||
si->applet.ctx.peers.ptr = NULL;
|
||||
/* Re init si->appctx.ctx.peers.ptr to null, to handle correctly a release case */
|
||||
si->appctx.ctx.peers.ptr = NULL;
|
||||
|
||||
if (trash.str[reql-1] != '\n') {
|
||||
/* Incomplete line, we quit */
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
else if (reql > 1 && (trash.str[reql-2] == '\r'))
|
||||
@ -369,8 +369,8 @@ switchstate:
|
||||
/* Parse line "<table name> <type> <size>" */
|
||||
p = strchr(trash.str, ' ');
|
||||
if (!p) {
|
||||
si->applet.st0 = PEER_SESSION_EXIT;
|
||||
si->applet.st1 = PEER_SESSION_ERRPROTO;
|
||||
si->appctx.st0 = PEER_SESSION_EXIT;
|
||||
si->appctx.st1 = PEER_SESSION_ERRPROTO;
|
||||
goto switchstate;
|
||||
}
|
||||
*p = 0;
|
||||
@ -378,9 +378,9 @@ switchstate:
|
||||
|
||||
p = strchr(p+1, ' ');
|
||||
if (!p) {
|
||||
si->applet.ctx.peers.ptr = NULL;
|
||||
si->applet.st0 = PEER_SESSION_EXIT;
|
||||
si->applet.st1 = PEER_SESSION_ERRPROTO;
|
||||
si->appctx.ctx.peers.ptr = NULL;
|
||||
si->appctx.st0 = PEER_SESSION_EXIT;
|
||||
si->appctx.st1 = PEER_SESSION_ERRPROTO;
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
@ -395,15 +395,15 @@ switchstate:
|
||||
if (key_size != st->table->key_size &&
|
||||
(key_type != STKTABLE_TYPE_STRING ||
|
||||
1 + 4 + 4 + key_size - 1 >= trash.size)) {
|
||||
si->applet.st0 = PEER_SESSION_EXIT;
|
||||
si->applet.st1 = PEER_SESSION_ERRSIZE;
|
||||
si->appctx.st0 = PEER_SESSION_EXIT;
|
||||
si->appctx.st1 = PEER_SESSION_ERRSIZE;
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
/* If key type mismatches */
|
||||
if (key_type != st->table->type) {
|
||||
si->applet.st0 = PEER_SESSION_EXIT;
|
||||
si->applet.st1 = PEER_SESSION_ERRTYPE;
|
||||
si->appctx.st0 = PEER_SESSION_EXIT;
|
||||
si->appctx.st1 = PEER_SESSION_ERRTYPE;
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
@ -414,8 +414,8 @@ switchstate:
|
||||
if (ps->session && ps->session != s) {
|
||||
if (ps->peer->local) {
|
||||
/* Local connection, reply a retry */
|
||||
si->applet.st0 = PEER_SESSION_EXIT;
|
||||
si->applet.st1 = PEER_SESSION_TRYAGAIN;
|
||||
si->appctx.st0 = PEER_SESSION_EXIT;
|
||||
si->appctx.st1 = PEER_SESSION_TRYAGAIN;
|
||||
goto switchstate;
|
||||
}
|
||||
peer_session_forceshutdown(ps->session);
|
||||
@ -430,31 +430,31 @@ switchstate:
|
||||
|
||||
/* If table not found */
|
||||
if (!st){
|
||||
si->applet.st0 = PEER_SESSION_EXIT;
|
||||
si->applet.st1 = PEER_SESSION_ERRTABLE;
|
||||
si->appctx.st0 = PEER_SESSION_EXIT;
|
||||
si->appctx.st1 = PEER_SESSION_ERRTABLE;
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
/* If no peer session for current peer */
|
||||
if (!ps) {
|
||||
si->applet.st0 = PEER_SESSION_EXIT;
|
||||
si->applet.st1 = PEER_SESSION_ERRPEER;
|
||||
si->appctx.st0 = PEER_SESSION_EXIT;
|
||||
si->appctx.st1 = PEER_SESSION_ERRPEER;
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
si->applet.ctx.peers.ptr = ps;
|
||||
si->applet.st0 = PEER_SESSION_SENDSUCCESS;
|
||||
si->appctx.ctx.peers.ptr = ps;
|
||||
si->appctx.st0 = PEER_SESSION_SENDSUCCESS;
|
||||
/* fall through */
|
||||
}
|
||||
case PEER_SESSION_SENDSUCCESS:{
|
||||
struct peer_session *ps = (struct peer_session *)si->applet.ctx.peers.ptr;
|
||||
struct peer_session *ps = (struct peer_session *)si->appctx.ctx.peers.ptr;
|
||||
|
||||
repl = snprintf(trash.str, trash.size, "%d\n", PEER_SESSION_SUCCESSCODE);
|
||||
repl = bi_putblk(si->ib, trash.str, repl);
|
||||
if (repl <= 0) {
|
||||
if (repl == -1)
|
||||
goto out;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
@ -493,11 +493,11 @@ switchstate:
|
||||
ps->table->flags |= SHTABLE_F_RESYNC_ASSIGN;
|
||||
}
|
||||
/* switch to waiting message state */
|
||||
si->applet.st0 = PEER_SESSION_WAITMSG;
|
||||
si->appctx.st0 = PEER_SESSION_WAITMSG;
|
||||
goto switchstate;
|
||||
}
|
||||
case PEER_SESSION_CONNECT: {
|
||||
struct peer_session *ps = (struct peer_session *)si->applet.ctx.peers.ptr;
|
||||
struct peer_session *ps = (struct peer_session *)si->appctx.ctx.peers.ptr;
|
||||
|
||||
/* Send headers */
|
||||
repl = snprintf(trash.str, trash.size,
|
||||
@ -510,7 +510,7 @@ switchstate:
|
||||
(int)ps->table->table->key_size);
|
||||
|
||||
if (repl >= trash.size) {
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
@ -518,16 +518,16 @@ switchstate:
|
||||
if (repl <= 0) {
|
||||
if (repl == -1)
|
||||
goto out;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
/* switch to the waiting statuscode state */
|
||||
si->applet.st0 = PEER_SESSION_GETSTATUS;
|
||||
si->appctx.st0 = PEER_SESSION_GETSTATUS;
|
||||
/* fall through */
|
||||
}
|
||||
case PEER_SESSION_GETSTATUS: {
|
||||
struct peer_session *ps = (struct peer_session *)si->applet.ctx.peers.ptr;
|
||||
struct peer_session *ps = (struct peer_session *)si->appctx.ctx.peers.ptr;
|
||||
|
||||
if (si->ib->flags & CF_WRITE_PARTIAL)
|
||||
ps->statuscode = PEER_SESSION_CONNECTEDCODE;
|
||||
@ -536,12 +536,12 @@ switchstate:
|
||||
if (reql <= 0) { /* closed or EOL not found */
|
||||
if (reql == 0)
|
||||
goto out;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
if (trash.str[reql-1] != '\n') {
|
||||
/* Incomplete line, we quit */
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
else if (reql > 1 && (trash.str[reql-2] == '\r'))
|
||||
@ -591,14 +591,14 @@ switchstate:
|
||||
}
|
||||
else {
|
||||
/* Status code is not success, abort */
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
si->applet.st0 = PEER_SESSION_WAITMSG;
|
||||
si->appctx.st0 = PEER_SESSION_WAITMSG;
|
||||
/* fall through */
|
||||
}
|
||||
case PEER_SESSION_WAITMSG: {
|
||||
struct peer_session *ps = (struct peer_session *)si->applet.ctx.peers.ptr;
|
||||
struct peer_session *ps = (struct peer_session *)si->appctx.ctx.peers.ptr;
|
||||
struct stksess *ts, *newts = NULL;
|
||||
char c;
|
||||
int totl = 0;
|
||||
@ -771,7 +771,7 @@ switchstate:
|
||||
if (stopping) {
|
||||
/* Close session, push resync no more needed */
|
||||
ps->flags |= PEER_F_TEACH_COMPLETE;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
@ -813,7 +813,7 @@ switchstate:
|
||||
}
|
||||
else {
|
||||
/* Unknown message */
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
@ -834,7 +834,7 @@ incomplete:
|
||||
|
||||
if (reql < 0) {
|
||||
/* there was an error */
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
@ -848,7 +848,7 @@ incomplete:
|
||||
/* no more write possible */
|
||||
if (repl == -1)
|
||||
goto out;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
ps->confirm--;
|
||||
@ -865,7 +865,7 @@ incomplete:
|
||||
/* no more write possible */
|
||||
if (repl == -1)
|
||||
goto out;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
ps->table->flags |= SHTABLE_F_RESYNC_PROCESS;
|
||||
@ -884,7 +884,7 @@ incomplete:
|
||||
/* no more write possible */
|
||||
if (repl == -1)
|
||||
goto out;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
ps->lastack = ps->pushack;
|
||||
@ -920,7 +920,7 @@ incomplete:
|
||||
/* no more write possible */
|
||||
if (repl == -1)
|
||||
goto out;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
ps->lastpush = ps->pushed = ts->upd.key;
|
||||
@ -954,7 +954,7 @@ incomplete:
|
||||
/* no more write possible */
|
||||
if (repl == -1)
|
||||
goto out;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
ps->lastpush = ps->pushed = ts->upd.key;
|
||||
@ -970,7 +970,7 @@ incomplete:
|
||||
/* no more write possible */
|
||||
if (repl == -1)
|
||||
goto out;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
|
||||
@ -1012,7 +1012,7 @@ incomplete:
|
||||
/* no more write possible */
|
||||
if (repl == -1)
|
||||
goto out;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
goto switchstate;
|
||||
}
|
||||
ps->lastpush = ps->pushed = ts->upd.key;
|
||||
@ -1024,11 +1024,11 @@ incomplete:
|
||||
goto out;
|
||||
}
|
||||
case PEER_SESSION_EXIT:
|
||||
repl = snprintf(trash.str, trash.size, "%d\n", si->applet.st1);
|
||||
repl = snprintf(trash.str, trash.size, "%d\n", si->appctx.st1);
|
||||
|
||||
if (bi_putblk(si->ib, trash.str, repl) == -1)
|
||||
goto out;
|
||||
si->applet.st0 = PEER_SESSION_END;
|
||||
si->appctx.st0 = PEER_SESSION_END;
|
||||
/* fall through */
|
||||
case PEER_SESSION_END: {
|
||||
si_shutw(si);
|
||||
@ -1071,8 +1071,8 @@ static void peer_session_forceshutdown(struct session * session)
|
||||
|
||||
/* call release to reinit resync states if needed */
|
||||
peer_session_release(oldsi);
|
||||
oldsi->applet.st0 = PEER_SESSION_END;
|
||||
oldsi->applet.ctx.peers.ptr = NULL;
|
||||
oldsi->appctx.st0 = PEER_SESSION_END;
|
||||
oldsi->appctx.ctx.peers.ptr = NULL;
|
||||
task_wakeup(session->task, TASK_WOKEN_MSG);
|
||||
}
|
||||
|
||||
@ -1087,8 +1087,8 @@ int peer_accept(struct session *s)
|
||||
/* we have a dedicated I/O handler for the stats */
|
||||
stream_int_register_handler(&s->si[1], &peer_applet);
|
||||
s->target = s->si[1].conn->target; // for logging only
|
||||
s->si[1].applet.ctx.peers.ptr = s;
|
||||
s->si[1].applet.st0 = PEER_SESSION_ACCEPT;
|
||||
s->si[1].appctx.ctx.peers.ptr = s;
|
||||
s->si[1].appctx.st0 = PEER_SESSION_ACCEPT;
|
||||
|
||||
tv_zero(&s->logs.tv_request);
|
||||
s->logs.t_queue = 0;
|
||||
@ -1178,8 +1178,8 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
|
||||
s->si[0].flags |= SI_FL_INDEP_STR;
|
||||
|
||||
stream_int_register_handler(&s->si[0], &peer_applet);
|
||||
s->si[0].applet.st0 = PEER_SESSION_CONNECT;
|
||||
s->si[0].applet.ctx.peers.ptr = (void *)ps;
|
||||
s->si[0].appctx.st0 = PEER_SESSION_CONNECT;
|
||||
s->si[0].appctx.ctx.peers.ptr = (void *)ps;
|
||||
|
||||
s->si[1].conn->obj_type = OBJ_TYPE_CONN;
|
||||
s->si[1].conn->t.sock.fd = -1; /* just to help with debugging */
|
||||
|
@ -2806,16 +2806,16 @@ int http_handle_stats(struct session *s, struct channel *req)
|
||||
struct uri_auth *uri_auth = s->be->uri_auth;
|
||||
const char *uri, *h, *lookup;
|
||||
|
||||
memset(&si->applet.ctx.stats, 0, sizeof(si->applet.ctx.stats));
|
||||
si->applet.ctx.stats.st_code = STAT_STATUS_INIT;
|
||||
si->applet.ctx.stats.flags |= STAT_FMT_HTML; /* assume HTML mode by default */
|
||||
memset(&si->appctx.ctx.stats, 0, sizeof(si->appctx.ctx.stats));
|
||||
si->appctx.ctx.stats.st_code = STAT_STATUS_INIT;
|
||||
si->appctx.ctx.stats.flags |= STAT_FMT_HTML; /* assume HTML mode by default */
|
||||
|
||||
uri = msg->chn->buf->p + msg->sl.rq.u;
|
||||
lookup = uri + uri_auth->uri_len;
|
||||
|
||||
for (h = lookup; h <= uri + msg->sl.rq.u_l - 3; h++) {
|
||||
if (memcmp(h, ";up", 3) == 0) {
|
||||
si->applet.ctx.stats.flags |= STAT_HIDE_DOWN;
|
||||
si->appctx.ctx.stats.flags |= STAT_HIDE_DOWN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2823,7 +2823,7 @@ int http_handle_stats(struct session *s, struct channel *req)
|
||||
if (uri_auth->refresh) {
|
||||
for (h = lookup; h <= uri + msg->sl.rq.u_l - 10; h++) {
|
||||
if (memcmp(h, ";norefresh", 10) == 0) {
|
||||
si->applet.ctx.stats.flags |= STAT_NO_REFRESH;
|
||||
si->appctx.ctx.stats.flags |= STAT_NO_REFRESH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2831,7 +2831,7 @@ int http_handle_stats(struct session *s, struct channel *req)
|
||||
|
||||
for (h = lookup; h <= uri + msg->sl.rq.u_l - 4; h++) {
|
||||
if (memcmp(h, ";csv", 4) == 0) {
|
||||
si->applet.ctx.stats.flags &= ~STAT_FMT_HTML;
|
||||
si->appctx.ctx.stats.flags &= ~STAT_FMT_HTML;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2840,10 +2840,10 @@ int http_handle_stats(struct session *s, struct channel *req)
|
||||
if (memcmp(h, ";st=", 4) == 0) {
|
||||
int i;
|
||||
h += 4;
|
||||
si->applet.ctx.stats.st_code = STAT_STATUS_UNKN;
|
||||
si->appctx.ctx.stats.st_code = STAT_STATUS_UNKN;
|
||||
for (i = STAT_STATUS_INIT + 1; i < STAT_STATUS_SIZE; i++) {
|
||||
if (strncmp(stat_status_codes[i], h, 4) == 0) {
|
||||
si->applet.ctx.stats.st_code = i;
|
||||
si->appctx.ctx.stats.st_code = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2851,8 +2851,8 @@ int http_handle_stats(struct session *s, struct channel *req)
|
||||
}
|
||||
}
|
||||
|
||||
si->applet.ctx.stats.scope_str = 0;
|
||||
si->applet.ctx.stats.scope_len = 0;
|
||||
si->appctx.ctx.stats.scope_str = 0;
|
||||
si->appctx.ctx.stats.scope_len = 0;
|
||||
for (h = lookup; h <= uri + msg->sl.rq.u_l - 8; h++) {
|
||||
if (memcmp(h, STAT_SCOPE_INPUT_NAME "=", strlen(STAT_SCOPE_INPUT_NAME) + 1) == 0) {
|
||||
int itx = 0;
|
||||
@ -2862,7 +2862,7 @@ int http_handle_stats(struct session *s, struct channel *req)
|
||||
|
||||
h += strlen(STAT_SCOPE_INPUT_NAME) + 1;
|
||||
h2 = h;
|
||||
si->applet.ctx.stats.scope_str = h2 - msg->chn->buf->p;
|
||||
si->appctx.ctx.stats.scope_str = h2 - msg->chn->buf->p;
|
||||
while (*h != ';' && *h != '\0' && *h != '&' && *h != ' ' && *h != '\n') {
|
||||
itx++;
|
||||
h++;
|
||||
@ -2870,16 +2870,16 @@ int http_handle_stats(struct session *s, struct channel *req)
|
||||
|
||||
if (itx > STAT_SCOPE_TXT_MAXLEN)
|
||||
itx = STAT_SCOPE_TXT_MAXLEN;
|
||||
si->applet.ctx.stats.scope_len = itx;
|
||||
si->appctx.ctx.stats.scope_len = itx;
|
||||
|
||||
/* scope_txt = search query, si->applet.ctx.stats.scope_len is always <= STAT_SCOPE_TXT_MAXLEN */
|
||||
/* scope_txt = search query, si->appctx.ctx.stats.scope_len is always <= STAT_SCOPE_TXT_MAXLEN */
|
||||
memcpy(scope_txt, h2, itx);
|
||||
scope_txt[itx] = '\0';
|
||||
err = invalid_char(scope_txt);
|
||||
if (err) {
|
||||
/* bad char in search text => clear scope */
|
||||
si->applet.ctx.stats.scope_str = 0;
|
||||
si->applet.ctx.stats.scope_len = 0;
|
||||
si->appctx.ctx.stats.scope_str = 0;
|
||||
si->appctx.ctx.stats.scope_len = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -2898,14 +2898,14 @@ int http_handle_stats(struct session *s, struct channel *req)
|
||||
|
||||
if (ret) {
|
||||
/* no rule, or the rule matches */
|
||||
s->rep->prod->applet.ctx.stats.flags |= STAT_ADMIN;
|
||||
s->rep->prod->appctx.ctx.stats.flags |= STAT_ADMIN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Was the status page requested with a POST ? */
|
||||
if (unlikely(txn->meth == HTTP_METH_POST && txn->req.body_len > 0)) {
|
||||
if (si->applet.ctx.stats.flags & STAT_ADMIN) {
|
||||
if (si->appctx.ctx.stats.flags & STAT_ADMIN) {
|
||||
if (msg->msg_state < HTTP_MSG_100_SENT) {
|
||||
/* If we have HTTP/1.1 and Expect: 100-continue, then we must
|
||||
* send an HTTP/1.1 100 Continue intermediate response.
|
||||
@ -2922,21 +2922,21 @@ int http_handle_stats(struct session *s, struct channel *req)
|
||||
msg->msg_state = HTTP_MSG_100_SENT;
|
||||
s->logs.tv_request = now; /* update the request timer to reflect full request */
|
||||
}
|
||||
s->rep->prod->applet.st0 = STAT_HTTP_POST;
|
||||
s->rep->prod->appctx.st0 = STAT_HTTP_POST;
|
||||
}
|
||||
else {
|
||||
si->applet.ctx.stats.st_code = STAT_STATUS_DENY;
|
||||
s->rep->prod->applet.st0 = STAT_HTTP_LAST;
|
||||
si->appctx.ctx.stats.st_code = STAT_STATUS_DENY;
|
||||
s->rep->prod->appctx.st0 = STAT_HTTP_LAST;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* So it was another method (GET/HEAD) */
|
||||
s->rep->prod->applet.st0 = STAT_HTTP_HEAD;
|
||||
s->rep->prod->appctx.st0 = STAT_HTTP_HEAD;
|
||||
}
|
||||
|
||||
s->task->nice = -32; /* small boost for HTTP statistics */
|
||||
stream_int_register_handler(s->rep->prod, &http_stats_applet);
|
||||
s->rep->prod->applet.st1 = s->rep->prod->applet.st2 = 0;
|
||||
s->rep->prod->appctx.st1 = s->rep->prod->appctx.st2 = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user