mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 21:31:28 +02:00
REORG/MEDIUM: stream_interface: move applet->state and private to connection
The state and the private pointer are not specific to the applets, since SSL will require exactly both of them. Move them to the connection layer now and rename them. We also now ensure that both are NULL on first call.
This commit is contained in:
parent
fb7508aefb
commit
949811319b
@ -114,6 +114,8 @@ static inline struct server *target_srv(struct target *t)
|
|||||||
static inline void stream_interface_prepare(struct stream_interface *si, const struct sock_ops *ops)
|
static inline void stream_interface_prepare(struct stream_interface *si, const struct sock_ops *ops)
|
||||||
{
|
{
|
||||||
si->conn.data = ops;
|
si->conn.data = ops;
|
||||||
|
si->conn.data_st = 0;
|
||||||
|
si->conn.data_ctx = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,6 +110,8 @@ struct connection {
|
|||||||
int fd; /* file descriptor for a stream driver when known */
|
int fd; /* file descriptor for a stream driver when known */
|
||||||
} sock;
|
} sock;
|
||||||
} t;
|
} t;
|
||||||
|
int data_st; /* data layer state, initialized to zero */
|
||||||
|
void *data_ctx; /* general purpose pointer, initialized to NULL */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct target {
|
struct target {
|
||||||
@ -164,8 +166,6 @@ struct stream_interface {
|
|||||||
int conn_retries; /* number of connect retries left */
|
int conn_retries; /* number of connect retries left */
|
||||||
int send_proxy_ofs; /* <0 = offset to (re)send from the end, >0 = send all */
|
int send_proxy_ofs; /* <0 = offset to (re)send from the end, >0 = send all */
|
||||||
struct {
|
struct {
|
||||||
int state; /* applet state, initialized to zero */
|
|
||||||
void *private; /* may be used by any function above */
|
|
||||||
unsigned int st0, st1; /* may be used by any function above */
|
unsigned int st0, st1; /* may be used by any function above */
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
|
@ -125,7 +125,7 @@ static 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);
|
||||||
copy_target(&s->target, &s->si[1].target); // for logging only
|
copy_target(&s->target, &s->si[1].target); // for logging only
|
||||||
s->si[1].applet.private = s;
|
s->si[1].conn.data_ctx = s;
|
||||||
s->si[1].applet.st1 = 0;
|
s->si[1].applet.st1 = 0;
|
||||||
s->si[1].applet.st0 = STAT_CLI_INIT;
|
s->si[1].applet.st0 = STAT_CLI_INIT;
|
||||||
|
|
||||||
@ -417,7 +417,7 @@ static int dump_binary(struct chunk *out, const char *buf, int bsize)
|
|||||||
static int stats_dump_table_head_to_buffer(struct chunk *msg, struct stream_interface *si,
|
static int stats_dump_table_head_to_buffer(struct chunk *msg, struct stream_interface *si,
|
||||||
struct proxy *proxy, struct proxy *target)
|
struct proxy *proxy, struct proxy *target)
|
||||||
{
|
{
|
||||||
struct session *s = si->applet.private;
|
struct session *s = si->conn.data_ctx;
|
||||||
|
|
||||||
chunk_printf(msg, "# table: %s, type: %s, size:%d, used:%d\n",
|
chunk_printf(msg, "# table: %s, type: %s, size:%d, used:%d\n",
|
||||||
proxy->id, stktable_types[proxy->table.type].kw, proxy->table.size, proxy->table.current);
|
proxy->id, stktable_types[proxy->table.type].kw, proxy->table.size, proxy->table.current);
|
||||||
@ -506,7 +506,7 @@ static int stats_dump_table_entry_to_buffer(struct chunk *msg, struct stream_int
|
|||||||
|
|
||||||
static void stats_sock_table_key_request(struct stream_interface *si, char **args, bool show)
|
static void stats_sock_table_key_request(struct stream_interface *si, char **args, bool show)
|
||||||
{
|
{
|
||||||
struct session *s = si->applet.private;
|
struct session *s = si->conn.data_ctx;
|
||||||
struct proxy *px = si->applet.ctx.table.target;
|
struct proxy *px = si->applet.ctx.table.target;
|
||||||
struct stksess *ts;
|
struct stksess *ts;
|
||||||
uint32_t uint32_key;
|
uint32_t uint32_key;
|
||||||
@ -623,7 +623,7 @@ static void stats_sock_table_data_request(struct stream_interface *si, char **ar
|
|||||||
static void stats_sock_table_request(struct stream_interface *si, char **args, bool show)
|
static void stats_sock_table_request(struct stream_interface *si, char **args, bool show)
|
||||||
{
|
{
|
||||||
si->applet.ctx.table.data_type = -1;
|
si->applet.ctx.table.data_type = -1;
|
||||||
si->applet.state = STAT_ST_INIT;
|
si->conn.data_st = STAT_ST_INIT;
|
||||||
si->applet.ctx.table.target = NULL;
|
si->applet.ctx.table.target = NULL;
|
||||||
si->applet.ctx.table.proxy = NULL;
|
si->applet.ctx.table.proxy = NULL;
|
||||||
si->applet.ctx.table.entry = NULL;
|
si->applet.ctx.table.entry = NULL;
|
||||||
@ -745,7 +745,7 @@ static struct server *expect_server_admin(struct session *s, struct stream_inter
|
|||||||
*/
|
*/
|
||||||
static int stats_sock_parse_request(struct stream_interface *si, char *line)
|
static int stats_sock_parse_request(struct stream_interface *si, char *line)
|
||||||
{
|
{
|
||||||
struct session *s = si->applet.private;
|
struct session *s = si->conn.data_ctx;
|
||||||
char *args[MAX_STATS_ARGS + 1];
|
char *args[MAX_STATS_ARGS + 1];
|
||||||
int arg;
|
int arg;
|
||||||
|
|
||||||
@ -784,17 +784,17 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
|
|||||||
|
|
||||||
si->applet.ctx.stats.flags |= STAT_SHOW_STAT;
|
si->applet.ctx.stats.flags |= STAT_SHOW_STAT;
|
||||||
si->applet.ctx.stats.flags |= STAT_FMT_CSV;
|
si->applet.ctx.stats.flags |= STAT_FMT_CSV;
|
||||||
si->applet.state = STAT_ST_INIT;
|
si->conn.data_st = STAT_ST_INIT;
|
||||||
si->applet.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) {
|
||||||
si->applet.ctx.stats.flags |= STAT_SHOW_INFO;
|
si->applet.ctx.stats.flags |= STAT_SHOW_INFO;
|
||||||
si->applet.ctx.stats.flags |= STAT_FMT_CSV;
|
si->applet.ctx.stats.flags |= STAT_FMT_CSV;
|
||||||
si->applet.state = STAT_ST_INIT;
|
si->conn.data_st = STAT_ST_INIT;
|
||||||
si->applet.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) {
|
||||||
si->applet.state = STAT_ST_INIT;
|
si->conn.data_st = STAT_ST_INIT;
|
||||||
if (s->listener->perm.ux.level < ACCESS_LVL_OPER) {
|
if (s->listener->perm.ux.level < ACCESS_LVL_OPER) {
|
||||||
si->applet.ctx.cli.msg = stats_permission_denied_msg;
|
si->applet.ctx.cli.msg = stats_permission_denied_msg;
|
||||||
si->applet.st0 = STAT_CLI_PRINT;
|
si->applet.st0 = STAT_CLI_PRINT;
|
||||||
@ -819,7 +819,7 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
|
|||||||
else
|
else
|
||||||
si->applet.ctx.errors.iid = -1;
|
si->applet.ctx.errors.iid = -1;
|
||||||
si->applet.ctx.errors.px = NULL;
|
si->applet.ctx.errors.px = NULL;
|
||||||
si->applet.state = STAT_ST_INIT;
|
si->conn.data_st = STAT_ST_INIT;
|
||||||
si->applet.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) {
|
||||||
@ -1567,10 +1567,10 @@ static int stats_dump_raw_to_buffer(struct stream_interface *si)
|
|||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, trashlen);
|
||||||
|
|
||||||
switch (si->applet.state) {
|
switch (si->conn.data_st) {
|
||||||
case STAT_ST_INIT:
|
case STAT_ST_INIT:
|
||||||
/* the function had not been called yet */
|
/* the function had not been called yet */
|
||||||
si->applet.state = STAT_ST_HEAD;
|
si->conn.data_st = STAT_ST_HEAD;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
case STAT_ST_HEAD:
|
case STAT_ST_HEAD:
|
||||||
@ -1580,7 +1580,7 @@ static int stats_dump_raw_to_buffer(struct stream_interface *si)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
si->applet.state = STAT_ST_INFO;
|
si->conn.data_st = STAT_ST_INFO;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
case STAT_ST_INFO:
|
case STAT_ST_INFO:
|
||||||
@ -1633,7 +1633,7 @@ static int stats_dump_raw_to_buffer(struct stream_interface *si)
|
|||||||
si->applet.ctx.stats.px = proxy;
|
si->applet.ctx.stats.px = proxy;
|
||||||
si->applet.ctx.stats.px_st = STAT_PX_ST_INIT;
|
si->applet.ctx.stats.px_st = STAT_PX_ST_INIT;
|
||||||
si->applet.ctx.stats.sv = NULL;
|
si->applet.ctx.stats.sv = NULL;
|
||||||
si->applet.state = STAT_ST_LIST;
|
si->conn.data_st = STAT_ST_LIST;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
case STAT_ST_LIST:
|
case STAT_ST_LIST:
|
||||||
@ -1654,11 +1654,11 @@ static int stats_dump_raw_to_buffer(struct stream_interface *si)
|
|||||||
/* here, we just have reached the last proxy */
|
/* here, we just have reached the last proxy */
|
||||||
}
|
}
|
||||||
|
|
||||||
si->applet.state = STAT_ST_END;
|
si->conn.data_st = STAT_ST_END;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
case STAT_ST_END:
|
case STAT_ST_END:
|
||||||
si->applet.state = STAT_ST_FIN;
|
si->conn.data_st = STAT_ST_FIN;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
case STAT_ST_FIN:
|
case STAT_ST_FIN:
|
||||||
@ -1666,7 +1666,7 @@ static int stats_dump_raw_to_buffer(struct stream_interface *si)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
/* unknown state ! */
|
/* unknown state ! */
|
||||||
si->applet.state = STAT_ST_FIN;
|
si->conn.data_st = STAT_ST_FIN;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1678,12 +1678,12 @@ static int stats_dump_raw_to_buffer(struct stream_interface *si)
|
|||||||
*/
|
*/
|
||||||
static int stats_http_redir(struct stream_interface *si, struct uri_auth *uri)
|
static int stats_http_redir(struct stream_interface *si, struct uri_auth *uri)
|
||||||
{
|
{
|
||||||
struct session *s = si->applet.private;
|
struct session *s = si->conn.data_ctx;
|
||||||
struct chunk msg;
|
struct chunk msg;
|
||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, trashlen);
|
||||||
|
|
||||||
switch (si->applet.state) {
|
switch (si->conn.data_st) {
|
||||||
case STAT_ST_INIT:
|
case STAT_ST_INIT:
|
||||||
chunk_printf(&msg,
|
chunk_printf(&msg,
|
||||||
"HTTP/1.0 303 See Other\r\n"
|
"HTTP/1.0 303 See Other\r\n"
|
||||||
@ -1709,7 +1709,7 @@ static int stats_http_redir(struct stream_interface *si, struct uri_auth *uri)
|
|||||||
if (!(s->flags & SN_FINST_MASK))
|
if (!(s->flags & SN_FINST_MASK))
|
||||||
s->flags |= SN_FINST_R;
|
s->flags |= SN_FINST_R;
|
||||||
|
|
||||||
si->applet.state = STAT_ST_FIN;
|
si->conn.data_st = STAT_ST_FIN;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -1723,7 +1723,7 @@ static int stats_http_redir(struct stream_interface *si, struct uri_auth *uri)
|
|||||||
*/
|
*/
|
||||||
static void http_stats_io_handler(struct stream_interface *si)
|
static void http_stats_io_handler(struct stream_interface *si)
|
||||||
{
|
{
|
||||||
struct session *s = si->applet.private;
|
struct session *s = si->conn.data_ctx;
|
||||||
struct buffer *req = si->ob;
|
struct buffer *req = si->ob;
|
||||||
struct buffer *res = si->ib;
|
struct buffer *res = si->ib;
|
||||||
|
|
||||||
@ -1779,7 +1779,7 @@ static void http_stats_io_handler(struct stream_interface *si)
|
|||||||
*/
|
*/
|
||||||
static int stats_dump_http(struct stream_interface *si, struct uri_auth *uri)
|
static int stats_dump_http(struct stream_interface *si, struct uri_auth *uri)
|
||||||
{
|
{
|
||||||
struct session *s = si->applet.private;
|
struct session *s = si->conn.data_ctx;
|
||||||
struct buffer *rep = si->ib;
|
struct buffer *rep = si->ib;
|
||||||
struct proxy *px;
|
struct proxy *px;
|
||||||
struct chunk msg;
|
struct chunk msg;
|
||||||
@ -1787,7 +1787,7 @@ static int stats_dump_http(struct stream_interface *si, struct uri_auth *uri)
|
|||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, trashlen);
|
||||||
|
|
||||||
switch (si->applet.state) {
|
switch (si->conn.data_st) {
|
||||||
case STAT_ST_INIT:
|
case STAT_ST_INIT:
|
||||||
chunk_printf(&msg,
|
chunk_printf(&msg,
|
||||||
"HTTP/1.0 200 OK\r\n"
|
"HTTP/1.0 200 OK\r\n"
|
||||||
@ -1813,11 +1813,11 @@ static int stats_dump_http(struct stream_interface *si, struct uri_auth *uri)
|
|||||||
|
|
||||||
if (s->txn.meth == HTTP_METH_HEAD) {
|
if (s->txn.meth == HTTP_METH_HEAD) {
|
||||||
/* that's all we return in case of HEAD request */
|
/* that's all we return in case of HEAD request */
|
||||||
si->applet.state = STAT_ST_FIN;
|
si->conn.data_st = STAT_ST_FIN;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
si->applet.state = STAT_ST_HEAD; /* let's start producing data */
|
si->conn.data_st = STAT_ST_HEAD; /* let's start producing data */
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
case STAT_ST_HEAD:
|
case STAT_ST_HEAD:
|
||||||
@ -1921,7 +1921,7 @@ static int stats_dump_http(struct stream_interface *si, struct uri_auth *uri)
|
|||||||
if (bi_putchk(rep, &msg) == -1)
|
if (bi_putchk(rep, &msg) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
si->applet.state = STAT_ST_INFO;
|
si->conn.data_st = STAT_ST_INFO;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
case STAT_ST_INFO:
|
case STAT_ST_INFO:
|
||||||
@ -2099,7 +2099,7 @@ static int stats_dump_http(struct stream_interface *si, struct uri_auth *uri)
|
|||||||
|
|
||||||
si->applet.ctx.stats.px = proxy;
|
si->applet.ctx.stats.px = proxy;
|
||||||
si->applet.ctx.stats.px_st = STAT_PX_ST_INIT;
|
si->applet.ctx.stats.px_st = STAT_PX_ST_INIT;
|
||||||
si->applet.state = STAT_ST_LIST;
|
si->conn.data_st = STAT_ST_LIST;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
case STAT_ST_LIST:
|
case STAT_ST_LIST:
|
||||||
@ -2118,7 +2118,7 @@ static int stats_dump_http(struct stream_interface *si, struct uri_auth *uri)
|
|||||||
}
|
}
|
||||||
/* here, we just have reached the last proxy */
|
/* here, we just have reached the last proxy */
|
||||||
|
|
||||||
si->applet.state = STAT_ST_END;
|
si->conn.data_st = STAT_ST_END;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
case STAT_ST_END:
|
case STAT_ST_END:
|
||||||
@ -2128,7 +2128,7 @@ static int stats_dump_http(struct stream_interface *si, struct uri_auth *uri)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
si->applet.state = STAT_ST_FIN;
|
si->conn.data_st = STAT_ST_FIN;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
case STAT_ST_FIN:
|
case STAT_ST_FIN:
|
||||||
@ -2136,7 +2136,7 @@ static int stats_dump_http(struct stream_interface *si, struct uri_auth *uri)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
/* unknown state ! */
|
/* unknown state ! */
|
||||||
si->applet.state = STAT_ST_FIN;
|
si->conn.data_st = STAT_ST_FIN;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2149,7 +2149,7 @@ static int stats_dump_http(struct stream_interface *si, struct uri_auth *uri)
|
|||||||
*/
|
*/
|
||||||
static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struct uri_auth *uri)
|
static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struct uri_auth *uri)
|
||||||
{
|
{
|
||||||
struct session *s = si->applet.private;
|
struct session *s = si->conn.data_ctx;
|
||||||
struct buffer *rep = si->ib;
|
struct buffer *rep = si->ib;
|
||||||
struct server *sv, *svs; /* server and server-state, server-state=server or server->track */
|
struct server *sv, *svs; /* server and server-state, server-state=server or server->track */
|
||||||
struct listener *l;
|
struct listener *l;
|
||||||
@ -3454,7 +3454,7 @@ static int stats_dump_sess_to_buffer(struct stream_interface *si)
|
|||||||
/* If we're forced to shut down, we might have to remove our
|
/* If we're forced to shut down, we might have to remove our
|
||||||
* reference to the last session being dumped.
|
* reference to the last session being dumped.
|
||||||
*/
|
*/
|
||||||
if (si->applet.state == STAT_ST_LIST) {
|
if (si->conn.data_st == STAT_ST_LIST) {
|
||||||
if (!LIST_ISEMPTY(&si->applet.ctx.sess.bref.users)) {
|
if (!LIST_ISEMPTY(&si->applet.ctx.sess.bref.users)) {
|
||||||
LIST_DEL(&si->applet.ctx.sess.bref.users);
|
LIST_DEL(&si->applet.ctx.sess.bref.users);
|
||||||
LIST_INIT(&si->applet.ctx.sess.bref.users);
|
LIST_INIT(&si->applet.ctx.sess.bref.users);
|
||||||
@ -3465,7 +3465,7 @@ static int stats_dump_sess_to_buffer(struct stream_interface *si)
|
|||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, trashlen);
|
||||||
|
|
||||||
switch (si->applet.state) {
|
switch (si->conn.data_st) {
|
||||||
case STAT_ST_INIT:
|
case STAT_ST_INIT:
|
||||||
/* the function had not been called yet, let's prepare the
|
/* the function had not been called yet, let's prepare the
|
||||||
* buffer for a response. We initialize the current session
|
* buffer for a response. We initialize the current session
|
||||||
@ -3476,7 +3476,7 @@ static int stats_dump_sess_to_buffer(struct stream_interface *si)
|
|||||||
*/
|
*/
|
||||||
LIST_INIT(&si->applet.ctx.sess.bref.users);
|
LIST_INIT(&si->applet.ctx.sess.bref.users);
|
||||||
si->applet.ctx.sess.bref.ref = sessions.n;
|
si->applet.ctx.sess.bref.ref = sessions.n;
|
||||||
si->applet.state = STAT_ST_LIST;
|
si->conn.data_st = STAT_ST_LIST;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
case STAT_ST_LIST:
|
case STAT_ST_LIST:
|
||||||
@ -3641,11 +3641,11 @@ static int stats_dump_sess_to_buffer(struct stream_interface *si)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
si->applet.state = STAT_ST_FIN;
|
si->conn.data_st = STAT_ST_FIN;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
si->applet.state = STAT_ST_FIN;
|
si->conn.data_st = STAT_ST_FIN;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3657,14 +3657,14 @@ static int stats_dump_sess_to_buffer(struct stream_interface *si)
|
|||||||
*/
|
*/
|
||||||
static int stats_table_request(struct stream_interface *si, bool show)
|
static int stats_table_request(struct stream_interface *si, bool show)
|
||||||
{
|
{
|
||||||
struct session *s = si->applet.private;
|
struct session *s = si->conn.data_ctx;
|
||||||
struct chunk msg;
|
struct chunk msg;
|
||||||
struct ebmb_node *eb;
|
struct ebmb_node *eb;
|
||||||
int dt;
|
int dt;
|
||||||
bool skip_entry;
|
bool skip_entry;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We have 3 possible states in si->applet.state :
|
* We have 3 possible states in si->conn.data_st :
|
||||||
* - STAT_ST_INIT : the first call
|
* - STAT_ST_INIT : the first call
|
||||||
* - STAT_ST_INFO : the proxy pointer points to the next table to
|
* - STAT_ST_INFO : the proxy pointer points to the next table to
|
||||||
* dump, the entry pointer is NULL ;
|
* dump, the entry pointer is NULL ;
|
||||||
@ -3677,7 +3677,7 @@ static int stats_table_request(struct stream_interface *si, bool show)
|
|||||||
|
|
||||||
if (unlikely(si->ib->flags & (BF_WRITE_ERROR|BF_SHUTW))) {
|
if (unlikely(si->ib->flags & (BF_WRITE_ERROR|BF_SHUTW))) {
|
||||||
/* in case of abort, remove any refcount we might have set on an entry */
|
/* in case of abort, remove any refcount we might have set on an entry */
|
||||||
if (si->applet.state == STAT_ST_LIST) {
|
if (si->conn.data_st == STAT_ST_LIST) {
|
||||||
si->applet.ctx.table.entry->ref_cnt--;
|
si->applet.ctx.table.entry->ref_cnt--;
|
||||||
stksess_kill_if_expired(&si->applet.ctx.table.proxy->table, si->applet.ctx.table.entry);
|
stksess_kill_if_expired(&si->applet.ctx.table.proxy->table, si->applet.ctx.table.entry);
|
||||||
}
|
}
|
||||||
@ -3686,22 +3686,22 @@ static int stats_table_request(struct stream_interface *si, bool show)
|
|||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, trashlen);
|
||||||
|
|
||||||
while (si->applet.state != STAT_ST_FIN) {
|
while (si->conn.data_st != STAT_ST_FIN) {
|
||||||
switch (si->applet.state) {
|
switch (si->conn.data_st) {
|
||||||
case STAT_ST_INIT:
|
case STAT_ST_INIT:
|
||||||
si->applet.ctx.table.proxy = si->applet.ctx.table.target;
|
si->applet.ctx.table.proxy = si->applet.ctx.table.target;
|
||||||
if (!si->applet.ctx.table.proxy)
|
if (!si->applet.ctx.table.proxy)
|
||||||
si->applet.ctx.table.proxy = proxy;
|
si->applet.ctx.table.proxy = proxy;
|
||||||
|
|
||||||
si->applet.ctx.table.entry = NULL;
|
si->applet.ctx.table.entry = NULL;
|
||||||
si->applet.state = STAT_ST_INFO;
|
si->conn.data_st = STAT_ST_INFO;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STAT_ST_INFO:
|
case STAT_ST_INFO:
|
||||||
if (!si->applet.ctx.table.proxy ||
|
if (!si->applet.ctx.table.proxy ||
|
||||||
(si->applet.ctx.table.target &&
|
(si->applet.ctx.table.target &&
|
||||||
si->applet.ctx.table.proxy != si->applet.ctx.table.target)) {
|
si->applet.ctx.table.proxy != si->applet.ctx.table.target)) {
|
||||||
si->applet.state = STAT_ST_END;
|
si->conn.data_st = STAT_ST_END;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3717,7 +3717,7 @@ static int stats_table_request(struct stream_interface *si, bool show)
|
|||||||
if (eb) {
|
if (eb) {
|
||||||
si->applet.ctx.table.entry = ebmb_entry(eb, struct stksess, key);
|
si->applet.ctx.table.entry = ebmb_entry(eb, struct stksess, key);
|
||||||
si->applet.ctx.table.entry->ref_cnt++;
|
si->applet.ctx.table.entry->ref_cnt++;
|
||||||
si->applet.state = STAT_ST_LIST;
|
si->conn.data_st = STAT_ST_LIST;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3797,11 +3797,11 @@ static int stats_table_request(struct stream_interface *si, bool show)
|
|||||||
stksess_kill(&si->applet.ctx.table.proxy->table, si->applet.ctx.table.entry);
|
stksess_kill(&si->applet.ctx.table.proxy->table, si->applet.ctx.table.entry);
|
||||||
|
|
||||||
si->applet.ctx.table.proxy = si->applet.ctx.table.proxy->next;
|
si->applet.ctx.table.proxy = si->applet.ctx.table.proxy->next;
|
||||||
si->applet.state = STAT_ST_INFO;
|
si->conn.data_st = STAT_ST_INFO;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STAT_ST_END:
|
case STAT_ST_END:
|
||||||
si->applet.state = STAT_ST_FIN;
|
si->conn.data_st = STAT_ST_FIN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
34
src/peers.c
34
src/peers.c
@ -185,9 +185,9 @@ static 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->applet.private;
|
struct peer_session *ps = (struct peer_session *)si->conn.data_ctx;
|
||||||
|
|
||||||
/* si->applet.private is not a peer session */
|
/* si->conn.data_ctx is not a peer session */
|
||||||
if (si->applet.st0 < PEER_SESSION_SENDSUCCESS)
|
if (si->applet.st0 < PEER_SESSION_SENDSUCCESS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
switchstate:
|
switchstate:
|
||||||
switch(si->applet.st0) {
|
switch(si->applet.st0) {
|
||||||
case PEER_SESSION_ACCEPT:
|
case PEER_SESSION_ACCEPT:
|
||||||
si->applet.private = NULL;
|
si->conn.data_ctx = NULL;
|
||||||
si->applet.st0 = PEER_SESSION_GETVERSION;
|
si->applet.st0 = PEER_SESSION_GETVERSION;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case PEER_SESSION_GETVERSION:
|
case PEER_SESSION_GETVERSION:
|
||||||
@ -333,12 +333,12 @@ switchstate:
|
|||||||
goto switchstate;
|
goto switchstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
si->applet.private = curpeer;
|
si->conn.data_ctx = curpeer;
|
||||||
si->applet.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->applet.private;
|
struct peer *curpeer = (struct peer *)si->conn.data_ctx;
|
||||||
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;
|
||||||
@ -349,12 +349,12 @@ switchstate:
|
|||||||
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->applet.private = NULL;
|
si->conn.data_ctx = NULL;
|
||||||
si->applet.st0 = PEER_SESSION_END;
|
si->applet.st0 = PEER_SESSION_END;
|
||||||
goto switchstate;
|
goto switchstate;
|
||||||
}
|
}
|
||||||
/* Re init si->applet.private to null, to handle correctly a release case */
|
/* Re init si->conn.data_ctx to null, to handle correctly a release case */
|
||||||
si->applet.private = NULL;
|
si->conn.data_ctx = NULL;
|
||||||
|
|
||||||
if (trash[reql-1] != '\n') {
|
if (trash[reql-1] != '\n') {
|
||||||
/* Incomplete line, we quit */
|
/* Incomplete line, we quit */
|
||||||
@ -380,7 +380,7 @@ switchstate:
|
|||||||
|
|
||||||
p = strchr(p+1, ' ');
|
p = strchr(p+1, ' ');
|
||||||
if (!p) {
|
if (!p) {
|
||||||
si->applet.private = NULL;
|
si->conn.data_ctx = NULL;
|
||||||
si->applet.st0 = PEER_SESSION_EXIT;
|
si->applet.st0 = PEER_SESSION_EXIT;
|
||||||
si->applet.st1 = PEER_SESSION_ERRPROTO;
|
si->applet.st1 = PEER_SESSION_ERRPROTO;
|
||||||
goto switchstate;
|
goto switchstate;
|
||||||
@ -439,12 +439,12 @@ switchstate:
|
|||||||
goto switchstate;
|
goto switchstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
si->applet.private = ps;
|
si->conn.data_ctx = ps;
|
||||||
si->applet.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->applet.private;
|
struct peer_session *ps = (struct peer_session *)si->conn.data_ctx;
|
||||||
|
|
||||||
repl = snprintf(trash, trashlen, "%d\n", PEER_SESSION_SUCCESSCODE);
|
repl = snprintf(trash, trashlen, "%d\n", PEER_SESSION_SUCCESSCODE);
|
||||||
repl = bi_putblk(si->ib, trash, repl);
|
repl = bi_putblk(si->ib, trash, repl);
|
||||||
@ -494,7 +494,7 @@ switchstate:
|
|||||||
goto switchstate;
|
goto switchstate;
|
||||||
}
|
}
|
||||||
case PEER_SESSION_CONNECT: {
|
case PEER_SESSION_CONNECT: {
|
||||||
struct peer_session *ps = (struct peer_session *)si->applet.private;
|
struct peer_session *ps = (struct peer_session *)si->conn.data_ctx;
|
||||||
|
|
||||||
/* Send headers */
|
/* Send headers */
|
||||||
repl = snprintf(trash, trashlen,
|
repl = snprintf(trash, trashlen,
|
||||||
@ -524,7 +524,7 @@ switchstate:
|
|||||||
/* fall through */
|
/* fall through */
|
||||||
}
|
}
|
||||||
case PEER_SESSION_GETSTATUS: {
|
case PEER_SESSION_GETSTATUS: {
|
||||||
struct peer_session *ps = (struct peer_session *)si->applet.private;
|
struct peer_session *ps = (struct peer_session *)si->conn.data_ctx;
|
||||||
|
|
||||||
if (si->ib->flags & BF_WRITE_PARTIAL)
|
if (si->ib->flags & BF_WRITE_PARTIAL)
|
||||||
ps->statuscode = PEER_SESSION_CONNECTEDCODE;
|
ps->statuscode = PEER_SESSION_CONNECTEDCODE;
|
||||||
@ -595,7 +595,7 @@ switchstate:
|
|||||||
/* fall through */
|
/* fall through */
|
||||||
}
|
}
|
||||||
case PEER_SESSION_WAITMSG: {
|
case PEER_SESSION_WAITMSG: {
|
||||||
struct peer_session *ps = (struct peer_session *)si->applet.private;
|
struct peer_session *ps = (struct peer_session *)si->conn.data_ctx;
|
||||||
char c;
|
char c;
|
||||||
int totl = 0;
|
int totl = 0;
|
||||||
|
|
||||||
@ -1064,7 +1064,7 @@ static 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->applet.st0 = PEER_SESSION_END;
|
oldsi->applet.st0 = PEER_SESSION_END;
|
||||||
oldsi->applet.private = NULL;
|
oldsi->conn.data_ctx = NULL;
|
||||||
task_wakeup(session->task, TASK_WOKEN_MSG);
|
task_wakeup(session->task, TASK_WOKEN_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1079,7 +1079,7 @@ 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);
|
||||||
copy_target(&s->target, &s->si[1].target); // for logging only
|
copy_target(&s->target, &s->si[1].target); // for logging only
|
||||||
s->si[1].applet.private = s;
|
s->si[1].conn.data_ctx = s;
|
||||||
s->si[1].applet.st0 = PEER_SESSION_ACCEPT;
|
s->si[1].applet.st0 = PEER_SESSION_ACCEPT;
|
||||||
|
|
||||||
tv_zero(&s->logs.tv_request);
|
tv_zero(&s->logs.tv_request);
|
||||||
@ -1162,7 +1162,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
|
|||||||
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].applet.private = (void *)ps;
|
s->si[0].conn.data_ctx = (void *)ps;
|
||||||
s->si[0].applet.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);
|
||||||
|
@ -2967,7 +2967,7 @@ int http_process_req_common(struct session *s, struct buffer *req, int an_bit, s
|
|||||||
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);
|
||||||
copy_target(&s->target, &s->rep->prod->target); // for logging only
|
copy_target(&s->target, &s->rep->prod->target); // for logging only
|
||||||
s->rep->prod->applet.private = s;
|
s->rep->prod->conn.data_ctx = s;
|
||||||
s->rep->prod->applet.st0 = s->rep->prod->applet.st1 = 0;
|
s->rep->prod->applet.st0 = s->rep->prod->applet.st1 = 0;
|
||||||
req->analysers = 0;
|
req->analysers = 0;
|
||||||
if (s->fe == s->be) /* report it if the request was intercepted by the frontend */
|
if (s->fe == s->be) /* report it if the request was intercepted by the frontend */
|
||||||
|
@ -341,7 +341,6 @@ struct task *stream_int_register_handler(struct stream_interface *si, struct si_
|
|||||||
stream_interface_prepare(si, &stream_int_embedded);
|
stream_interface_prepare(si, &stream_int_embedded);
|
||||||
si->conn.ctrl = NULL;
|
si->conn.ctrl = NULL;
|
||||||
set_target_applet(&si->target, app);
|
set_target_applet(&si->target, app);
|
||||||
si->applet.state = 0;
|
|
||||||
si->release = app->release;
|
si->release = app->release;
|
||||||
si->flags |= SI_FL_WAIT_DATA;
|
si->flags |= SI_FL_WAIT_DATA;
|
||||||
return si->owner;
|
return si->owner;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user