/* we have a dedicated I/O handler for the stats */
stream_int_register_handler(&s->si[1], &cli_applet);
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.st0 = STAT_CLI_INIT;
static int stats_dump_table_head_to_buffer(struct chunk *msg, struct stream_interface *si,
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",
proxy->id, stktable_types[proxy->table.type].kw, proxy->table.size, proxy->table.current);
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 stksess *ts;
uint32_t uint32_key;
static void stats_sock_table_request(struct stream_interface *si, char **args, bool show)
{
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.proxy = NULL;
si->applet.ctx.table.entry = NULL;
*/
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];
int arg;
si->applet.ctx.stats.flags |= STAT_SHOW_STAT;
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
}
else if (strcmp(args[1], "info") == 0) {
si->applet.ctx.stats.flags |= STAT_SHOW_INFO;
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
}
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) {
si->applet.ctx.cli.msg = stats_permission_denied_msg;
si->applet.st0 = STAT_CLI_PRINT;
else
si->applet.ctx.errors.iid = -1;
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
}
else if (strcmp(args[1], "table") == 0) {
chunk_init(&msg, trash, trashlen);
- switch (si->applet.state) {
+ switch (si->conn.data_st) {
case STAT_ST_INIT:
/* the function had not been called yet */
- si->applet.state = STAT_ST_HEAD;
+ si->conn.data_st = STAT_ST_HEAD;
/* fall through */
case STAT_ST_HEAD:
return 0;
}
- si->applet.state = STAT_ST_INFO;
+ si->conn.data_st = STAT_ST_INFO;
/* fall through */
case STAT_ST_INFO:
si->applet.ctx.stats.px = proxy;
si->applet.ctx.stats.px_st = STAT_PX_ST_INIT;
si->applet.ctx.stats.sv = NULL;
- si->applet.state = STAT_ST_LIST;
+ si->conn.data_st = STAT_ST_LIST;
/* fall through */
case STAT_ST_LIST:
/* here, we just have reached the last proxy */
}
- si->applet.state = STAT_ST_END;
+ si->conn.data_st = STAT_ST_END;
/* fall through */
case STAT_ST_END:
- si->applet.state = STAT_ST_FIN;
+ si->conn.data_st = STAT_ST_FIN;
/* fall through */
case STAT_ST_FIN:
default:
/* unknown state ! */
- si->applet.state = STAT_ST_FIN;
+ si->conn.data_st = STAT_ST_FIN;
return 1;
}
}
*/
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;
chunk_init(&msg, trash, trashlen);
- switch (si->applet.state) {
+ switch (si->conn.data_st) {
case STAT_ST_INIT:
chunk_printf(&msg,
"HTTP/1.0 303 See Other\r\n"
if (!(s->flags & SN_FINST_MASK))
s->flags |= SN_FINST_R;
- si->applet.state = STAT_ST_FIN;
+ si->conn.data_st = STAT_ST_FIN;
return 1;
}
return 1;
*/
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 *res = si->ib;
*/
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 proxy *px;
struct chunk msg;
chunk_init(&msg, trash, trashlen);
- switch (si->applet.state) {
+ switch (si->conn.data_st) {
case STAT_ST_INIT:
chunk_printf(&msg,
"HTTP/1.0 200 OK\r\n"
if (s->txn.meth == HTTP_METH_HEAD) {
/* 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;
}
- 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 */
case STAT_ST_HEAD:
if (bi_putchk(rep, &msg) == -1)
return 0;
- si->applet.state = STAT_ST_INFO;
+ si->conn.data_st = STAT_ST_INFO;
/* fall through */
case STAT_ST_INFO:
si->applet.ctx.stats.px = proxy;
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 */
case STAT_ST_LIST:
}
/* here, we just have reached the last proxy */
- si->applet.state = STAT_ST_END;
+ si->conn.data_st = STAT_ST_END;
/* fall through */
case STAT_ST_END:
return 0;
}
- si->applet.state = STAT_ST_FIN;
+ si->conn.data_st = STAT_ST_FIN;
/* fall through */
case STAT_ST_FIN:
default:
/* unknown state ! */
- si->applet.state = STAT_ST_FIN;
+ si->conn.data_st = STAT_ST_FIN;
return -1;
}
}
*/
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 server *sv, *svs; /* server and server-state, server-state=server or server->track */
struct listener *l;
/* If we're forced to shut down, we might have to remove our
* 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)) {
LIST_DEL(&si->applet.ctx.sess.bref.users);
LIST_INIT(&si->applet.ctx.sess.bref.users);
chunk_init(&msg, trash, trashlen);
- switch (si->applet.state) {
+ switch (si->conn.data_st) {
case STAT_ST_INIT:
/* the function had not been called yet, let's prepare the
* buffer for a response. We initialize the current session
*/
LIST_INIT(&si->applet.ctx.sess.bref.users);
si->applet.ctx.sess.bref.ref = sessions.n;
- si->applet.state = STAT_ST_LIST;
+ si->conn.data_st = STAT_ST_LIST;
/* fall through */
case STAT_ST_LIST:
return 1;
}
- si->applet.state = STAT_ST_FIN;
+ si->conn.data_st = STAT_ST_FIN;
/* fall through */
default:
- si->applet.state = STAT_ST_FIN;
+ si->conn.data_st = STAT_ST_FIN;
return 1;
}
}
*/
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 ebmb_node *eb;
int dt;
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_INFO : the proxy pointer points to the next table to
* dump, the entry pointer is NULL ;
if (unlikely(si->ib->flags & (BF_WRITE_ERROR|BF_SHUTW))) {
/* 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--;
stksess_kill_if_expired(&si->applet.ctx.table.proxy->table, si->applet.ctx.table.entry);
}
chunk_init(&msg, trash, trashlen);
- while (si->applet.state != STAT_ST_FIN) {
- switch (si->applet.state) {
+ while (si->conn.data_st != STAT_ST_FIN) {
+ switch (si->conn.data_st) {
case STAT_ST_INIT:
si->applet.ctx.table.proxy = si->applet.ctx.table.target;
if (!si->applet.ctx.table.proxy)
si->applet.ctx.table.proxy = proxy;
si->applet.ctx.table.entry = NULL;
- si->applet.state = STAT_ST_INFO;
+ si->conn.data_st = STAT_ST_INFO;
break;
case STAT_ST_INFO:
if (!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;
}
if (eb) {
si->applet.ctx.table.entry = ebmb_entry(eb, struct stksess, key);
si->applet.ctx.table.entry->ref_cnt++;
- si->applet.state = STAT_ST_LIST;
+ si->conn.data_st = STAT_ST_LIST;
break;
}
}
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.state = STAT_ST_INFO;
+ si->conn.data_st = STAT_ST_INFO;
break;
case STAT_ST_END:
- si->applet.state = STAT_ST_FIN;
+ si->conn.data_st = STAT_ST_FIN;
break;
}
}
{
struct task *t = (struct task *)si->owner;
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)
return;
switchstate:
switch(si->applet.st0) {
case PEER_SESSION_ACCEPT:
- si->applet.private = NULL;
+ si->conn.data_ctx = NULL;
si->applet.st0 = PEER_SESSION_GETVERSION;
/* fall through */
case PEER_SESSION_GETVERSION:
goto switchstate;
}
- si->applet.private = curpeer;
+ si->conn.data_ctx = curpeer;
si->applet.st0 = PEER_SESSION_GETTABLE;
/* fall through */
}
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 peer_session *ps = NULL;
unsigned long key_type;
if (reql <= 0) { /* closed or EOL not found */
if (reql == 0)
goto out;
- si->applet.private = NULL;
+ si->conn.data_ctx = NULL;
si->applet.st0 = PEER_SESSION_END;
goto switchstate;
}
- /* Re init si->applet.private to null, to handle correctly a release case */
- si->applet.private = NULL;
+ /* Re init si->conn.data_ctx to null, to handle correctly a release case */
+ si->conn.data_ctx = NULL;
if (trash[reql-1] != '\n') {
/* Incomplete line, we quit */
p = strchr(p+1, ' ');
if (!p) {
- si->applet.private = NULL;
+ si->conn.data_ctx = NULL;
si->applet.st0 = PEER_SESSION_EXIT;
si->applet.st1 = PEER_SESSION_ERRPROTO;
goto switchstate;
goto switchstate;
}
- si->applet.private = ps;
+ si->conn.data_ctx = ps;
si->applet.st0 = PEER_SESSION_SENDSUCCESS;
/* fall through */
}
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 = bi_putblk(si->ib, trash, repl);
goto switchstate;
}
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 */
repl = snprintf(trash, trashlen,
/* fall through */
}
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)
ps->statuscode = PEER_SESSION_CONNECTEDCODE;
/* fall through */
}
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;
int totl = 0;
/* call release to reinit resync states if needed */
peer_session_release(oldsi);
oldsi->applet.st0 = PEER_SESSION_END;
- oldsi->applet.private = NULL;
+ oldsi->conn.data_ctx = NULL;
task_wakeup(session->task, TASK_WOKEN_MSG);
}
/* we have a dedicated I/O handler for the stats */
stream_int_register_handler(&s->si[1], &peer_applet);
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;
tv_zero(&s->logs.tv_request);
s->si[0].flags = SI_FL_NONE;
if (s->fe->options2 & PR_O2_INDEPSTR)
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;
stream_int_register_handler(&s->si[0], &peer_applet);