[REORG] stream_interface: move the st0, st1 and private members to the applet

Those fields are only used by the applets, so let's move them to the
struct.
This commit is contained in:
Willy Tarreau 2011-02-13 13:25:14 +01:00
parent b24281b0ff
commit bc4af0573c
4 changed files with 176 additions and 176 deletions

View File

@ -105,9 +105,9 @@ struct stream_interface {
void *err_loc; /* commonly the server, NULL when SI_ET_NONE */ void *err_loc; /* commonly the server, NULL when SI_ET_NONE */
struct { struct {
struct si_applet *handler; /* applet to use instead of doing I/O */ struct si_applet *handler; /* applet to use instead of doing I/O */
void *private; /* may be used by any function above */
unsigned int st0, st1; /* may be used by any function above */
} applet; } applet;
void *private; /* may be used by any function above */
unsigned int st0, st1; /* may be used by any function above */
}; };
/* An applet designed to run in a stream interface */ /* An applet designed to run in a stream interface */

View File

@ -85,9 +85,9 @@ int stats_accept(struct session *s)
{ {
/* we have a dedicated I/O handler for the stats */ /* we have a dedicated I/O handler for the stats */
stream_int_register_handler(&s->si[1], &cli_applet); stream_int_register_handler(&s->si[1], &cli_applet);
s->si[1].private = s; s->si[1].applet.private = s;
s->si[1].st1 = 0; s->si[1].applet.st1 = 0;
s->si[1].st0 = STAT_CLI_INIT; s->si[1].applet.st0 = STAT_CLI_INIT;
tv_zero(&s->logs.tv_request); tv_zero(&s->logs.tv_request);
s->logs.t_queue = 0; s->logs.t_queue = 0;
@ -316,13 +316,13 @@ int print_csv_header(struct chunk *msg)
/* Processes the stats interpreter on the statistics socket. This function is /* Processes the stats interpreter on the statistics socket. This function is
* called from an applet running in a stream interface. The function returns 1 * called from an applet running in a stream interface. The function returns 1
* if the request was understood, otherwise zero. It sets si->st0 to a value * if the request was understood, otherwise zero. It sets si->applet.st0 to a value
* designating the function which will have to process the request, which can * designating the function which will have to process the request, which can
* also be the print function to display the return message set into cli.msg. * also be the print function to display the return message set into cli.msg.
*/ */
int stats_sock_parse_request(struct stream_interface *si, char *line) int stats_sock_parse_request(struct stream_interface *si, char *line)
{ {
struct session *s = si->private; struct session *s = si->applet.private;
char *args[MAX_STATS_ARGS + 1]; char *args[MAX_STATS_ARGS + 1];
int arg; int arg;
@ -362,19 +362,19 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
s->data_ctx.stats.flags |= STAT_SHOW_STAT; s->data_ctx.stats.flags |= STAT_SHOW_STAT;
s->data_ctx.stats.flags |= STAT_FMT_CSV; s->data_ctx.stats.flags |= STAT_FMT_CSV;
s->data_state = DATA_ST_INIT; s->data_state = DATA_ST_INIT;
si->st0 = STAT_CLI_O_INFO; // stats_dump_raw_to_buffer si->applet.st0 = STAT_CLI_O_INFO; // stats_dump_raw_to_buffer
} }
else if (strcmp(args[1], "info") == 0) { else if (strcmp(args[1], "info") == 0) {
s->data_ctx.stats.flags |= STAT_SHOW_INFO; s->data_ctx.stats.flags |= STAT_SHOW_INFO;
s->data_ctx.stats.flags |= STAT_FMT_CSV; s->data_ctx.stats.flags |= STAT_FMT_CSV;
s->data_state = DATA_ST_INIT; s->data_state = DATA_ST_INIT;
si->st0 = STAT_CLI_O_INFO; // stats_dump_raw_to_buffer si->applet.st0 = STAT_CLI_O_INFO; // stats_dump_raw_to_buffer
} }
else if (strcmp(args[1], "sess") == 0) { else if (strcmp(args[1], "sess") == 0) {
s->data_state = DATA_ST_INIT; s->data_state = DATA_ST_INIT;
if (s->listener->perm.ux.level < ACCESS_LVL_OPER) { if (s->listener->perm.ux.level < ACCESS_LVL_OPER) {
s->data_ctx.cli.msg = stats_permission_denied_msg; s->data_ctx.cli.msg = stats_permission_denied_msg;
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
if (*args[2]) if (*args[2])
@ -383,12 +383,12 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
s->data_ctx.sess.target = NULL; s->data_ctx.sess.target = NULL;
s->data_ctx.sess.section = 0; /* start with session status */ s->data_ctx.sess.section = 0; /* start with session status */
s->data_ctx.sess.pos = 0; s->data_ctx.sess.pos = 0;
si->st0 = STAT_CLI_O_SESS; // stats_dump_sess_to_buffer si->applet.st0 = STAT_CLI_O_SESS; // stats_dump_sess_to_buffer
} }
else if (strcmp(args[1], "errors") == 0) { else if (strcmp(args[1], "errors") == 0) {
if (s->listener->perm.ux.level < ACCESS_LVL_OPER) { if (s->listener->perm.ux.level < ACCESS_LVL_OPER) {
s->data_ctx.cli.msg = stats_permission_denied_msg; s->data_ctx.cli.msg = stats_permission_denied_msg;
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
if (*args[2]) if (*args[2])
@ -397,7 +397,7 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
s->data_ctx.errors.iid = -1; s->data_ctx.errors.iid = -1;
s->data_ctx.errors.px = NULL; s->data_ctx.errors.px = NULL;
s->data_state = DATA_ST_INIT; s->data_state = DATA_ST_INIT;
si->st0 = STAT_CLI_O_ERR; // stats_dump_errors_to_buffer si->applet.st0 = STAT_CLI_O_ERR; // stats_dump_errors_to_buffer
} }
else if (strcmp(args[1], "table") == 0) { else if (strcmp(args[1], "table") == 0) {
s->data_state = DATA_ST_INIT; s->data_state = DATA_ST_INIT;
@ -405,7 +405,7 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
s->data_ctx.table.target = find_stktable(args[2]); s->data_ctx.table.target = find_stktable(args[2]);
if (!s->data_ctx.table.target) { if (!s->data_ctx.table.target) {
s->data_ctx.cli.msg = "No such table\n"; s->data_ctx.cli.msg = "No such table\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
} }
@ -418,38 +418,38 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
s->data_ctx.table.data_type = stktable_get_data_type(args[3] + 5); s->data_ctx.table.data_type = stktable_get_data_type(args[3] + 5);
if (s->data_ctx.table.data_type < 0) { if (s->data_ctx.table.data_type < 0) {
s->data_ctx.cli.msg = "Unknown data type\n"; s->data_ctx.cli.msg = "Unknown data type\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
if (!((struct proxy *)s->data_ctx.table.target)->table.data_ofs[s->data_ctx.table.data_type]) { if (!((struct proxy *)s->data_ctx.table.target)->table.data_ofs[s->data_ctx.table.data_type]) {
s->data_ctx.cli.msg = "Data type not stored in this table\n"; s->data_ctx.cli.msg = "Data type not stored in this table\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
s->data_ctx.table.data_op = get_std_op(args[4]); s->data_ctx.table.data_op = get_std_op(args[4]);
if (s->data_ctx.table.data_op < 0) { if (s->data_ctx.table.data_op < 0) {
s->data_ctx.cli.msg = "Require and operator among \"eq\", \"ne\", \"le\", \"ge\", \"lt\", \"gt\"\n"; s->data_ctx.cli.msg = "Require and operator among \"eq\", \"ne\", \"le\", \"ge\", \"lt\", \"gt\"\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
if (!*args[5] || strl2llrc(args[5], strlen(args[5]), &s->data_ctx.table.value) != 0) { if (!*args[5] || strl2llrc(args[5], strlen(args[5]), &s->data_ctx.table.value) != 0) {
s->data_ctx.cli.msg = "Require a valid integer value to compare against\n"; s->data_ctx.cli.msg = "Require a valid integer value to compare against\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
} }
else if (*args[3]) { else if (*args[3]) {
s->data_ctx.cli.msg = "Optional argument only supports \"data.<store_data_type>\" <operator> <value>\n"; s->data_ctx.cli.msg = "Optional argument only supports \"data.<store_data_type>\" <operator> <value>\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
s->data_ctx.table.proxy = NULL; s->data_ctx.table.proxy = NULL;
s->data_ctx.table.entry = NULL; s->data_ctx.table.entry = NULL;
si->st0 = STAT_CLI_O_TAB; // stats_dump_table_to_buffer si->applet.st0 = STAT_CLI_O_TAB; // stats_dump_table_to_buffer
} }
else { /* neither "stat" nor "info" nor "sess" nor "errors" no "table" */ else { /* neither "stat" nor "info" nor "sess" nor "errors" no "table" */
return 0; return 0;
@ -469,7 +469,7 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
if (s->listener->perm.ux.level < ACCESS_LVL_OPER || if (s->listener->perm.ux.level < ACCESS_LVL_OPER ||
(clrall && s->listener->perm.ux.level < ACCESS_LVL_ADMIN)) { (clrall && s->listener->perm.ux.level < ACCESS_LVL_ADMIN)) {
s->data_ctx.cli.msg = stats_permission_denied_msg; s->data_ctx.cli.msg = stats_permission_denied_msg;
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
@ -513,7 +513,7 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
if (!*args[2]) { if (!*args[2]) {
s->data_ctx.cli.msg = "\"table\" argument expected\n"; s->data_ctx.cli.msg = "\"table\" argument expected\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
@ -521,19 +521,19 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
if (!px) { if (!px) {
s->data_ctx.cli.msg = "No such table\n"; s->data_ctx.cli.msg = "No such table\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
if (strcmp(args[3], "key") != 0) { if (strcmp(args[3], "key") != 0) {
s->data_ctx.cli.msg = "\"key\" argument expected\n"; s->data_ctx.cli.msg = "\"key\" argument expected\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
if (!*args[4]) { if (!*args[4]) {
s->data_ctx.cli.msg = "Key value expected\n"; s->data_ctx.cli.msg = "Key value expected\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
@ -543,14 +543,14 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
} }
else { else {
s->data_ctx.cli.msg = "Removing keys from non-ip tables is not supported\n"; s->data_ctx.cli.msg = "Removing keys from non-ip tables is not supported\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
/* check permissions */ /* check permissions */
if (s->listener->perm.ux.level < ACCESS_LVL_OPER) { if (s->listener->perm.ux.level < ACCESS_LVL_OPER) {
s->data_ctx.cli.msg = stats_permission_denied_msg; s->data_ctx.cli.msg = stats_permission_denied_msg;
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
@ -562,7 +562,7 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
else if (ts->ref_cnt) { else if (ts->ref_cnt) {
/* don't delete an entry which is currently referenced */ /* don't delete an entry which is currently referenced */
s->data_ctx.cli.msg = "Entry currently in use, cannot remove\n"; s->data_ctx.cli.msg = "Entry currently in use, cannot remove\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
@ -589,13 +589,13 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
if (!*line) { if (!*line) {
s->data_ctx.cli.msg = "Require 'backend/server'.\n"; s->data_ctx.cli.msg = "Require 'backend/server'.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
if (!get_backend_server(args[2], line, &px, &sv)) { if (!get_backend_server(args[2], line, &px, &sv)) {
s->data_ctx.cli.msg = px ? "No such server.\n" : "No such backend.\n"; s->data_ctx.cli.msg = px ? "No such server.\n" : "No such backend.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
@ -616,7 +616,7 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
if (s->listener->perm.ux.level < ACCESS_LVL_ADMIN) { if (s->listener->perm.ux.level < ACCESS_LVL_ADMIN) {
s->data_ctx.cli.msg = stats_permission_denied_msg; s->data_ctx.cli.msg = stats_permission_denied_msg;
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
@ -629,19 +629,19 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
if (!*line || !*args[3]) { if (!*line || !*args[3]) {
s->data_ctx.cli.msg = "Require 'backend/server' and 'weight' or 'weight%'.\n"; s->data_ctx.cli.msg = "Require 'backend/server' and 'weight' or 'weight%'.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
if (!get_backend_server(args[2], line, &px, &sv)) { if (!get_backend_server(args[2], line, &px, &sv)) {
s->data_ctx.cli.msg = px ? "No such server.\n" : "No such backend.\n"; s->data_ctx.cli.msg = px ? "No such server.\n" : "No such backend.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
if (px->state == PR_STSTOPPED) { if (px->state == PR_STSTOPPED) {
s->data_ctx.cli.msg = "Proxy is disabled.\n"; s->data_ctx.cli.msg = "Proxy is disabled.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
@ -652,7 +652,7 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
if (strchr(args[3], '%') != NULL) { if (strchr(args[3], '%') != NULL) {
if (w < 0 || w > 100) { if (w < 0 || w > 100) {
s->data_ctx.cli.msg = "Relative weight can only be set between 0 and 100% inclusive.\n"; s->data_ctx.cli.msg = "Relative weight can only be set between 0 and 100% inclusive.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
w = sv->iweight * w / 100; w = sv->iweight * w / 100;
@ -660,14 +660,14 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
else { else {
if (w < 0 || w > 256) { if (w < 0 || w > 256) {
s->data_ctx.cli.msg = "Absolute weight can only be between 0 and 256 inclusive.\n"; s->data_ctx.cli.msg = "Absolute weight can only be between 0 and 256 inclusive.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
} }
if (w && w != sv->iweight && !(px->lbprm.algo & BE_LB_PROP_DYN)) { if (w && w != sv->iweight && !(px->lbprm.algo & BE_LB_PROP_DYN)) {
s->data_ctx.cli.msg = "Backend is using a static LB algorithm and only accepts weights '0%' and '100%'.\n"; s->data_ctx.cli.msg = "Backend is using a static LB algorithm and only accepts weights '0%' and '100%'.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
@ -701,14 +701,14 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
if (!*args[3]) { if (!*args[3]) {
s->data_ctx.cli.msg = "Expects an integer value.\n"; s->data_ctx.cli.msg = "Expects an integer value.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
res = parse_time_err(args[3], &timeout, TIME_UNIT_S); res = parse_time_err(args[3], &timeout, TIME_UNIT_S);
if (res || timeout < 1) { if (res || timeout < 1) {
s->data_ctx.cli.msg = "Invalid timeout value.\n"; s->data_ctx.cli.msg = "Invalid timeout value.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
@ -717,7 +717,7 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
} }
else { else {
s->data_ctx.cli.msg = "'set timeout' only supports 'cli'.\n"; s->data_ctx.cli.msg = "'set timeout' only supports 'cli'.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
} }
@ -732,7 +732,7 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
if (s->listener->perm.ux.level < ACCESS_LVL_ADMIN) { if (s->listener->perm.ux.level < ACCESS_LVL_ADMIN) {
s->data_ctx.cli.msg = stats_permission_denied_msg; s->data_ctx.cli.msg = stats_permission_denied_msg;
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
@ -745,19 +745,19 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
if (!*line || !*args[2]) { if (!*line || !*args[2]) {
s->data_ctx.cli.msg = "Require 'backend/server'.\n"; s->data_ctx.cli.msg = "Require 'backend/server'.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
if (!get_backend_server(args[2], line, &px, &sv)) { if (!get_backend_server(args[2], line, &px, &sv)) {
s->data_ctx.cli.msg = px ? "No such server.\n" : "No such backend.\n"; s->data_ctx.cli.msg = px ? "No such server.\n" : "No such backend.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
if (px->state == PR_STSTOPPED) { if (px->state == PR_STSTOPPED) {
s->data_ctx.cli.msg = "Proxy is disabled.\n"; s->data_ctx.cli.msg = "Proxy is disabled.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
@ -793,7 +793,7 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
if (s->listener->perm.ux.level < ACCESS_LVL_ADMIN) { if (s->listener->perm.ux.level < ACCESS_LVL_ADMIN) {
s->data_ctx.cli.msg = stats_permission_denied_msg; s->data_ctx.cli.msg = stats_permission_denied_msg;
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
@ -806,19 +806,19 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
if (!*line || !*args[2]) { if (!*line || !*args[2]) {
s->data_ctx.cli.msg = "Require 'backend/server'.\n"; s->data_ctx.cli.msg = "Require 'backend/server'.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
if (!get_backend_server(args[2], line, &px, &sv)) { if (!get_backend_server(args[2], line, &px, &sv)) {
s->data_ctx.cli.msg = px ? "No such server.\n" : "No such backend.\n"; s->data_ctx.cli.msg = px ? "No such server.\n" : "No such backend.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
if (px->state == PR_STSTOPPED) { if (px->state == PR_STSTOPPED) {
s->data_ctx.cli.msg = "Proxy is disabled.\n"; s->data_ctx.cli.msg = "Proxy is disabled.\n";
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
return 1; return 1;
} }
@ -844,13 +844,13 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
* used to processes I/O from/to the stats unix socket. The system relies on a * used to processes I/O from/to the stats unix socket. The system relies on a
* state machine handling requests and various responses. We read a request, * state machine handling requests and various responses. We read a request,
* then we process it and send the response, and we possibly display a prompt. * then we process it and send the response, and we possibly display a prompt.
* Then we can read again. The state is stored in si->st0 and is one of the * Then we can read again. The state is stored in si->applet.st0 and is one of the
* STAT_CLI_* constants. si->st1 is used to indicate whether prompt is enabled * STAT_CLI_* constants. si->applet.st1 is used to indicate whether prompt is enabled
* or not. * or not.
*/ */
static void cli_io_handler(struct stream_interface *si) static void cli_io_handler(struct stream_interface *si)
{ {
struct session *s = si->private; struct session *s = si->applet.private;
struct buffer *req = si->ob; struct buffer *req = si->ob;
struct buffer *res = si->ib; struct buffer *res = si->ib;
int reql; int reql;
@ -860,20 +860,20 @@ static void cli_io_handler(struct stream_interface *si)
goto out; goto out;
while (1) { while (1) {
if (si->st0 == STAT_CLI_INIT) { if (si->applet.st0 == STAT_CLI_INIT) {
/* Stats output not initialized yet */ /* Stats output not initialized yet */
memset(&s->data_ctx.stats, 0, sizeof(s->data_ctx.stats)); memset(&s->data_ctx.stats, 0, sizeof(s->data_ctx.stats));
s->data_source = DATA_SRC_STATS; s->data_source = DATA_SRC_STATS;
si->st0 = STAT_CLI_GETREQ; si->applet.st0 = STAT_CLI_GETREQ;
} }
else if (si->st0 == STAT_CLI_END) { else if (si->applet.st0 == STAT_CLI_END) {
/* Let's close for real now. We just close the request /* Let's close for real now. We just close the request
* side, the conditions below will complete if needed. * side, the conditions below will complete if needed.
*/ */
si->shutw(si); si->shutw(si);
break; break;
} }
else if (si->st0 == STAT_CLI_GETREQ) { else if (si->applet.st0 == STAT_CLI_GETREQ) {
/* ensure we have some output room left in the event we /* ensure we have some output room left in the event we
* would want to return some info right after parsing. * would want to return some info right after parsing.
*/ */
@ -884,7 +884,7 @@ static void cli_io_handler(struct stream_interface *si)
if (reql <= 0) { /* closed or EOL not found */ if (reql <= 0) { /* closed or EOL not found */
if (reql == 0) if (reql == 0)
break; break;
si->st0 = STAT_CLI_END; si->applet.st0 = STAT_CLI_END;
continue; continue;
} }
@ -904,7 +904,7 @@ static void cli_io_handler(struct stream_interface *si)
*/ */
len = reql - 1; len = reql - 1;
if (trash[len] != '\n') { if (trash[len] != '\n') {
si->st0 = STAT_CLI_END; si->applet.st0 = STAT_CLI_END;
continue; continue;
} }
@ -913,30 +913,30 @@ static void cli_io_handler(struct stream_interface *si)
trash[len] = '\0'; trash[len] = '\0';
si->st0 = STAT_CLI_PROMPT; si->applet.st0 = STAT_CLI_PROMPT;
if (len) { if (len) {
if (strcmp(trash, "quit") == 0) { if (strcmp(trash, "quit") == 0) {
si->st0 = STAT_CLI_END; si->applet.st0 = STAT_CLI_END;
continue; continue;
} }
else if (strcmp(trash, "prompt") == 0) else if (strcmp(trash, "prompt") == 0)
si->st1 = !si->st1; si->applet.st1 = !si->applet.st1;
else if (strcmp(trash, "help") == 0 || else if (strcmp(trash, "help") == 0 ||
!stats_sock_parse_request(si, trash)) { !stats_sock_parse_request(si, trash)) {
s->data_ctx.cli.msg = stats_sock_usage_msg; s->data_ctx.cli.msg = stats_sock_usage_msg;
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
} }
/* NB: stats_sock_parse_request() may have put /* NB: stats_sock_parse_request() may have put
* another STAT_CLI_O_* into si->st0. * another STAT_CLI_O_* into si->applet.st0.
*/ */
} }
else if (!si->st1) { else if (!si->applet.st1) {
/* if prompt is disabled, print help on empty lines, /* if prompt is disabled, print help on empty lines,
* so that the user at least knows how to enable * so that the user at least knows how to enable
* prompt and find help. * prompt and find help.
*/ */
s->data_ctx.cli.msg = stats_sock_usage_msg; s->data_ctx.cli.msg = stats_sock_usage_msg;
si->st0 = STAT_CLI_PRINT; si->applet.st0 = STAT_CLI_PRINT;
} }
/* re-adjust req buffer */ /* re-adjust req buffer */
@ -945,44 +945,44 @@ static void cli_io_handler(struct stream_interface *si)
} }
else { /* output functions: first check if the output buffer is closed then abort */ else { /* output functions: first check if the output buffer is closed then abort */
if (res->flags & (BF_SHUTR_NOW|BF_SHUTR)) { if (res->flags & (BF_SHUTR_NOW|BF_SHUTR)) {
si->st0 = STAT_CLI_END; si->applet.st0 = STAT_CLI_END;
continue; continue;
} }
switch (si->st0) { switch (si->applet.st0) {
case STAT_CLI_PRINT: case STAT_CLI_PRINT:
if (buffer_feed(si->ib, s->data_ctx.cli.msg) < 0) if (buffer_feed(si->ib, s->data_ctx.cli.msg) < 0)
si->st0 = STAT_CLI_PROMPT; si->applet.st0 = STAT_CLI_PROMPT;
break; break;
case STAT_CLI_O_INFO: case STAT_CLI_O_INFO:
if (stats_dump_raw_to_buffer(s, res)) if (stats_dump_raw_to_buffer(s, res))
si->st0 = STAT_CLI_PROMPT; si->applet.st0 = STAT_CLI_PROMPT;
break; break;
case STAT_CLI_O_SESS: case STAT_CLI_O_SESS:
if (stats_dump_sess_to_buffer(s, res)) if (stats_dump_sess_to_buffer(s, res))
si->st0 = STAT_CLI_PROMPT; si->applet.st0 = STAT_CLI_PROMPT;
break; break;
case STAT_CLI_O_ERR: /* errors dump */ case STAT_CLI_O_ERR: /* errors dump */
if (stats_dump_errors_to_buffer(s, res)) if (stats_dump_errors_to_buffer(s, res))
si->st0 = STAT_CLI_PROMPT; si->applet.st0 = STAT_CLI_PROMPT;
break; break;
case STAT_CLI_O_TAB: case STAT_CLI_O_TAB:
if (stats_dump_table_to_buffer(s, res)) if (stats_dump_table_to_buffer(s, res))
si->st0 = STAT_CLI_PROMPT; si->applet.st0 = STAT_CLI_PROMPT;
break; break;
default: /* abnormal state */ default: /* abnormal state */
si->st0 = STAT_CLI_PROMPT; si->applet.st0 = STAT_CLI_PROMPT;
break; break;
} }
/* The post-command prompt is either LF alone or LF + '> ' in interactive mode */ /* The post-command prompt is either LF alone or LF + '> ' in interactive mode */
if (si->st0 == STAT_CLI_PROMPT) { if (si->applet.st0 == STAT_CLI_PROMPT) {
if (buffer_feed(si->ib, si->st1 ? "\n> " : "\n") < 0) if (buffer_feed(si->ib, si->applet.st1 ? "\n> " : "\n") < 0)
si->st0 = STAT_CLI_GETREQ; si->applet.st0 = STAT_CLI_GETREQ;
} }
/* If the output functions are still there, it means they require more room. */ /* If the output functions are still there, it means they require more room. */
if (si->st0 >= STAT_CLI_OUTPUT) if (si->applet.st0 >= STAT_CLI_OUTPUT)
break; break;
/* Now we close the output if one of the writers did so, /* Now we close the output if one of the writers did so,
@ -990,17 +990,17 @@ static void cli_io_handler(struct stream_interface *si)
* buffer is empty. This still allows pipelined requests * buffer is empty. This still allows pipelined requests
* to be sent in non-interactive mode. * to be sent in non-interactive mode.
*/ */
if ((res->flags & (BF_SHUTW|BF_SHUTW_NOW)) || (!si->st1 && !req->send_max)) { if ((res->flags & (BF_SHUTW|BF_SHUTW_NOW)) || (!si->applet.st1 && !req->send_max)) {
si->st0 = STAT_CLI_END; si->applet.st0 = STAT_CLI_END;
continue; continue;
} }
/* switch state back to GETREQ to read next requests */ /* switch state back to GETREQ to read next requests */
si->st0 = STAT_CLI_GETREQ; si->applet.st0 = STAT_CLI_GETREQ;
} }
} }
if ((res->flags & BF_SHUTR) && (si->state == SI_ST_EST) && (si->st0 != STAT_CLI_GETREQ)) { if ((res->flags & BF_SHUTR) && (si->state == SI_ST_EST) && (si->applet.st0 != STAT_CLI_GETREQ)) {
DPRINTF(stderr, "%s@%d: si to buf closed. req=%08x, res=%08x, st=%d\n", DPRINTF(stderr, "%s@%d: si to buf closed. req=%08x, res=%08x, st=%d\n",
__FUNCTION__, __LINE__, req->flags, res->flags, si->state); __FUNCTION__, __LINE__, req->flags, res->flags, si->state);
/* Other size has closed, let's abort if we have no more processing to do /* Other size has closed, let's abort if we have no more processing to do
@ -1011,7 +1011,7 @@ static void cli_io_handler(struct stream_interface *si)
si->shutw(si); si->shutw(si);
} }
if ((req->flags & BF_SHUTW) && (si->state == SI_ST_EST) && (si->st0 < STAT_CLI_OUTPUT)) { if ((req->flags & BF_SHUTW) && (si->state == SI_ST_EST) && (si->applet.st0 < STAT_CLI_OUTPUT)) {
DPRINTF(stderr, "%s@%d: buf to si closed. req=%08x, res=%08x, st=%d\n", DPRINTF(stderr, "%s@%d: buf to si closed. req=%08x, res=%08x, st=%d\n",
__FUNCTION__, __LINE__, req->flags, res->flags, si->state); __FUNCTION__, __LINE__, req->flags, res->flags, si->state);
/* We have no more processing to do, and nothing more to send, and /* We have no more processing to do, and nothing more to send, and
@ -1197,12 +1197,12 @@ int stats_http_redir(struct session *s, struct buffer *rep, struct uri_auth *uri
/* This I/O handler runs as an applet embedded in a stream interface. It is /* This I/O handler runs as an applet embedded in a stream interface. It is
* used to send HTTP stats over a TCP socket. The mechanism is very simple. * used to send HTTP stats over a TCP socket. The mechanism is very simple.
* si->st0 becomes non-zero once the transfer is finished. The handler * si->applet.st0 becomes non-zero once the transfer is finished. The handler
* automatically unregisters itself once transfer is complete. * automatically unregisters itself once transfer is complete.
*/ */
static void http_stats_io_handler(struct stream_interface *si) static void http_stats_io_handler(struct stream_interface *si)
{ {
struct session *s = si->private; struct session *s = si->applet.private;
struct buffer *req = si->ob; struct buffer *req = si->ob;
struct buffer *res = si->ib; struct buffer *res = si->ib;
@ -1211,17 +1211,17 @@ static void http_stats_io_handler(struct stream_interface *si)
/* check that the output is not closed */ /* check that the output is not closed */
if (res->flags & (BF_SHUTW|BF_SHUTW_NOW)) if (res->flags & (BF_SHUTW|BF_SHUTW_NOW))
si->st0 = 1; si->applet.st0 = 1;
if (!si->st0) { if (!si->applet.st0) {
if (s->txn.meth == HTTP_METH_POST) { if (s->txn.meth == HTTP_METH_POST) {
if (stats_http_redir(s, res, s->be->uri_auth)) { if (stats_http_redir(s, res, s->be->uri_auth)) {
si->st0 = 1; si->applet.st0 = 1;
si->shutw(si); si->shutw(si);
} }
} else { } else {
if (stats_dump_http(s, res, s->be->uri_auth)) { if (stats_dump_http(s, res, s->be->uri_auth)) {
si->st0 = 1; si->applet.st0 = 1;
si->shutw(si); si->shutw(si);
} }
} }
@ -1230,7 +1230,7 @@ static void http_stats_io_handler(struct stream_interface *si)
if ((res->flags & BF_SHUTR) && (si->state == SI_ST_EST)) if ((res->flags & BF_SHUTR) && (si->state == SI_ST_EST))
si->shutw(si); si->shutw(si);
if ((req->flags & BF_SHUTW) && (si->state == SI_ST_EST) && si->st0) { if ((req->flags & BF_SHUTW) && (si->state == SI_ST_EST) && si->applet.st0) {
si->shutr(si); si->shutr(si);
res->flags |= BF_READ_NULL; res->flags |= BF_READ_NULL;
} }

View File

@ -186,10 +186,10 @@ void peer_session_release(struct stream_interface *si)
{ {
struct task *t= (struct task *)si->owner; struct task *t= (struct task *)si->owner;
struct session *s = (struct session *)t->context; struct session *s = (struct session *)t->context;
struct peer_session *ps = (struct peer_session *)si->private; struct peer_session *ps = (struct peer_session *)si->applet.private;
/* si->private is not a peer session */ /* si->applet.private is not a peer session */
if (si->st0 < PEER_SESSION_SENDSUCCESS) if (si->applet.st0 < PEER_SESSION_SENDSUCCESS)
return; return;
/* peer session identified */ /* peer session identified */
@ -226,21 +226,21 @@ static void peer_io_handler(struct stream_interface *si)
while (1) { while (1) {
switchstate: switchstate:
switch(si->st0) { switch(si->applet.st0) {
case PEER_SESSION_ACCEPT: case PEER_SESSION_ACCEPT:
si->private = NULL; si->applet.private = NULL;
si->st0 = PEER_SESSION_GETVERSION; si->applet.st0 = PEER_SESSION_GETVERSION;
/* fall through */ /* fall through */
case PEER_SESSION_GETVERSION: case PEER_SESSION_GETVERSION:
reql = buffer_get_line(si->ob, trash, sizeof(trash)); reql = buffer_get_line(si->ob, trash, sizeof(trash));
if (reql <= 0) { /* closed or EOL not found */ if (reql <= 0) { /* closed or EOL not found */
if (reql == 0) if (reql == 0)
goto out; goto out;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
if (trash[reql-1] != '\n') { if (trash[reql-1] != '\n') {
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
else if (reql > 1 && (trash[reql-2] == '\r')) else if (reql > 1 && (trash[reql-2] == '\r'))
@ -252,26 +252,26 @@ static void peer_io_handler(struct stream_interface *si)
/* test version */ /* test version */
if (strcmp(PEER_SESSION_PROTO_NAME " 1.0", trash) != 0) { if (strcmp(PEER_SESSION_PROTO_NAME " 1.0", trash) != 0) {
si->st0 = PEER_SESSION_EXIT; si->applet.st0 = PEER_SESSION_EXIT;
si->st1 = PEER_SESSION_ERRVERSION; si->applet.st1 = PEER_SESSION_ERRVERSION;
/* test protocol */ /* test protocol */
if (strncmp(PEER_SESSION_PROTO_NAME " ", trash, strlen(PEER_SESSION_PROTO_NAME)+1) != 0) if (strncmp(PEER_SESSION_PROTO_NAME " ", trash, strlen(PEER_SESSION_PROTO_NAME)+1) != 0)
si->st1 = PEER_SESSION_ERRPROTO; si->applet.st1 = PEER_SESSION_ERRPROTO;
goto switchstate; goto switchstate;
} }
si->st0 = PEER_SESSION_GETHOST; si->applet.st0 = PEER_SESSION_GETHOST;
/* fall through */ /* fall through */
case PEER_SESSION_GETHOST: case PEER_SESSION_GETHOST:
reql = buffer_get_line(si->ob, trash, sizeof(trash)); reql = buffer_get_line(si->ob, trash, sizeof(trash));
if (reql <= 0) { /* closed or EOL not found */ if (reql <= 0) { /* closed or EOL not found */
if (reql == 0) if (reql == 0)
goto out; goto out;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
if (trash[reql-1] != '\n') { if (trash[reql-1] != '\n') {
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
else if (reql > 1 && (trash[reql-2] == '\r')) else if (reql > 1 && (trash[reql-2] == '\r'))
@ -283,12 +283,12 @@ static void peer_io_handler(struct stream_interface *si)
/* test hostname match */ /* test hostname match */
if (strcmp(localpeer, trash) != 0) { if (strcmp(localpeer, trash) != 0) {
si->st0 = PEER_SESSION_EXIT; si->applet.st0 = PEER_SESSION_EXIT;
si->st1 = PEER_SESSION_ERRHOST; si->applet.st1 = PEER_SESSION_ERRHOST;
goto switchstate; goto switchstate;
} }
si->st0 = PEER_SESSION_GETPEER; si->applet.st0 = PEER_SESSION_GETPEER;
/* fall through */ /* fall through */
case PEER_SESSION_GETPEER: { case PEER_SESSION_GETPEER: {
struct peer *curpeer; struct peer *curpeer;
@ -297,12 +297,12 @@ static void peer_io_handler(struct stream_interface *si)
if (reql <= 0) { /* closed or EOL not found */ if (reql <= 0) { /* closed or EOL not found */
if (reql == 0) if (reql == 0)
goto out; goto out;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
if (trash[reql-1] != '\n') { if (trash[reql-1] != '\n') {
/* Incomplete line, we quit */ /* Incomplete line, we quit */
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
else if (reql > 1 && (trash[reql-2] == '\r')) else if (reql > 1 && (trash[reql-2] == '\r'))
@ -315,8 +315,8 @@ static void peer_io_handler(struct stream_interface *si)
/* parse line "<peer name> <pid>" */ /* parse line "<peer name> <pid>" */
p = strchr(trash, ' '); p = strchr(trash, ' ');
if (!p) { if (!p) {
si->st0 = PEER_SESSION_EXIT; si->applet.st0 = PEER_SESSION_EXIT;
si->st1 = PEER_SESSION_ERRPROTO; si->applet.st1 = PEER_SESSION_ERRPROTO;
goto switchstate; goto switchstate;
} }
*p = 0; *p = 0;
@ -329,17 +329,17 @@ static void peer_io_handler(struct stream_interface *si)
/* if unknown peer */ /* if unknown peer */
if (!curpeer) { if (!curpeer) {
si->st0 = PEER_SESSION_EXIT; si->applet.st0 = PEER_SESSION_EXIT;
si->st1 = PEER_SESSION_ERRPEER; si->applet.st1 = PEER_SESSION_ERRPEER;
goto switchstate; goto switchstate;
} }
si->private = curpeer; si->applet.private = curpeer;
si->st0 = PEER_SESSION_GETTABLE; si->applet.st0 = PEER_SESSION_GETTABLE;
/* fall through */ /* fall through */
} }
case PEER_SESSION_GETTABLE: { case PEER_SESSION_GETTABLE: {
struct peer *curpeer = (struct peer *)si->private; struct peer *curpeer = (struct peer *)si->applet.private;
struct shared_table *st; struct shared_table *st;
struct peer_session *ps = NULL; struct peer_session *ps = NULL;
unsigned long key_type; unsigned long key_type;
@ -350,16 +350,16 @@ static void peer_io_handler(struct stream_interface *si)
if (reql <= 0) { /* closed or EOL not found */ if (reql <= 0) { /* closed or EOL not found */
if (reql == 0) if (reql == 0)
goto out; goto out;
si->private = NULL; si->applet.private = NULL;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
/* Re init si->private to null, to handle correctly a release case */ /* Re init si->applet.private to null, to handle correctly a release case */
si->private = NULL; si->applet.private = NULL;
if (trash[reql-1] != '\n') { if (trash[reql-1] != '\n') {
/* Incomplete line, we quit */ /* Incomplete line, we quit */
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
else if (reql > 1 && (trash[reql-2] == '\r')) else if (reql > 1 && (trash[reql-2] == '\r'))
@ -372,8 +372,8 @@ static void peer_io_handler(struct stream_interface *si)
/* Parse line "<table name> <type> <size>" */ /* Parse line "<table name> <type> <size>" */
p = strchr(trash, ' '); p = strchr(trash, ' ');
if (!p) { if (!p) {
si->st0 = PEER_SESSION_EXIT; si->applet.st0 = PEER_SESSION_EXIT;
si->st1 = PEER_SESSION_ERRPROTO; si->applet.st1 = PEER_SESSION_ERRPROTO;
goto switchstate; goto switchstate;
} }
*p = 0; *p = 0;
@ -381,9 +381,9 @@ static void peer_io_handler(struct stream_interface *si)
p = strchr(p+1, ' '); p = strchr(p+1, ' ');
if (!p) { if (!p) {
si->private = NULL; si->applet.private = NULL;
si->st0 = PEER_SESSION_EXIT; si->applet.st0 = PEER_SESSION_EXIT;
si->st1 = PEER_SESSION_ERRPROTO; si->applet.st1 = PEER_SESSION_ERRPROTO;
goto switchstate; goto switchstate;
} }
@ -393,15 +393,15 @@ static void peer_io_handler(struct stream_interface *si)
if (strcmp(st->table->id, trash) == 0) { if (strcmp(st->table->id, trash) == 0) {
/* If key size mismatches */ /* If key size mismatches */
if (key_size != st->table->key_size) { if (key_size != st->table->key_size) {
si->st0 = PEER_SESSION_EXIT; si->applet.st0 = PEER_SESSION_EXIT;
si->st1 = PEER_SESSION_ERRSIZE; si->applet.st1 = PEER_SESSION_ERRSIZE;
goto switchstate; goto switchstate;
} }
/* If key type mismatches */ /* If key type mismatches */
if (key_type != st->table->type) { if (key_type != st->table->type) {
si->st0 = PEER_SESSION_EXIT; si->applet.st0 = PEER_SESSION_EXIT;
si->st1 = PEER_SESSION_ERRTYPE; si->applet.st1 = PEER_SESSION_ERRTYPE;
goto switchstate; goto switchstate;
} }
@ -412,8 +412,8 @@ static void peer_io_handler(struct stream_interface *si)
if (ps->session && ps->session != s) { if (ps->session && ps->session != s) {
if (ps->peer->local) { if (ps->peer->local) {
/* Local connection, reply a retry */ /* Local connection, reply a retry */
si->st0 = PEER_SESSION_EXIT; si->applet.st0 = PEER_SESSION_EXIT;
si->st1 = PEER_SESSION_TRYAGAIN; si->applet.st1 = PEER_SESSION_TRYAGAIN;
goto switchstate; goto switchstate;
} }
peer_session_forceshutdown(ps->session); peer_session_forceshutdown(ps->session);
@ -428,31 +428,31 @@ static void peer_io_handler(struct stream_interface *si)
/* If table not found */ /* If table not found */
if (!st){ if (!st){
si->st0 = PEER_SESSION_EXIT; si->applet.st0 = PEER_SESSION_EXIT;
si->st1 = PEER_SESSION_ERRTABLE; si->applet.st1 = PEER_SESSION_ERRTABLE;
goto switchstate; goto switchstate;
} }
/* If no peer session for current peer */ /* If no peer session for current peer */
if (!ps) { if (!ps) {
si->st0 = PEER_SESSION_EXIT; si->applet.st0 = PEER_SESSION_EXIT;
si->st1 = PEER_SESSION_ERRPEER; si->applet.st1 = PEER_SESSION_ERRPEER;
goto switchstate; goto switchstate;
} }
si->private = ps; si->applet.private = ps;
si->st0 = PEER_SESSION_SENDSUCCESS; si->applet.st0 = PEER_SESSION_SENDSUCCESS;
/* fall through */ /* fall through */
} }
case PEER_SESSION_SENDSUCCESS:{ case PEER_SESSION_SENDSUCCESS:{
struct peer_session *ps = (struct peer_session *)si->private; struct peer_session *ps = (struct peer_session *)si->applet.private;
repl = snprintf(trash, sizeof(trash), "%d\n", PEER_SESSION_SUCCESSCODE); repl = snprintf(trash, sizeof(trash), "%d\n", PEER_SESSION_SUCCESSCODE);
repl = buffer_put_block(si->ib, trash, repl); repl = buffer_put_block(si->ib, trash, repl);
if (repl <= 0) { if (repl <= 0) {
if (repl == -1) if (repl == -1)
goto out; goto out;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
@ -491,11 +491,11 @@ static void peer_io_handler(struct stream_interface *si)
ps->table->flags |= SHTABLE_F_RESYNC_ASSIGN; ps->table->flags |= SHTABLE_F_RESYNC_ASSIGN;
} }
/* switch to waiting message state */ /* switch to waiting message state */
si->st0 = PEER_SESSION_WAITMSG; si->applet.st0 = PEER_SESSION_WAITMSG;
goto switchstate; goto switchstate;
} }
case PEER_SESSION_CONNECT: { case PEER_SESSION_CONNECT: {
struct peer_session *ps = (struct peer_session *)si->private; struct peer_session *ps = (struct peer_session *)si->applet.private;
/* Send headers */ /* Send headers */
repl = snprintf(trash, sizeof(trash), repl = snprintf(trash, sizeof(trash),
@ -508,7 +508,7 @@ static void peer_io_handler(struct stream_interface *si)
(int)ps->table->table->key_size); (int)ps->table->table->key_size);
if (repl >= sizeof(trash)) { if (repl >= sizeof(trash)) {
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
@ -516,16 +516,16 @@ static void peer_io_handler(struct stream_interface *si)
if (repl <= 0) { if (repl <= 0) {
if (repl == -1) if (repl == -1)
goto out; goto out;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
/* switch to the waiting statuscode state */ /* switch to the waiting statuscode state */
si->st0 = PEER_SESSION_GETSTATUS; si->applet.st0 = PEER_SESSION_GETSTATUS;
/* fall through */ /* fall through */
} }
case PEER_SESSION_GETSTATUS: { case PEER_SESSION_GETSTATUS: {
struct peer_session *ps = (struct peer_session *)si->private; struct peer_session *ps = (struct peer_session *)si->applet.private;
if (si->ib->flags & BF_WRITE_PARTIAL) if (si->ib->flags & BF_WRITE_PARTIAL)
ps->statuscode = PEER_SESSION_CONNECTEDCODE; ps->statuscode = PEER_SESSION_CONNECTEDCODE;
@ -534,12 +534,12 @@ static void peer_io_handler(struct stream_interface *si)
if (reql <= 0) { /* closed or EOL not found */ if (reql <= 0) { /* closed or EOL not found */
if (reql == 0) if (reql == 0)
goto out; goto out;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
if (trash[reql-1] != '\n') { if (trash[reql-1] != '\n') {
/* Incomplete line, we quit */ /* Incomplete line, we quit */
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
else if (reql > 1 && (trash[reql-2] == '\r')) else if (reql > 1 && (trash[reql-2] == '\r'))
@ -589,14 +589,14 @@ static void peer_io_handler(struct stream_interface *si)
} }
else { else {
/* Status code is not success, abort */ /* Status code is not success, abort */
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
si->st0 = PEER_SESSION_WAITMSG; si->applet.st0 = PEER_SESSION_WAITMSG;
/* fall through */ /* fall through */
} }
case PEER_SESSION_WAITMSG: { case PEER_SESSION_WAITMSG: {
struct peer_session *ps = (struct peer_session *)si->private; struct peer_session *ps = (struct peer_session *)si->applet.private;
char c; char c;
int totl = 0; int totl = 0;
@ -606,7 +606,7 @@ static void peer_io_handler(struct stream_interface *si)
/* nothing to read */ /* nothing to read */
goto incomplete; goto incomplete;
} }
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
totl += reql; totl += reql;
@ -630,7 +630,7 @@ static void peer_io_handler(struct stream_interface *si)
if (reql == 0) { if (reql == 0) {
goto incomplete; goto incomplete;
} }
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
totl += reql; totl += reql;
@ -647,7 +647,7 @@ static void peer_io_handler(struct stream_interface *si)
if (reql == 0) { if (reql == 0) {
goto incomplete; goto incomplete;
} }
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
totl += reql; totl += reql;
@ -658,7 +658,7 @@ static void peer_io_handler(struct stream_interface *si)
if (reql == 0) { if (reql == 0) {
goto incomplete; goto incomplete;
} }
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
totl += reql; totl += reql;
@ -673,7 +673,7 @@ static void peer_io_handler(struct stream_interface *si)
if (reql == 0) { if (reql == 0) {
goto incomplete; goto incomplete;
} }
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
totl += reql; totl += reql;
@ -689,7 +689,7 @@ static void peer_io_handler(struct stream_interface *si)
if (reql == 0) { if (reql == 0) {
goto incomplete; goto incomplete;
} }
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
totl += reql; totl += reql;
@ -702,7 +702,7 @@ static void peer_io_handler(struct stream_interface *si)
if (reql == 0) { if (reql == 0) {
goto incomplete; goto incomplete;
} }
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
totl += reql; totl += reql;
@ -775,7 +775,7 @@ static void peer_io_handler(struct stream_interface *si)
if (stopping) { if (stopping) {
/* Close session, push resync no more needed */ /* Close session, push resync no more needed */
ps->flags |= PEER_F_TEACH_COMPLETE; ps->flags |= PEER_F_TEACH_COMPLETE;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
@ -811,7 +811,7 @@ static void peer_io_handler(struct stream_interface *si)
if (reql == 0) { if (reql == 0) {
goto incomplete; goto incomplete;
} }
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
totl += reql; totl += reql;
@ -821,7 +821,7 @@ static void peer_io_handler(struct stream_interface *si)
} }
else { else {
/* Unknown message */ /* Unknown message */
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
@ -841,7 +841,7 @@ static void peer_io_handler(struct stream_interface *si)
/* no more write possible */ /* no more write possible */
if (repl == -1) if (repl == -1)
goto out; goto out;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
ps->confirm--; ps->confirm--;
@ -858,7 +858,7 @@ static void peer_io_handler(struct stream_interface *si)
/* no more write possible */ /* no more write possible */
if (repl == -1) if (repl == -1)
goto out; goto out;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
ps->table->flags |= SHTABLE_F_RESYNC_PROCESS; ps->table->flags |= SHTABLE_F_RESYNC_PROCESS;
@ -877,7 +877,7 @@ static void peer_io_handler(struct stream_interface *si)
/* no more write possible */ /* no more write possible */
if (repl == -1) if (repl == -1)
goto out; goto out;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
ps->lastack = ps->pushack; ps->lastack = ps->pushack;
@ -913,7 +913,7 @@ static void peer_io_handler(struct stream_interface *si)
/* no more write possible */ /* no more write possible */
if (repl == -1) if (repl == -1)
goto out; goto out;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
ps->lastpush = ps->pushed = ts->upd.key; ps->lastpush = ps->pushed = ts->upd.key;
@ -947,7 +947,7 @@ static void peer_io_handler(struct stream_interface *si)
/* no more write possible */ /* no more write possible */
if (repl == -1) if (repl == -1)
goto out; goto out;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
ps->lastpush = ps->pushed = ts->upd.key; ps->lastpush = ps->pushed = ts->upd.key;
@ -963,7 +963,7 @@ static void peer_io_handler(struct stream_interface *si)
/* no more write possible */ /* no more write possible */
if (repl == -1) if (repl == -1)
goto out; goto out;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
@ -1005,7 +1005,7 @@ static void peer_io_handler(struct stream_interface *si)
/* no more write possible */ /* no more write possible */
if (repl == -1) if (repl == -1)
goto out; goto out;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
goto switchstate; goto switchstate;
} }
ps->lastpush = ps->pushed = ts->upd.key; ps->lastpush = ps->pushed = ts->upd.key;
@ -1017,11 +1017,11 @@ static void peer_io_handler(struct stream_interface *si)
goto out; goto out;
} }
case PEER_SESSION_EXIT: case PEER_SESSION_EXIT:
repl = snprintf(trash, sizeof(trash), "%d\n", si->st1); repl = snprintf(trash, sizeof(trash), "%d\n", si->applet.st1);
if (buffer_put_block(si->ib, trash, repl) == -1) if (buffer_put_block(si->ib, trash, repl) == -1)
goto out; goto out;
si->st0 = PEER_SESSION_END; si->applet.st0 = PEER_SESSION_END;
/* fall through */ /* fall through */
case PEER_SESSION_END: { case PEER_SESSION_END: {
si->shutw(si); si->shutw(si);
@ -1062,8 +1062,8 @@ void peer_session_forceshutdown(struct session * session)
/* call release to reinit resync states if needed */ /* call release to reinit resync states if needed */
peer_session_release(oldsi); peer_session_release(oldsi);
oldsi->st0 = PEER_SESSION_END; oldsi->applet.st0 = PEER_SESSION_END;
oldsi->private = NULL; oldsi->applet.private = NULL;
task_wakeup(session->task, TASK_WOKEN_MSG); task_wakeup(session->task, TASK_WOKEN_MSG);
} }
@ -1078,8 +1078,8 @@ int peer_accept(struct session *s)
/* we have a dedicated I/O handler for the stats */ /* we have a dedicated I/O handler for the stats */
stream_int_register_handler(&s->si[1], &peer_applet); stream_int_register_handler(&s->si[1], &peer_applet);
s->si[1].release = peer_session_release; s->si[1].release = peer_session_release;
s->si[1].private = s; s->si[1].applet.private = s;
s->si[1].st0 = PEER_SESSION_ACCEPT; s->si[1].applet.st0 = PEER_SESSION_ACCEPT;
tv_zero(&s->logs.tv_request); tv_zero(&s->logs.tv_request);
s->logs.t_queue = 0; s->logs.t_queue = 0;
@ -1159,8 +1159,8 @@ struct session *peer_session_create(struct peer *peer, struct peer_session *ps)
s->si[0].flags = SI_FL_NONE; s->si[0].flags = SI_FL_NONE;
if (s->fe->options2 & PR_O2_INDEPSTR) if (s->fe->options2 & PR_O2_INDEPSTR)
s->si[0].flags |= SI_FL_INDEP_STR; s->si[0].flags |= SI_FL_INDEP_STR;
s->si[0].private = (void *)ps; s->si[0].applet.private = (void *)ps;
s->si[0].st0 = PEER_SESSION_CONNECT; s->si[0].applet.st0 = PEER_SESSION_CONNECT;
stream_int_register_handler(&s->si[0], &peer_applet); stream_int_register_handler(&s->si[0], &peer_applet);
s->si[0].release = peer_session_release; s->si[0].release = peer_session_release;

View File

@ -3227,8 +3227,8 @@ int http_process_req_common(struct session *s, struct buffer *req, int an_bit, s
s->data_state = DATA_ST_INIT; s->data_state = DATA_ST_INIT;
s->task->nice = -32; /* small boost for HTTP statistics */ s->task->nice = -32; /* small boost for HTTP statistics */
stream_int_register_handler(s->rep->prod, &http_stats_applet); stream_int_register_handler(s->rep->prod, &http_stats_applet);
s->rep->prod->private = s; s->rep->prod->applet.private = s;
s->rep->prod->st0 = s->rep->prod->st1 = 0; s->rep->prod->applet.st0 = s->rep->prod->applet.st1 = 0;
req->analysers = 0; req->analysers = 0;
return 0; return 0;