MEDIUM: stream: move the frontend's pointer to the session
Just like for the listener, the frontend is session-wide so let's move it to the session. There are a lot of places which were changed but the changes are minimal in fact.
This commit is contained in:
parent
fb0afa77c9
commit
e36cbcb3b0
@ -36,6 +36,7 @@
|
||||
#include <types/stick_table.h>
|
||||
|
||||
struct session {
|
||||
struct proxy *fe; /* the proxy this session depends on for the client side */
|
||||
struct listener *listener; /* the listener by which the request arrived */
|
||||
};
|
||||
|
||||
|
@ -117,7 +117,6 @@ struct stream {
|
||||
struct channel req; /* request channel */
|
||||
struct channel res; /* response channel */
|
||||
|
||||
struct proxy *fe; /* the proxy this stream depends on for the client side */
|
||||
struct proxy *be; /* the proxy this stream depends on for the server side */
|
||||
|
||||
struct session *sess; /* the session this stream is attached to */
|
||||
|
@ -1090,7 +1090,7 @@ int connect_server(struct stream *s)
|
||||
}
|
||||
|
||||
/* flag for logging source ip/port */
|
||||
if (s->fe->options2 & PR_O2_SRC_ADDR)
|
||||
if (strm_sess(s)->fe->options2 & PR_O2_SRC_ADDR)
|
||||
s->si[1].flags |= SI_FL_SRC_ADDR;
|
||||
|
||||
/* disable lingering */
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <proto/compression.h>
|
||||
#include <proto/freq_ctr.h>
|
||||
#include <proto/proto_http.h>
|
||||
#include <proto/stream.h>
|
||||
|
||||
|
||||
#ifdef USE_ZLIB
|
||||
@ -318,10 +319,10 @@ int http_compression_buffer_end(struct stream *s, struct buffer **in, struct buf
|
||||
/* update input rate */
|
||||
if (s->comp_ctx && s->comp_ctx->cur_lvl > 0) {
|
||||
update_freq_ctr(&global.comp_bps_in, msg->next);
|
||||
s->fe->fe_counters.comp_in += msg->next;
|
||||
strm_sess(s)->fe->fe_counters.comp_in += msg->next;
|
||||
s->be->be_counters.comp_in += msg->next;
|
||||
} else {
|
||||
s->fe->fe_counters.comp_byp += msg->next;
|
||||
strm_sess(s)->fe->fe_counters.comp_byp += msg->next;
|
||||
s->be->be_counters.comp_byp += msg->next;
|
||||
}
|
||||
|
||||
@ -345,7 +346,7 @@ int http_compression_buffer_end(struct stream *s, struct buffer **in, struct buf
|
||||
|
||||
if (s->comp_ctx && s->comp_ctx->cur_lvl > 0) {
|
||||
update_freq_ctr(&global.comp_bps_out, to_forward);
|
||||
s->fe->fe_counters.comp_out += to_forward;
|
||||
strm_sess(s)->fe->fe_counters.comp_out += to_forward;
|
||||
s->be->be_counters.comp_out += to_forward;
|
||||
}
|
||||
|
||||
|
@ -1511,8 +1511,8 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
|
||||
resume_listener(l);
|
||||
}
|
||||
|
||||
if (px->maxconn > px->feconn && !LIST_ISEMPTY(&s->fe->listener_queue))
|
||||
dequeue_all_listeners(&s->fe->listener_queue);
|
||||
if (px->maxconn > px->feconn && !LIST_ISEMPTY(&strm_sess(s)->fe->listener_queue))
|
||||
dequeue_all_listeners(&strm_sess(s)->fe->listener_queue);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -5044,7 +5044,7 @@ static int stats_dump_full_sess_to_buffer(struct stream_interface *si, struct st
|
||||
|
||||
chunk_appendf(&trash,
|
||||
" frontend=%s (id=%u mode=%s), listener=%s (id=%u)",
|
||||
sess->fe->id, sess->fe->uuid, sess->fe->mode ? "http" : "tcp",
|
||||
strm_sess(sess)->fe->id, strm_sess(sess)->fe->uuid, strm_sess(sess)->fe->mode ? "http" : "tcp",
|
||||
strm_sess(sess)->listener ? strm_sess(sess)->listener->name ? strm_sess(sess)->listener->name : "?" : "?",
|
||||
strm_sess(sess)->listener ? strm_sess(sess)->listener->luid : 0);
|
||||
|
||||
@ -5612,7 +5612,7 @@ static int stats_dump_sess_to_buffer(struct stream_interface *si)
|
||||
" src=%s:%d fe=%s be=%s srv=%s",
|
||||
pn,
|
||||
get_host_port(&conn->addr.from),
|
||||
curr_sess->fe->id,
|
||||
strm_sess(curr_sess)->fe->id,
|
||||
(curr_sess->be->cap & PR_CAP_BE) ? curr_sess->be->id : "<NONE>",
|
||||
objt_server(curr_sess->target) ? objt_server(curr_sess->target)->id : "<none>"
|
||||
);
|
||||
@ -5621,7 +5621,7 @@ static int stats_dump_sess_to_buffer(struct stream_interface *si)
|
||||
chunk_appendf(&trash,
|
||||
" src=unix:%d fe=%s be=%s srv=%s",
|
||||
strm_sess(curr_sess)->listener->luid,
|
||||
curr_sess->fe->id,
|
||||
strm_sess(curr_sess)->fe->id,
|
||||
(curr_sess->be->cap & PR_CAP_BE) ? curr_sess->be->id : "<NONE>",
|
||||
objt_server(curr_sess->target) ? objt_server(curr_sess->target)->id : "<none>"
|
||||
);
|
||||
|
@ -54,8 +54,10 @@
|
||||
*/
|
||||
int frontend_accept(struct stream *s)
|
||||
{
|
||||
struct session *sess = s->sess;
|
||||
struct connection *conn = __objt_conn(s->si[0].end);
|
||||
struct listener *l = strm_sess(s)->listener;
|
||||
struct listener *l = sess->listener;
|
||||
struct proxy *fe = sess->fe;
|
||||
|
||||
int cfd = conn->t.sock.fd;
|
||||
|
||||
@ -82,11 +84,11 @@ int frontend_accept(struct stream *s)
|
||||
(char *) &one, sizeof(one)) == -1)
|
||||
goto out_return;
|
||||
|
||||
if (s->fe->options & PR_O_TCP_CLI_KA)
|
||||
if (fe->options & PR_O_TCP_CLI_KA)
|
||||
setsockopt(cfd, SOL_SOCKET, SO_KEEPALIVE,
|
||||
(char *) &one, sizeof(one));
|
||||
|
||||
if (s->fe->options & PR_O_TCP_NOLING)
|
||||
if (fe->options & PR_O_TCP_NOLING)
|
||||
fdtab[cfd].linger_risk = 1;
|
||||
|
||||
#if defined(TCP_MAXSEG)
|
||||
@ -108,19 +110,19 @@ int frontend_accept(struct stream *s)
|
||||
if (global.tune.client_rcvbuf)
|
||||
setsockopt(cfd, SOL_SOCKET, SO_RCVBUF, &global.tune.client_rcvbuf, sizeof(global.tune.client_rcvbuf));
|
||||
|
||||
if (unlikely(s->fe->nb_req_cap > 0)) {
|
||||
if ((s->txn.req.cap = pool_alloc2(s->fe->req_cap_pool)) == NULL)
|
||||
if (unlikely(fe->nb_req_cap > 0)) {
|
||||
if ((s->txn.req.cap = pool_alloc2(fe->req_cap_pool)) == NULL)
|
||||
goto out_return; /* no memory */
|
||||
memset(s->txn.req.cap, 0, s->fe->nb_req_cap * sizeof(void *));
|
||||
memset(s->txn.req.cap, 0, fe->nb_req_cap * sizeof(void *));
|
||||
}
|
||||
|
||||
if (unlikely(s->fe->nb_rsp_cap > 0)) {
|
||||
if ((s->txn.rsp.cap = pool_alloc2(s->fe->rsp_cap_pool)) == NULL)
|
||||
if (unlikely(fe->nb_rsp_cap > 0)) {
|
||||
if ((s->txn.rsp.cap = pool_alloc2(fe->rsp_cap_pool)) == NULL)
|
||||
goto out_free_reqcap; /* no memory */
|
||||
memset(s->txn.rsp.cap, 0, s->fe->nb_rsp_cap * sizeof(void *));
|
||||
memset(s->txn.rsp.cap, 0, fe->nb_rsp_cap * sizeof(void *));
|
||||
}
|
||||
|
||||
if (s->fe->http_needed) {
|
||||
if (fe->http_needed) {
|
||||
/* we have to allocate header indexes only if we know
|
||||
* that we may make use of them. This of course includes
|
||||
* (mode == PR_MODE_HTTP).
|
||||
@ -134,9 +136,9 @@ int frontend_accept(struct stream *s)
|
||||
http_init_txn(s);
|
||||
}
|
||||
|
||||
if ((s->fe->mode == PR_MODE_TCP || s->fe->mode == PR_MODE_HTTP)
|
||||
&& (!LIST_ISEMPTY(&s->fe->logsrvs))) {
|
||||
if (likely(!LIST_ISEMPTY(&s->fe->logformat))) {
|
||||
if ((fe->mode == PR_MODE_TCP || fe->mode == PR_MODE_HTTP)
|
||||
&& (!LIST_ISEMPTY(&fe->logsrvs))) {
|
||||
if (likely(!LIST_ISEMPTY(&fe->logformat))) {
|
||||
/* we have the client ip */
|
||||
if (s->logs.logwait & LW_CLIP)
|
||||
if (!(s->logs.logwait &= ~(LW_CLIP|LW_INIT)))
|
||||
@ -152,16 +154,16 @@ int frontend_accept(struct stream *s)
|
||||
case AF_INET:
|
||||
case AF_INET6:
|
||||
addr_to_str(&conn->addr.to, sn, sizeof(sn));
|
||||
send_log(s->fe, LOG_INFO, "Connect from %s:%d to %s:%d (%s/%s)\n",
|
||||
send_log(fe, LOG_INFO, "Connect from %s:%d to %s:%d (%s/%s)\n",
|
||||
pn, get_host_port(&conn->addr.from),
|
||||
sn, get_host_port(&conn->addr.to),
|
||||
s->fe->id, (s->fe->mode == PR_MODE_HTTP) ? "HTTP" : "TCP");
|
||||
fe->id, (fe->mode == PR_MODE_HTTP) ? "HTTP" : "TCP");
|
||||
break;
|
||||
case AF_UNIX:
|
||||
/* UNIX socket, only the destination is known */
|
||||
send_log(s->fe, LOG_INFO, "Connect to unix:%d (%s/%s)\n",
|
||||
send_log(fe, LOG_INFO, "Connect to unix:%d (%s/%s)\n",
|
||||
l->luid,
|
||||
s->fe->id, (s->fe->mode == PR_MODE_HTTP) ? "HTTP" : "TCP");
|
||||
fe->id, (fe->mode == PR_MODE_HTTP) ? "HTTP" : "TCP");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -176,13 +178,13 @@ int frontend_accept(struct stream *s)
|
||||
case AF_INET:
|
||||
case AF_INET6:
|
||||
chunk_printf(&trash, "%08x:%s.accept(%04x)=%04x from [%s:%d]\n",
|
||||
s->uniq_id, s->fe->id, (unsigned short)l->fd, (unsigned short)cfd,
|
||||
s->uniq_id, fe->id, (unsigned short)l->fd, (unsigned short)cfd,
|
||||
pn, get_host_port(&conn->addr.from));
|
||||
break;
|
||||
case AF_UNIX:
|
||||
/* UNIX socket, only the destination is known */
|
||||
chunk_printf(&trash, "%08x:%s.accept(%04x)=%04x from [unix:%d]\n",
|
||||
s->uniq_id, s->fe->id, (unsigned short)l->fd, (unsigned short)cfd,
|
||||
s->uniq_id, fe->id, (unsigned short)l->fd, (unsigned short)cfd,
|
||||
l->luid);
|
||||
break;
|
||||
}
|
||||
@ -190,7 +192,7 @@ int frontend_accept(struct stream *s)
|
||||
shut_your_big_mouth_gcc(write(1, trash.str, trash.len));
|
||||
}
|
||||
|
||||
if (s->fe->mode == PR_MODE_HTTP)
|
||||
if (fe->mode == PR_MODE_HTTP)
|
||||
s->req.flags |= CF_READ_DONTWAIT; /* one read is usually enough */
|
||||
|
||||
/* note: this should not happen anymore since there's always at least the switching rules */
|
||||
@ -199,17 +201,17 @@ int frontend_accept(struct stream *s)
|
||||
channel_auto_close(&s->req); /* let the producer forward close requests */
|
||||
}
|
||||
|
||||
s->req.rto = s->fe->timeout.client;
|
||||
s->res.wto = s->fe->timeout.client;
|
||||
s->req.rto = fe->timeout.client;
|
||||
s->res.wto = fe->timeout.client;
|
||||
|
||||
/* everything's OK, let's go on */
|
||||
return 1;
|
||||
|
||||
/* Error unrolling */
|
||||
out_free_rspcap:
|
||||
pool_free2(s->fe->rsp_cap_pool, s->txn.rsp.cap);
|
||||
pool_free2(fe->rsp_cap_pool, s->txn.rsp.cap);
|
||||
out_free_reqcap:
|
||||
pool_free2(s->fe->req_cap_pool, s->txn.req.cap);
|
||||
pool_free2(fe->req_cap_pool, s->txn.req.cap);
|
||||
out_return:
|
||||
return -1;
|
||||
}
|
||||
@ -225,7 +227,7 @@ smp_fetch_fe_id(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
|
||||
{
|
||||
smp->flags = SMP_F_VOL_SESS;
|
||||
smp->type = SMP_T_UINT;
|
||||
smp->data.uint = l4->fe->uuid;
|
||||
smp->data.uint = strm_sess(l4)->fe->uuid;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2139,8 +2139,8 @@ __LJMP static int hlua_socket_new(lua_State *L)
|
||||
socket->s->flags = 0;
|
||||
|
||||
/* Assign the configured proxy to the new stream. */
|
||||
socket->s->sess->fe = &socket_proxy;
|
||||
socket->s->be = &socket_proxy;
|
||||
socket->s->fe = &socket_proxy;
|
||||
|
||||
/* XXX: Set namy variables */
|
||||
socket->s->store_count = 0;
|
||||
|
27
src/log.c
27
src/log.c
@ -920,7 +920,7 @@ const char sess_set_cookie[8] = "NPDIRU67"; /* No set-cookie, Set-cookie found a
|
||||
int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list_format)
|
||||
{
|
||||
struct session *sess = strm_sess(s);
|
||||
struct proxy *fe = s->fe;
|
||||
struct proxy *fe = sess->fe;
|
||||
struct proxy *be = s->be;
|
||||
struct http_txn *txn = &s->txn;
|
||||
char *uri;
|
||||
@ -1541,13 +1541,13 @@ int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list
|
||||
|
||||
case LOG_FMT_LOGCNT: // %lc
|
||||
if (tmp->options & LOG_OPT_HEXA) {
|
||||
iret = snprintf(tmplog, dst + maxsize - tmplog, "%04X", s->fe->log_count);
|
||||
iret = snprintf(tmplog, dst + maxsize - tmplog, "%04X", fe->log_count);
|
||||
if (iret < 0 || iret > dst + maxsize - tmplog)
|
||||
goto out;
|
||||
last_isspace = 0;
|
||||
tmplog += iret;
|
||||
} else {
|
||||
ret = ultoa_o(s->fe->log_count, tmplog, dst + maxsize - tmplog);
|
||||
ret = ultoa_o(fe->log_count, tmplog, dst + maxsize - tmplog);
|
||||
if (ret == NULL)
|
||||
goto out;
|
||||
tmplog = ret;
|
||||
@ -1606,6 +1606,7 @@ out:
|
||||
*/
|
||||
void strm_log(struct stream *s)
|
||||
{
|
||||
struct session *sess = s->sess;
|
||||
char *tmplog;
|
||||
int size, err, level;
|
||||
|
||||
@ -1614,12 +1615,12 @@ void strm_log(struct stream *s)
|
||||
((s->flags & SF_ERR_MASK) > SF_ERR_LOCAL) ||
|
||||
(((s->flags & SF_ERR_MASK) == SF_ERR_NONE) &&
|
||||
(s->si[1].conn_retries != s->be->conn_retries)) ||
|
||||
((s->fe->mode == PR_MODE_HTTP) && s->txn.status >= 500);
|
||||
((sess->fe->mode == PR_MODE_HTTP) && s->txn.status >= 500);
|
||||
|
||||
if (!err && (s->fe->options2 & PR_O2_NOLOGNORM))
|
||||
if (!err && (sess->fe->options2 & PR_O2_NOLOGNORM))
|
||||
return;
|
||||
|
||||
if (LIST_ISEMPTY(&s->fe->logsrvs))
|
||||
if (LIST_ISEMPTY(&sess->fe->logsrvs))
|
||||
return;
|
||||
|
||||
if (s->logs.level) { /* loglevel was overridden */
|
||||
@ -1631,22 +1632,22 @@ void strm_log(struct stream *s)
|
||||
}
|
||||
else {
|
||||
level = LOG_INFO;
|
||||
if (err && (s->fe->options2 & PR_O2_LOGERRORS))
|
||||
if (err && (sess->fe->options2 & PR_O2_LOGERRORS))
|
||||
level = LOG_ERR;
|
||||
}
|
||||
|
||||
/* if unique-id was not generated */
|
||||
if (!s->unique_id && !LIST_ISEMPTY(&s->fe->format_unique_id)) {
|
||||
if (!s->unique_id && !LIST_ISEMPTY(&sess->fe->format_unique_id)) {
|
||||
if ((s->unique_id = pool_alloc2(pool2_uniqueid)) != NULL)
|
||||
build_logline(s, s->unique_id, UNIQUEID_LEN, &s->fe->format_unique_id);
|
||||
build_logline(s, s->unique_id, UNIQUEID_LEN, &sess->fe->format_unique_id);
|
||||
}
|
||||
|
||||
tmplog = update_log_hdr(s->fe->log_tag ? s->fe->log_tag : global.log_tag);
|
||||
tmplog = update_log_hdr(sess->fe->log_tag ? sess->fe->log_tag : global.log_tag);
|
||||
size = tmplog - logline;
|
||||
size += build_logline(s, tmplog, global.max_syslog_len - size, &s->fe->logformat);
|
||||
size += build_logline(s, tmplog, global.max_syslog_len - size, &sess->fe->logformat);
|
||||
if (size > 0) {
|
||||
s->fe->log_count++;
|
||||
__send_log(s->fe, level, logline, size + 1);
|
||||
sess->fe->log_count++;
|
||||
__send_log(sess->fe, level, logline, size + 1);
|
||||
s->logs.logwait = 0;
|
||||
}
|
||||
}
|
||||
|
16
src/peers.c
16
src/peers.c
@ -215,7 +215,7 @@ static void peer_session_release(struct stream_interface *si)
|
||||
static void peer_io_handler(struct stream_interface *si)
|
||||
{
|
||||
struct stream *s = si_strm(si);
|
||||
struct peers *curpeers = (struct peers *)s->fe->parent;
|
||||
struct peers *curpeers = (struct peers *)strm_sess(s)->fe->parent;
|
||||
struct appctx *appctx = objt_appctx(si->end);
|
||||
int reql = 0;
|
||||
int repl = 0;
|
||||
@ -1151,12 +1151,8 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session
|
||||
}
|
||||
|
||||
s->sess->listener = l;
|
||||
|
||||
/* Note: initially, the stream's backend points to the frontend.
|
||||
* This changes later when switching rules are executed or
|
||||
* when the default backend is assigned.
|
||||
*/
|
||||
s->be = s->fe = p;
|
||||
s->sess->fe = p;
|
||||
s->be = s->sess->fe;
|
||||
s->req.buf = s->res.buf = NULL;
|
||||
|
||||
s->si[0].flags = SI_FL_NONE;
|
||||
@ -1165,7 +1161,7 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session
|
||||
si_reset(&s->si[0]);
|
||||
si_set_state(&s->si[0], SI_ST_EST);
|
||||
|
||||
if (s->fe->options2 & PR_O2_INDEPSTR)
|
||||
if (s->sess->fe->options2 & PR_O2_INDEPSTR)
|
||||
s->si[0].flags |= SI_FL_INDEP_STR;
|
||||
|
||||
appctx = stream_int_register_handler(&s->si[0], &peer_applet);
|
||||
@ -1245,14 +1241,14 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session
|
||||
channel_auto_close(&s->req);/* let the producer forward close requests */
|
||||
}
|
||||
|
||||
s->req.rto = s->fe->timeout.client;
|
||||
s->req.rto = s->sess->fe->timeout.client;
|
||||
s->req.wto = s->be->timeout.server;
|
||||
|
||||
channel_init(&s->res);
|
||||
s->res.flags |= CF_ISRESP;
|
||||
|
||||
s->res.rto = s->be->timeout.server;
|
||||
s->res.wto = s->fe->timeout.client;
|
||||
s->res.wto = s->sess->fe->timeout.client;
|
||||
|
||||
s->req.rex = TICK_ETERNITY;
|
||||
s->req.wex = TICK_ETERNITY;
|
||||
|
295
src/proto_http.c
295
src/proto_http.c
@ -850,8 +850,8 @@ struct chunk *http_error_message(struct stream *s, int msgnum)
|
||||
{
|
||||
if (s->be->errmsg[msgnum].str)
|
||||
return &s->be->errmsg[msgnum];
|
||||
else if (s->fe->errmsg[msgnum].str)
|
||||
return &s->fe->errmsg[msgnum];
|
||||
else if (strm_sess(s)->fe->errmsg[msgnum].str)
|
||||
return &strm_sess(s)->fe->errmsg[msgnum];
|
||||
else
|
||||
return &http_err_chunks[msgnum];
|
||||
}
|
||||
@ -2262,7 +2262,7 @@ int select_compression_request_header(struct stream *s, struct buffer *req)
|
||||
}
|
||||
|
||||
/* search for the algo in the backend in priority or the frontend */
|
||||
if ((s->be->comp && (comp_algo_back = s->be->comp->algos)) || (s->fe->comp && (comp_algo_back = s->fe->comp->algos))) {
|
||||
if ((s->be->comp && (comp_algo_back = s->be->comp->algos)) || (strm_sess(s)->fe->comp && (comp_algo_back = strm_sess(s)->fe->comp->algos))) {
|
||||
int best_q = 0;
|
||||
|
||||
ctx.idx = 0;
|
||||
@ -2320,7 +2320,7 @@ int select_compression_request_header(struct stream *s, struct buffer *req)
|
||||
|
||||
/* remove all occurrences of the header when "compression offload" is set */
|
||||
if (s->comp_algo) {
|
||||
if ((s->be->comp && s->be->comp->offload) || (s->fe->comp && s->fe->comp->offload)) {
|
||||
if ((s->be->comp && s->be->comp->offload) || (strm_sess(s)->fe->comp && strm_sess(s)->fe->comp->offload)) {
|
||||
http_remove_header2(msg, &txn->hdr_idx, &ctx);
|
||||
ctx.idx = 0;
|
||||
while (http_find_header2("Accept-Encoding", 15, req->p, &txn->hdr_idx, &ctx)) {
|
||||
@ -2331,7 +2331,7 @@ int select_compression_request_header(struct stream *s, struct buffer *req)
|
||||
}
|
||||
|
||||
/* identity is implicit does not require headers */
|
||||
if ((s->be->comp && (comp_algo_back = s->be->comp->algos)) || (s->fe->comp && (comp_algo_back = s->fe->comp->algos))) {
|
||||
if ((s->be->comp && (comp_algo_back = s->be->comp->algos)) || (strm_sess(s)->fe->comp && (comp_algo_back = strm_sess(s)->fe->comp->algos))) {
|
||||
for (comp_algo = comp_algo_back; comp_algo; comp_algo = comp_algo->next) {
|
||||
if (comp_algo->cfg_name_len == 8 && memcmp(comp_algo->cfg_name, "identity", 8) == 0) {
|
||||
s->comp_algo = comp_algo;
|
||||
@ -2398,7 +2398,7 @@ int select_compression_response_header(struct stream *s, struct buffer *res)
|
||||
goto fail;
|
||||
|
||||
if ((s->be->comp && (comp_type = s->be->comp->types)) ||
|
||||
(s->fe->comp && (comp_type = s->fe->comp->types))) {
|
||||
(strm_sess(s)->fe->comp && (comp_type = strm_sess(s)->fe->comp->types))) {
|
||||
for (; comp_type; comp_type = comp_type->next) {
|
||||
if (ctx.vlen >= comp_type->name_len &&
|
||||
strncasecmp(ctx.line+ctx.val, comp_type->name, comp_type->name_len) == 0)
|
||||
@ -2411,7 +2411,7 @@ int select_compression_response_header(struct stream *s, struct buffer *res)
|
||||
}
|
||||
}
|
||||
else { /* no content-type header */
|
||||
if ((s->be->comp && s->be->comp->types) || (s->fe->comp && s->fe->comp->types))
|
||||
if ((s->be->comp && s->be->comp->types) || (strm_sess(s)->fe->comp && strm_sess(s)->fe->comp->types))
|
||||
goto fail; /* a content-type was required */
|
||||
}
|
||||
|
||||
@ -2462,29 +2462,30 @@ fail:
|
||||
|
||||
void http_adjust_conn_mode(struct stream *s, struct http_txn *txn, struct http_msg *msg)
|
||||
{
|
||||
struct proxy *fe = strm_sess(s)->fe;
|
||||
int tmp = TX_CON_WANT_KAL;
|
||||
|
||||
if (!((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA)) {
|
||||
if ((s->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_TUN ||
|
||||
if (!((fe->options2|s->be->options2) & PR_O2_FAKE_KA)) {
|
||||
if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_TUN ||
|
||||
(s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_TUN)
|
||||
tmp = TX_CON_WANT_TUN;
|
||||
|
||||
if ((s->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
|
||||
if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
|
||||
(s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL)
|
||||
tmp = TX_CON_WANT_TUN;
|
||||
}
|
||||
|
||||
if ((s->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_SCL ||
|
||||
if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_SCL ||
|
||||
(s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_SCL) {
|
||||
/* option httpclose + server_close => forceclose */
|
||||
if ((s->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
|
||||
if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
|
||||
(s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL)
|
||||
tmp = TX_CON_WANT_CLO;
|
||||
else
|
||||
tmp = TX_CON_WANT_SCL;
|
||||
}
|
||||
|
||||
if ((s->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_FCL ||
|
||||
if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_FCL ||
|
||||
(s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_FCL)
|
||||
tmp = TX_CON_WANT_CLO;
|
||||
|
||||
@ -2497,7 +2498,7 @@ void http_adjust_conn_mode(struct stream *s, struct http_txn *txn, struct http_m
|
||||
int to_del = 0;
|
||||
if ((msg->flags & HTTP_MSGF_VER_11) ||
|
||||
((txn->flags & TX_CON_WANT_MSK) >= TX_CON_WANT_SCL &&
|
||||
!((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA)))
|
||||
!((fe->options2|s->be->options2) & PR_O2_FAKE_KA)))
|
||||
to_del |= 2; /* remove "keep-alive" */
|
||||
if (!(msg->flags & HTTP_MSGF_VER_11))
|
||||
to_del |= 1; /* remove "close" */
|
||||
@ -2510,7 +2511,7 @@ void http_adjust_conn_mode(struct stream *s, struct http_txn *txn, struct http_m
|
||||
((txn->flags & TX_HDR_CONN_CLO) || /* "connection: close" */
|
||||
(!(msg->flags & HTTP_MSGF_VER_11) && !(txn->flags & TX_HDR_CONN_KAL)) || /* no "connection: k-a" in 1.0 */
|
||||
!(msg->flags & HTTP_MSGF_XFER_LEN) || /* no length known => close */
|
||||
s->fe->state == PR_STSTOPPED)) /* frontend is stopping */
|
||||
fe->state == PR_STSTOPPED)) /* frontend is stopping */
|
||||
txn->flags = (txn->flags & ~TX_CON_WANT_MSK) | TX_CON_WANT_CLO;
|
||||
}
|
||||
|
||||
@ -2660,7 +2661,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
if (unlikely(msg->msg_state == HTTP_MSG_ERROR)) {
|
||||
stream_inc_http_req_ctr(s);
|
||||
stream_inc_http_err_ctr(s);
|
||||
proxy_inc_fe_req_ctr(s->fe);
|
||||
proxy_inc_fe_req_ctr(sess->fe);
|
||||
goto return_bad_req;
|
||||
}
|
||||
|
||||
@ -2675,7 +2676,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
*/
|
||||
stream_inc_http_req_ctr(s);
|
||||
stream_inc_http_err_ctr(s);
|
||||
proxy_inc_fe_req_ctr(s->fe);
|
||||
proxy_inc_fe_req_ctr(sess->fe);
|
||||
if (msg->err_pos < 0)
|
||||
msg->err_pos = req->buf->i;
|
||||
goto return_bad_req;
|
||||
@ -2691,7 +2692,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
|
||||
/* we cannot return any message on error */
|
||||
if (msg->err_pos >= 0) {
|
||||
http_capture_bad_message(&s->fe->invalid_req, s, msg, msg->msg_state, s->fe);
|
||||
http_capture_bad_message(&sess->fe->invalid_req, s, msg, msg->msg_state, sess->fe);
|
||||
stream_inc_http_err_ctr(s);
|
||||
}
|
||||
|
||||
@ -2701,8 +2702,8 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
req->analysers = 0;
|
||||
|
||||
stream_inc_http_req_ctr(s);
|
||||
proxy_inc_fe_req_ctr(s->fe);
|
||||
s->fe->fe_counters.failed_req++;
|
||||
proxy_inc_fe_req_ctr(sess->fe);
|
||||
sess->fe->fe_counters.failed_req++;
|
||||
if (sess->listener->counters)
|
||||
sess->listener->counters->failed_req++;
|
||||
|
||||
@ -2721,7 +2722,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
|
||||
/* read timeout : give up with an error message. */
|
||||
if (msg->err_pos >= 0) {
|
||||
http_capture_bad_message(&s->fe->invalid_req, s, msg, msg->msg_state, s->fe);
|
||||
http_capture_bad_message(&sess->fe->invalid_req, s, msg, msg->msg_state, sess->fe);
|
||||
stream_inc_http_err_ctr(s);
|
||||
}
|
||||
txn->status = 408;
|
||||
@ -2730,8 +2731,8 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
req->analysers = 0;
|
||||
|
||||
stream_inc_http_req_ctr(s);
|
||||
proxy_inc_fe_req_ctr(s->fe);
|
||||
s->fe->fe_counters.failed_req++;
|
||||
proxy_inc_fe_req_ctr(sess->fe);
|
||||
sess->fe->fe_counters.failed_req++;
|
||||
if (sess->listener->counters)
|
||||
sess->listener->counters->failed_req++;
|
||||
|
||||
@ -2749,7 +2750,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
goto failed_keep_alive;
|
||||
|
||||
if (msg->err_pos >= 0)
|
||||
http_capture_bad_message(&s->fe->invalid_req, s, msg, msg->msg_state, s->fe);
|
||||
http_capture_bad_message(&sess->fe->invalid_req, s, msg, msg->msg_state, sess->fe);
|
||||
txn->status = 400;
|
||||
stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_400));
|
||||
msg->msg_state = HTTP_MSG_ERROR;
|
||||
@ -2757,8 +2758,8 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
|
||||
stream_inc_http_err_ctr(s);
|
||||
stream_inc_http_req_ctr(s);
|
||||
proxy_inc_fe_req_ctr(s->fe);
|
||||
s->fe->fe_counters.failed_req++;
|
||||
proxy_inc_fe_req_ctr(sess->fe);
|
||||
sess->fe->fe_counters.failed_req++;
|
||||
if (sess->listener->counters)
|
||||
sess->listener->counters->failed_req++;
|
||||
|
||||
@ -2828,7 +2829,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
*/
|
||||
|
||||
stream_inc_http_req_ctr(s);
|
||||
proxy_inc_fe_req_ctr(s->fe); /* one more valid request for this FE */
|
||||
proxy_inc_fe_req_ctr(sess->fe); /* one more valid request for this FE */
|
||||
|
||||
if (txn->flags & TX_WAIT_NEXT_RQ) {
|
||||
/* kill the pending keep-alive timeout */
|
||||
@ -2841,7 +2842,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
* to block on that, so we have to capture it now.
|
||||
*/
|
||||
if (unlikely(msg->err_pos >= 0))
|
||||
http_capture_bad_message(&s->fe->invalid_req, s, msg, msg->msg_state, s->fe);
|
||||
http_capture_bad_message(&sess->fe->invalid_req, s, msg, msg->msg_state, sess->fe);
|
||||
|
||||
/*
|
||||
* 1: identify the method
|
||||
@ -2857,22 +2858,22 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
* We have to do this for every request which gets in, because
|
||||
* the monitor-uri is defined by the frontend.
|
||||
*/
|
||||
if (unlikely((s->fe->monitor_uri_len != 0) &&
|
||||
(s->fe->monitor_uri_len == msg->sl.rq.u_l) &&
|
||||
if (unlikely((sess->fe->monitor_uri_len != 0) &&
|
||||
(sess->fe->monitor_uri_len == msg->sl.rq.u_l) &&
|
||||
!memcmp(req->buf->p + msg->sl.rq.u,
|
||||
s->fe->monitor_uri,
|
||||
s->fe->monitor_uri_len))) {
|
||||
sess->fe->monitor_uri,
|
||||
sess->fe->monitor_uri_len))) {
|
||||
/*
|
||||
* We have found the monitor URI
|
||||
*/
|
||||
struct acl_cond *cond;
|
||||
|
||||
s->flags |= SF_MONITOR;
|
||||
s->fe->fe_counters.intercepted_req++;
|
||||
sess->fe->fe_counters.intercepted_req++;
|
||||
|
||||
/* Check if we want to fail this monitor request or not */
|
||||
list_for_each_entry(cond, &s->fe->mon_fail_cond, list) {
|
||||
int ret = acl_exec_cond(cond, s->fe, s, txn, SMP_OPT_DIR_REQ|SMP_OPT_FINAL);
|
||||
list_for_each_entry(cond, &sess->fe->mon_fail_cond, list) {
|
||||
int ret = acl_exec_cond(cond, sess->fe, s, txn, SMP_OPT_DIR_REQ|SMP_OPT_FINAL);
|
||||
|
||||
ret = acl_pass(ret);
|
||||
if (cond->pol == ACL_COND_UNLESS)
|
||||
@ -2941,7 +2942,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
* a proxied connection, which covers both "scheme://location" and
|
||||
* CONNECT ip:port.
|
||||
*/
|
||||
if ((s->fe->options2 & PR_O2_USE_PXHDR) &&
|
||||
if ((sess->fe->options2 & PR_O2_USE_PXHDR) &&
|
||||
req->buf->p[msg->sl.rq.u] != '/' && req->buf->p[msg->sl.rq.u] != '*')
|
||||
txn->flags |= TX_USE_PX_CONN;
|
||||
|
||||
@ -2951,7 +2952,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
/* 5: we may need to capture headers */
|
||||
if (unlikely((s->logs.logwait & LW_REQHDR) && txn->req.cap))
|
||||
capture_headers(req->buf->p, &txn->hdr_idx,
|
||||
txn->req.cap, s->fe->req_cap);
|
||||
txn->req.cap, sess->fe->req_cap);
|
||||
|
||||
/* 6: determine the transfer-length.
|
||||
* According to RFC2616 #4.4, amended by the HTTPbis working group,
|
||||
@ -3050,7 +3051,7 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
* time.
|
||||
*/
|
||||
if (!(txn->flags & TX_HDR_CONN_PRS) ||
|
||||
((s->fe->options & PR_O_HTTP_MODE) != (s->be->options & PR_O_HTTP_MODE)))
|
||||
((sess->fe->options & PR_O_HTTP_MODE) != (s->be->options & PR_O_HTTP_MODE)))
|
||||
http_adjust_conn_mode(s, txn, msg);
|
||||
|
||||
/* end of job, return OK */
|
||||
@ -3064,14 +3065,14 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
/* we detected a parsing error. We want to archive this request
|
||||
* in the dedicated proxy area for later troubleshooting.
|
||||
*/
|
||||
http_capture_bad_message(&s->fe->invalid_req, s, msg, msg->msg_state, s->fe);
|
||||
http_capture_bad_message(&sess->fe->invalid_req, s, msg, msg->msg_state, sess->fe);
|
||||
}
|
||||
|
||||
txn->req.msg_state = HTTP_MSG_ERROR;
|
||||
txn->status = 400;
|
||||
stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_400));
|
||||
|
||||
s->fe->fe_counters.failed_req++;
|
||||
sess->fe->fe_counters.failed_req++;
|
||||
if (sess->listener->counters)
|
||||
sess->listener->counters->failed_req++;
|
||||
|
||||
@ -3576,7 +3577,7 @@ resume_execution:
|
||||
t->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u, 1);
|
||||
|
||||
stkctr_set_flags(&s->stkctr[http_req_trk_idx(rule->action)], STKCTR_TRACK_CONTENT);
|
||||
if (s->fe != s->be)
|
||||
if (strm_sess(s)->fe != s->be)
|
||||
stkctr_set_flags(&s->stkctr[http_req_trk_idx(rule->action)], STKCTR_TRACK_BACKEND);
|
||||
}
|
||||
}
|
||||
@ -4179,8 +4180,8 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
|
||||
/* Proceed with the stats now. */
|
||||
if (unlikely(objt_applet(s->target) == &http_stats_applet)) {
|
||||
/* process the stats request now */
|
||||
if (s->fe == s->be) /* report it if the request was intercepted by the frontend */
|
||||
s->fe->fe_counters.intercepted_req++;
|
||||
if (sess->fe == s->be) /* report it if the request was intercepted by the frontend */
|
||||
sess->fe->fe_counters.intercepted_req++;
|
||||
|
||||
if (!(s->flags & SF_ERR_MASK)) // this is not really an error but it is
|
||||
s->flags |= SF_ERR_LOCAL; // to mark that it comes from the proxy
|
||||
@ -4188,7 +4189,7 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
|
||||
s->flags |= SF_FINST_R;
|
||||
|
||||
/* we may want to compress the stats page */
|
||||
if (s->fe->comp || s->be->comp)
|
||||
if (sess->fe->comp || s->be->comp)
|
||||
select_compression_request_header(s, req->buf);
|
||||
|
||||
/* enable the minimally required analyzers to handle keep-alive and compression on the HTTP response */
|
||||
@ -4248,8 +4249,8 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
|
||||
if (!req->analyse_exp)
|
||||
req->analyse_exp = tick_add(now_ms, 0);
|
||||
stream_inc_http_err_ctr(s);
|
||||
s->fe->fe_counters.denied_req++;
|
||||
if (s->fe != s->be)
|
||||
sess->fe->fe_counters.denied_req++;
|
||||
if (sess->fe != s->be)
|
||||
s->be->be_counters.denied_req++;
|
||||
if (sess->listener->counters)
|
||||
sess->listener->counters->denied_req++;
|
||||
@ -4261,8 +4262,8 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
|
||||
s->logs.tv_request = now;
|
||||
stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_403));
|
||||
stream_inc_http_err_ctr(s);
|
||||
s->fe->fe_counters.denied_req++;
|
||||
if (s->fe != s->be)
|
||||
sess->fe->fe_counters.denied_req++;
|
||||
if (sess->fe != s->be)
|
||||
s->be->be_counters.denied_req++;
|
||||
if (sess->listener->counters)
|
||||
sess->listener->counters->denied_req++;
|
||||
@ -4274,14 +4275,14 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
|
||||
/* we detected a parsing error. We want to archive this request
|
||||
* in the dedicated proxy area for later troubleshooting.
|
||||
*/
|
||||
http_capture_bad_message(&s->fe->invalid_req, s, msg, msg->msg_state, s->fe);
|
||||
http_capture_bad_message(&sess->fe->invalid_req, s, msg, msg->msg_state, sess->fe);
|
||||
}
|
||||
|
||||
txn->req.msg_state = HTTP_MSG_ERROR;
|
||||
txn->status = 400;
|
||||
stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_400));
|
||||
|
||||
s->fe->fe_counters.failed_req++;
|
||||
sess->fe->fe_counters.failed_req++;
|
||||
if (sess->listener->counters)
|
||||
sess->listener->counters->failed_req++;
|
||||
|
||||
@ -4327,7 +4328,7 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
req->buf->i,
|
||||
req->analysers);
|
||||
|
||||
if (s->fe->comp || s->be->comp)
|
||||
if (sess->fe->comp || s->be->comp)
|
||||
select_compression_request_header(s, req->buf);
|
||||
|
||||
/*
|
||||
@ -4401,7 +4402,7 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
* the fields will stay coherent and the URI will not move.
|
||||
* This should only be performed in the backend.
|
||||
*/
|
||||
if ((s->be->cookie_name || s->be->appsession_name || s->fe->capture_name)
|
||||
if ((s->be->cookie_name || s->be->appsession_name || sess->fe->capture_name)
|
||||
&& !(txn->flags & (TX_CLDENY|TX_CLTARPIT)))
|
||||
manage_client_side_cookies(s, req);
|
||||
|
||||
@ -4417,15 +4418,15 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
|
||||
/* add unique-id if "header-unique-id" is specified */
|
||||
|
||||
if (!LIST_ISEMPTY(&s->fe->format_unique_id)) {
|
||||
if (!LIST_ISEMPTY(&sess->fe->format_unique_id)) {
|
||||
if ((s->unique_id = pool_alloc2(pool2_uniqueid)) == NULL)
|
||||
goto return_bad_req;
|
||||
s->unique_id[0] = '\0';
|
||||
build_logline(s, s->unique_id, UNIQUEID_LEN, &s->fe->format_unique_id);
|
||||
build_logline(s, s->unique_id, UNIQUEID_LEN, &sess->fe->format_unique_id);
|
||||
}
|
||||
|
||||
if (s->fe->header_unique_id && s->unique_id) {
|
||||
chunk_printf(&trash, "%s: %s", s->fe->header_unique_id, s->unique_id);
|
||||
if (sess->fe->header_unique_id && s->unique_id) {
|
||||
chunk_printf(&trash, "%s: %s", sess->fe->header_unique_id, s->unique_id);
|
||||
if (trash.len < 0)
|
||||
goto return_bad_req;
|
||||
if (unlikely(http_header_add_tail2(&txn->req, &txn->hdr_idx, trash.str, trash.len) < 0))
|
||||
@ -4436,11 +4437,11 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
* 9: add X-Forwarded-For if either the frontend or the backend
|
||||
* asks for it.
|
||||
*/
|
||||
if ((s->fe->options | s->be->options) & PR_O_FWDFOR) {
|
||||
if ((sess->fe->options | s->be->options) & PR_O_FWDFOR) {
|
||||
struct hdr_ctx ctx = { .idx = 0 };
|
||||
if (!((s->fe->options | s->be->options) & PR_O_FF_ALWAYS) &&
|
||||
http_find_header2(s->be->fwdfor_hdr_len ? s->be->fwdfor_hdr_name : s->fe->fwdfor_hdr_name,
|
||||
s->be->fwdfor_hdr_len ? s->be->fwdfor_hdr_len : s->fe->fwdfor_hdr_len,
|
||||
if (!((sess->fe->options | s->be->options) & PR_O_FF_ALWAYS) &&
|
||||
http_find_header2(s->be->fwdfor_hdr_len ? s->be->fwdfor_hdr_name : sess->fe->fwdfor_hdr_name,
|
||||
s->be->fwdfor_hdr_len ? s->be->fwdfor_hdr_len : sess->fe->fwdfor_hdr_len,
|
||||
req->buf->p, &txn->hdr_idx, &ctx)) {
|
||||
/* The header is set to be added only if none is present
|
||||
* and we found it, so don't do anything.
|
||||
@ -4450,9 +4451,9 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
/* Add an X-Forwarded-For header unless the source IP is
|
||||
* in the 'except' network range.
|
||||
*/
|
||||
if ((!s->fe->except_mask.s_addr ||
|
||||
(((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr.s_addr & s->fe->except_mask.s_addr)
|
||||
!= s->fe->except_net.s_addr) &&
|
||||
if ((!sess->fe->except_mask.s_addr ||
|
||||
(((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr.s_addr & sess->fe->except_mask.s_addr)
|
||||
!= sess->fe->except_net.s_addr) &&
|
||||
(!s->be->except_mask.s_addr ||
|
||||
(((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr.s_addr & s->be->except_mask.s_addr)
|
||||
!= s->be->except_net.s_addr)) {
|
||||
@ -4469,8 +4470,8 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
len = s->be->fwdfor_hdr_len;
|
||||
memcpy(trash.str, s->be->fwdfor_hdr_name, len);
|
||||
} else {
|
||||
len = s->fe->fwdfor_hdr_len;
|
||||
memcpy(trash.str, s->fe->fwdfor_hdr_name, len);
|
||||
len = sess->fe->fwdfor_hdr_len;
|
||||
memcpy(trash.str, sess->fe->fwdfor_hdr_name, len);
|
||||
}
|
||||
len += snprintf(trash.str + len, trash.size - len, ": %d.%d.%d.%d", pn[0], pn[1], pn[2], pn[3]);
|
||||
|
||||
@ -4497,8 +4498,8 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
len = s->be->fwdfor_hdr_len;
|
||||
memcpy(trash.str, s->be->fwdfor_hdr_name, len);
|
||||
} else {
|
||||
len = s->fe->fwdfor_hdr_len;
|
||||
memcpy(trash.str, s->fe->fwdfor_hdr_name, len);
|
||||
len = sess->fe->fwdfor_hdr_len;
|
||||
memcpy(trash.str, sess->fe->fwdfor_hdr_name, len);
|
||||
}
|
||||
len += snprintf(trash.str + len, trash.size - len, ": %s", pn);
|
||||
|
||||
@ -4511,7 +4512,7 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
* 10: add X-Original-To if either the frontend or the backend
|
||||
* asks for it.
|
||||
*/
|
||||
if ((s->fe->options | s->be->options) & PR_O_ORGTO) {
|
||||
if ((sess->fe->options | s->be->options) & PR_O_ORGTO) {
|
||||
|
||||
/* FIXME: don't know if IPv6 can handle that case too. */
|
||||
if (cli_conn && cli_conn->addr.from.ss_family == AF_INET) {
|
||||
@ -4521,9 +4522,9 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
conn_get_to_addr(cli_conn);
|
||||
|
||||
if (cli_conn->addr.to.ss_family == AF_INET &&
|
||||
((!s->fe->except_mask_to.s_addr ||
|
||||
(((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr.s_addr & s->fe->except_mask_to.s_addr)
|
||||
!= s->fe->except_to.s_addr) &&
|
||||
((!sess->fe->except_mask_to.s_addr ||
|
||||
(((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr.s_addr & sess->fe->except_mask_to.s_addr)
|
||||
!= sess->fe->except_to.s_addr) &&
|
||||
(!s->be->except_mask_to.s_addr ||
|
||||
(((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr.s_addr & s->be->except_mask_to.s_addr)
|
||||
!= s->be->except_to.s_addr))) {
|
||||
@ -4540,8 +4541,8 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
len = s->be->orgto_hdr_len;
|
||||
memcpy(trash.str, s->be->orgto_hdr_name, len);
|
||||
} else {
|
||||
len = s->fe->orgto_hdr_len;
|
||||
memcpy(trash.str, s->fe->orgto_hdr_name, len);
|
||||
len = sess->fe->orgto_hdr_len;
|
||||
memcpy(trash.str, sess->fe->orgto_hdr_name, len);
|
||||
}
|
||||
len += snprintf(trash.str + len, trash.size - len, ": %d.%d.%d.%d", pn[0], pn[1], pn[2], pn[3]);
|
||||
|
||||
@ -4558,21 +4559,21 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
*/
|
||||
if (!(txn->flags & TX_HDR_CONN_UPG) &&
|
||||
(((txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN) ||
|
||||
((s->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
|
||||
((sess->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
|
||||
(s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL))) {
|
||||
unsigned int want_flags = 0;
|
||||
|
||||
if (msg->flags & HTTP_MSGF_VER_11) {
|
||||
if (((txn->flags & TX_CON_WANT_MSK) >= TX_CON_WANT_SCL ||
|
||||
((s->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
|
||||
((sess->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
|
||||
(s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL)) &&
|
||||
!((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA))
|
||||
!((sess->fe->options2|s->be->options2) & PR_O2_FAKE_KA))
|
||||
want_flags |= TX_CON_CLO_SET;
|
||||
} else {
|
||||
if (((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL &&
|
||||
((s->fe->options & PR_O_HTTP_MODE) != PR_O_HTTP_PCL &&
|
||||
((sess->fe->options & PR_O_HTTP_MODE) != PR_O_HTTP_PCL &&
|
||||
(s->be->options & PR_O_HTTP_MODE) != PR_O_HTTP_PCL)) ||
|
||||
((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA))
|
||||
((sess->fe->options2|s->be->options2) & PR_O2_FAKE_KA))
|
||||
want_flags |= TX_CON_KAL_SET;
|
||||
}
|
||||
|
||||
@ -4630,7 +4631,7 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
/* we detected a parsing error. We want to archive this request
|
||||
* in the dedicated proxy area for later troubleshooting.
|
||||
*/
|
||||
http_capture_bad_message(&s->fe->invalid_req, s, msg, msg->msg_state, s->fe);
|
||||
http_capture_bad_message(&sess->fe->invalid_req, s, msg, msg->msg_state, sess->fe);
|
||||
}
|
||||
|
||||
txn->req.msg_state = HTTP_MSG_ERROR;
|
||||
@ -4638,7 +4639,7 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
req->analysers = 0;
|
||||
stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_400));
|
||||
|
||||
s->fe->fe_counters.failed_req++;
|
||||
sess->fe->fe_counters.failed_req++;
|
||||
if (sess->listener->counters)
|
||||
sess->listener->counters->failed_req++;
|
||||
|
||||
@ -4831,7 +4832,7 @@ int http_wait_for_request_body(struct stream *s, struct channel *req, int an_bit
|
||||
|
||||
return_err_msg:
|
||||
req->analysers = 0;
|
||||
s->fe->fe_counters.failed_req++;
|
||||
sess->fe->fe_counters.failed_req++;
|
||||
if (sess->listener->counters)
|
||||
sess->listener->counters->failed_req++;
|
||||
return 0;
|
||||
@ -4898,6 +4899,7 @@ int http_send_name_header(struct http_txn *txn, struct proxy* be, const char* sr
|
||||
void http_end_txn_clean_session(struct stream *s)
|
||||
{
|
||||
int prev_status = s->txn.status;
|
||||
struct proxy *fe = strm_sess(s)->fe;
|
||||
|
||||
/* FIXME: We need a more portable way of releasing a backend's and a
|
||||
* server's connections. We need a safer way to reinitialize buffer
|
||||
@ -4931,10 +4933,10 @@ void http_end_txn_clean_session(struct stream *s)
|
||||
if (n < 1 || n > 5)
|
||||
n = 0;
|
||||
|
||||
if (s->fe->mode == PR_MODE_HTTP) {
|
||||
s->fe->fe_counters.p.http.rsp[n]++;
|
||||
if (fe->mode == PR_MODE_HTTP) {
|
||||
fe->fe_counters.p.http.rsp[n]++;
|
||||
if (s->comp_algo && (s->flags & SF_COMP_READY))
|
||||
s->fe->fe_counters.p.http.comp_rsp++;
|
||||
fe->fe_counters.p.http.comp_rsp++;
|
||||
}
|
||||
if ((s->flags & SF_BE_ASSIGNED) &&
|
||||
(s->be->mode == PR_MODE_HTTP)) {
|
||||
@ -4950,9 +4952,9 @@ void http_end_txn_clean_session(struct stream *s)
|
||||
s->logs.bytes_out -= s->res.buf->i;
|
||||
|
||||
/* let's do a final log if we need it */
|
||||
if (!LIST_ISEMPTY(&s->fe->logformat) && s->logs.logwait &&
|
||||
if (!LIST_ISEMPTY(&fe->logformat) && s->logs.logwait &&
|
||||
!(s->flags & SF_MONITOR) &&
|
||||
(!(s->fe->options & PR_O_NULLNOLOG) || s->req.total)) {
|
||||
(!(fe->options & PR_O_NULLNOLOG) || s->req.total)) {
|
||||
s->do_log(s);
|
||||
}
|
||||
|
||||
@ -5021,10 +5023,10 @@ void http_end_txn_clean_session(struct stream *s)
|
||||
s->txn.flags |= TX_PREFER_LAST;
|
||||
}
|
||||
|
||||
if (s->fe->options2 & PR_O2_INDEPSTR)
|
||||
if (fe->options2 & PR_O2_INDEPSTR)
|
||||
s->si[1].flags |= SI_FL_INDEP_STR;
|
||||
|
||||
if (s->fe->options2 & PR_O2_NODELAY) {
|
||||
if (fe->options2 & PR_O2_NODELAY) {
|
||||
s->req.flags |= CF_NEVER_WAIT;
|
||||
s->res.flags |= CF_NEVER_WAIT;
|
||||
}
|
||||
@ -5505,7 +5507,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
|
||||
else if (ret < 0) {
|
||||
stream_inc_http_err_ctr(s);
|
||||
if (msg->err_pos >= 0)
|
||||
http_capture_bad_message(&s->fe->invalid_req, s, msg, HTTP_MSG_CHUNK_SIZE, s->be);
|
||||
http_capture_bad_message(&sess->fe->invalid_req, s, msg, HTTP_MSG_CHUNK_SIZE, s->be);
|
||||
goto return_bad_req;
|
||||
}
|
||||
/* otherwise we're in HTTP_MSG_DATA or HTTP_MSG_TRAILERS state */
|
||||
@ -5519,7 +5521,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
|
||||
else if (ret < 0) {
|
||||
stream_inc_http_err_ctr(s);
|
||||
if (msg->err_pos >= 0)
|
||||
http_capture_bad_message(&s->fe->invalid_req, s, msg, HTTP_MSG_CHUNK_CRLF, s->be);
|
||||
http_capture_bad_message(&sess->fe->invalid_req, s, msg, HTTP_MSG_CHUNK_CRLF, s->be);
|
||||
goto return_bad_req;
|
||||
}
|
||||
/* we're in MSG_CHUNK_SIZE now */
|
||||
@ -5532,7 +5534,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
|
||||
else if (ret < 0) {
|
||||
stream_inc_http_err_ctr(s);
|
||||
if (msg->err_pos >= 0)
|
||||
http_capture_bad_message(&s->fe->invalid_req, s, msg, HTTP_MSG_TRAILERS, s->be);
|
||||
http_capture_bad_message(&sess->fe->invalid_req, s, msg, HTTP_MSG_TRAILERS, s->be);
|
||||
goto return_bad_req;
|
||||
}
|
||||
/* we're in HTTP_MSG_DONE now */
|
||||
@ -5566,7 +5568,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
|
||||
goto aborted_xfer;
|
||||
}
|
||||
if (msg->err_pos >= 0)
|
||||
http_capture_bad_message(&s->fe->invalid_req, s, msg, old_state, s->be);
|
||||
http_capture_bad_message(&sess->fe->invalid_req, s, msg, old_state, s->be);
|
||||
goto return_bad_req;
|
||||
}
|
||||
return 1;
|
||||
@ -5615,7 +5617,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
|
||||
s->flags |= SF_FINST_D;
|
||||
}
|
||||
|
||||
s->fe->fe_counters.cli_aborts++;
|
||||
sess->fe->fe_counters.cli_aborts++;
|
||||
s->be->be_counters.cli_aborts++;
|
||||
if (objt_server(s->target))
|
||||
objt_server(s->target)->counters.cli_aborts++;
|
||||
@ -5647,7 +5649,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
|
||||
return 0;
|
||||
|
||||
return_bad_req: /* let's centralize all bad requests */
|
||||
s->fe->fe_counters.failed_req++;
|
||||
sess->fe->fe_counters.failed_req++;
|
||||
if (sess->listener->counters)
|
||||
sess->listener->counters->failed_req++;
|
||||
|
||||
@ -5689,7 +5691,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
|
||||
req->analysers = 0;
|
||||
s->res.analysers = 0; /* we're in data phase, we want to abort both directions */
|
||||
|
||||
s->fe->fe_counters.srv_aborts++;
|
||||
sess->fe->fe_counters.srv_aborts++;
|
||||
s->be->be_counters.srv_aborts++;
|
||||
if (objt_server(s->target))
|
||||
objt_server(s->target)->counters.srv_aborts++;
|
||||
@ -5714,6 +5716,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
|
||||
*/
|
||||
int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
{
|
||||
struct session *sess = s->sess;
|
||||
struct http_txn *txn = &s->txn;
|
||||
struct http_msg *msg = &txn->rsp;
|
||||
struct hdr_ctx ctx;
|
||||
@ -5813,7 +5816,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
*/
|
||||
hdr_response_bad:
|
||||
if (msg->msg_state == HTTP_MSG_ERROR || msg->err_pos >= 0)
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, s->fe);
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, sess->fe);
|
||||
|
||||
s->be->be_counters.failed_resp++;
|
||||
if (objt_server(s->target)) {
|
||||
@ -5846,7 +5849,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
/* read error */
|
||||
else if (rep->flags & CF_READ_ERROR) {
|
||||
if (msg->err_pos >= 0)
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, s->fe);
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, sess->fe);
|
||||
else if (txn->flags & TX_NOT_FIRST)
|
||||
goto abort_keep_alive;
|
||||
|
||||
@ -5873,7 +5876,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
/* read timeout : return a 504 to the client. */
|
||||
else if (rep->flags & CF_READ_TIMEOUT) {
|
||||
if (msg->err_pos >= 0)
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, s->fe);
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, sess->fe);
|
||||
else if (txn->flags & TX_NOT_FIRST)
|
||||
goto abort_keep_alive;
|
||||
|
||||
@ -5899,7 +5902,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
|
||||
/* client abort with an abortonclose */
|
||||
else if ((rep->flags & CF_SHUTR) && ((s->req.flags & (CF_SHUTR|CF_SHUTW)) == (CF_SHUTR|CF_SHUTW))) {
|
||||
s->fe->fe_counters.cli_aborts++;
|
||||
sess->fe->fe_counters.cli_aborts++;
|
||||
s->be->be_counters.cli_aborts++;
|
||||
if (objt_server(s->target))
|
||||
objt_server(s->target)->counters.cli_aborts++;
|
||||
@ -5923,7 +5926,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
/* close from server, capture the response if the server has started to respond */
|
||||
else if (rep->flags & CF_SHUTR) {
|
||||
if (msg->msg_state >= HTTP_MSG_RPVER || msg->err_pos >= 0)
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, s->fe);
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, sess->fe);
|
||||
else if (txn->flags & TX_NOT_FIRST)
|
||||
goto abort_keep_alive;
|
||||
|
||||
@ -5950,7 +5953,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
/* write error to client (we don't send any message then) */
|
||||
else if (rep->flags & CF_WRITE_ERROR) {
|
||||
if (msg->err_pos >= 0)
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, s->fe);
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, sess->fe);
|
||||
else if (txn->flags & TX_NOT_FIRST)
|
||||
goto abort_keep_alive;
|
||||
|
||||
@ -5978,7 +5981,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
*/
|
||||
|
||||
if (unlikely(msg->err_pos >= 0))
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, s->fe);
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, msg->msg_state, sess->fe);
|
||||
|
||||
/*
|
||||
* 1: get the status code
|
||||
@ -6072,7 +6075,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
s->logs.logwait &= ~LW_RESP;
|
||||
if (unlikely((s->logs.logwait & LW_RSPHDR) && txn->rsp.cap))
|
||||
capture_headers(rep->buf->p, &txn->hdr_idx,
|
||||
txn->rsp.cap, s->fe->rsp_cap);
|
||||
txn->rsp.cap, sess->fe->rsp_cap);
|
||||
|
||||
/* 4: determine the transfer-length.
|
||||
* According to RFC2616 #4.4, amended by the HTTPbis working group,
|
||||
@ -6171,7 +6174,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
msg->body_len = msg->chunk_len = cl;
|
||||
}
|
||||
|
||||
if (s->fe->comp || s->be->comp)
|
||||
if (sess->fe->comp || s->be->comp)
|
||||
select_compression_response_header(s, rep->buf);
|
||||
|
||||
skip_content_length:
|
||||
@ -6207,13 +6210,13 @@ skip_content_length:
|
||||
}
|
||||
else if ((txn->status >= 200) && !(txn->flags & TX_HDR_CONN_PRS) &&
|
||||
((txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN ||
|
||||
((s->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
|
||||
((sess->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
|
||||
(s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL))) {
|
||||
int to_del = 0;
|
||||
|
||||
/* this situation happens when combining pretend-keepalive with httpclose. */
|
||||
if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL &&
|
||||
((s->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
|
||||
((sess->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
|
||||
(s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL))
|
||||
txn->flags = (txn->flags & ~TX_CON_WANT_MSK) | TX_CON_WANT_CLO;
|
||||
|
||||
@ -6327,8 +6330,8 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
|
||||
* pointer and the ->fe rule list. If it doesn't match, I initialize
|
||||
* the loop with the ->be.
|
||||
*/
|
||||
if (s->current_rule_list == &s->fe->http_res_rules)
|
||||
cur_proxy = s->fe;
|
||||
if (s->current_rule_list == &sess->fe->http_res_rules)
|
||||
cur_proxy = sess->fe;
|
||||
else
|
||||
cur_proxy = s->be;
|
||||
while (1) {
|
||||
@ -6374,7 +6377,7 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
|
||||
objt_server(s->target)->counters.failed_secu++;
|
||||
|
||||
s->be->be_counters.denied_resp++;
|
||||
s->fe->fe_counters.denied_resp++;
|
||||
sess->fe->fe_counters.denied_resp++;
|
||||
if (sess->listener->counters)
|
||||
sess->listener->counters->denied_resp++;
|
||||
|
||||
@ -6398,9 +6401,9 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
|
||||
}
|
||||
|
||||
/* check whether we're already working on the frontend */
|
||||
if (cur_proxy == s->fe)
|
||||
if (cur_proxy == sess->fe)
|
||||
break;
|
||||
cur_proxy = s->fe;
|
||||
cur_proxy = sess->fe;
|
||||
}
|
||||
|
||||
/* After this point, this anayzer can't return yield, so we can
|
||||
@ -6419,7 +6422,7 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
|
||||
/*
|
||||
* Now check for a server cookie.
|
||||
*/
|
||||
if (s->be->cookie_name || s->be->appsession_name || s->fe->capture_name ||
|
||||
if (s->be->cookie_name || s->be->appsession_name || sess->fe->capture_name ||
|
||||
(s->be->options & PR_O_CHK_CACHE))
|
||||
manage_server_side_cookies(s, rep);
|
||||
|
||||
@ -6525,7 +6528,7 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
|
||||
objt_server(s->target)->counters.failed_secu++;
|
||||
|
||||
s->be->be_counters.denied_resp++;
|
||||
s->fe->fe_counters.denied_resp++;
|
||||
sess->fe->fe_counters.denied_resp++;
|
||||
if (sess->listener->counters)
|
||||
sess->listener->counters->denied_resp++;
|
||||
|
||||
@ -6548,7 +6551,7 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
|
||||
*/
|
||||
if ((txn->status != 101) && !(txn->flags & TX_HDR_CONN_UPG) &&
|
||||
(((txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN) ||
|
||||
((s->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
|
||||
((sess->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
|
||||
(s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL))) {
|
||||
unsigned int want_flags = 0;
|
||||
|
||||
@ -6581,7 +6584,7 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
|
||||
* bytes from the server, then this is the right moment. We have
|
||||
* to temporarily assign bytes_out to log what we currently have.
|
||||
*/
|
||||
if (!LIST_ISEMPTY(&s->fe->logformat) && !(s->logs.logwait & LW_BYTES)) {
|
||||
if (!LIST_ISEMPTY(&sess->fe->logformat) && !(s->logs.logwait & LW_BYTES)) {
|
||||
s->logs.t_close = s->logs.t_data; /* to get a valid end date */
|
||||
s->logs.bytes_out = txn->rsp.eoh;
|
||||
s->do_log(s);
|
||||
@ -6621,6 +6624,7 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
|
||||
*/
|
||||
int http_response_forward_body(struct stream *s, struct channel *res, int an_bit)
|
||||
{
|
||||
struct session *sess = s->sess;
|
||||
struct http_txn *txn = &s->txn;
|
||||
struct http_msg *msg = &s->txn.rsp;
|
||||
static struct buffer *tmpbuf = &buf_empty;
|
||||
@ -6734,7 +6738,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
|
||||
goto missing_data;
|
||||
else if (ret < 0) {
|
||||
if (msg->err_pos >= 0)
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, HTTP_MSG_CHUNK_CRLF, s->fe);
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, HTTP_MSG_CHUNK_CRLF, sess->fe);
|
||||
goto return_bad_res;
|
||||
}
|
||||
/* we're in MSG_CHUNK_SIZE now, fall through */
|
||||
@ -6750,7 +6754,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
|
||||
goto missing_data;
|
||||
else if (ret < 0) {
|
||||
if (msg->err_pos >= 0)
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, HTTP_MSG_CHUNK_SIZE, s->fe);
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, HTTP_MSG_CHUNK_SIZE, sess->fe);
|
||||
goto return_bad_res;
|
||||
}
|
||||
/* otherwise we're in HTTP_MSG_DATA or HTTP_MSG_TRAILERS state */
|
||||
@ -6768,7 +6772,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
|
||||
goto missing_data;
|
||||
else if (ret < 0) {
|
||||
if (msg->err_pos >= 0)
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, HTTP_MSG_TRAILERS, s->fe);
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, HTTP_MSG_TRAILERS, sess->fe);
|
||||
goto return_bad_res;
|
||||
}
|
||||
/* we're in HTTP_MSG_DONE now, fall through */
|
||||
@ -6805,7 +6809,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
|
||||
goto aborted_xfer;
|
||||
}
|
||||
if (msg->err_pos >= 0)
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, ret, s->fe);
|
||||
http_capture_bad_message(&s->be->invalid_rep, s, msg, ret, sess->fe);
|
||||
goto return_bad_res;
|
||||
}
|
||||
return 1;
|
||||
@ -6917,7 +6921,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
|
||||
res->analysers = 0;
|
||||
s->req.analysers = 0; /* we're in data phase, we want to abort both directions */
|
||||
|
||||
s->fe->fe_counters.cli_aborts++;
|
||||
sess->fe->fe_counters.cli_aborts++;
|
||||
s->be->be_counters.cli_aborts++;
|
||||
if (objt_server(s->target))
|
||||
objt_server(s->target)->counters.cli_aborts++;
|
||||
@ -6976,7 +6980,7 @@ int apply_filter_to_req_headers(struct stream *s, struct channel *req, struct hd
|
||||
* FIXME: should we return an HTTP/500 here so that
|
||||
* the admin knows there's a problem ?
|
||||
*/
|
||||
if (s->be != s->fe)
|
||||
if (s->be != strm_sess(s)->fe)
|
||||
break;
|
||||
|
||||
/* Swithing Proxy */
|
||||
@ -7077,7 +7081,7 @@ int apply_filter_to_req_line(struct stream *s, struct channel *req, struct hdr_e
|
||||
* FIXME: should we return an HTTP/500 here so that
|
||||
* the admin knows there's a problem ?
|
||||
*/
|
||||
if (s->be != s->fe)
|
||||
if (s->be != strm_sess(s)->fe)
|
||||
break;
|
||||
|
||||
/* Swithing Proxy */
|
||||
@ -7351,6 +7355,7 @@ int del_hdr_value(struct buffer *buf, char **from, char *next)
|
||||
void manage_client_side_cookies(struct stream *s, struct channel *req)
|
||||
{
|
||||
struct http_txn *txn = &s->txn;
|
||||
struct session *sess = s->sess;
|
||||
int preserve_hdr;
|
||||
int cur_idx, old_idx;
|
||||
char *hdr_beg, *hdr_end, *hdr_next, *del_from;
|
||||
@ -7534,16 +7539,16 @@ void manage_client_side_cookies(struct stream *s, struct channel *req)
|
||||
* can only capture one. Also as an optimisation, we ignore
|
||||
* cookies shorter than the declared name.
|
||||
*/
|
||||
if (s->fe->capture_name != NULL && txn->cli_cookie == NULL &&
|
||||
(val_end - att_beg >= s->fe->capture_namelen) &&
|
||||
memcmp(att_beg, s->fe->capture_name, s->fe->capture_namelen) == 0) {
|
||||
if (sess->fe->capture_name != NULL && txn->cli_cookie == NULL &&
|
||||
(val_end - att_beg >= sess->fe->capture_namelen) &&
|
||||
memcmp(att_beg, sess->fe->capture_name, sess->fe->capture_namelen) == 0) {
|
||||
int log_len = val_end - att_beg;
|
||||
|
||||
if ((txn->cli_cookie = pool_alloc2(pool2_capture)) == NULL) {
|
||||
Alert("HTTP logging : out of memory.\n");
|
||||
} else {
|
||||
if (log_len > s->fe->capture_len)
|
||||
log_len = s->fe->capture_len;
|
||||
if (log_len > sess->fe->capture_len)
|
||||
log_len = sess->fe->capture_len;
|
||||
memcpy(txn->cli_cookie, att_beg, log_len);
|
||||
txn->cli_cookie[log_len] = 0;
|
||||
}
|
||||
@ -8024,6 +8029,7 @@ int apply_filters_to_response(struct stream *s, struct channel *rtr, struct prox
|
||||
void manage_server_side_cookies(struct stream *s, struct channel *res)
|
||||
{
|
||||
struct http_txn *txn = &s->txn;
|
||||
struct session *sess = s->sess;
|
||||
struct server *srv;
|
||||
int is_cookie2;
|
||||
int cur_idx, old_idx, delta;
|
||||
@ -8074,7 +8080,7 @@ void manage_server_side_cookies(struct stream *s, struct channel *res)
|
||||
*/
|
||||
if (s->be->cookie_name == NULL &&
|
||||
s->be->appsession_name == NULL &&
|
||||
s->fe->capture_name == NULL)
|
||||
sess->fe->capture_name == NULL)
|
||||
return;
|
||||
|
||||
/* OK so now we know we have to process this response cookie.
|
||||
@ -8208,17 +8214,17 @@ void manage_server_side_cookies(struct stream *s, struct channel *res)
|
||||
* can only capture one. Also as an optimisation, we ignore
|
||||
* cookies shorter than the declared name.
|
||||
*/
|
||||
if (s->fe->capture_name != NULL &&
|
||||
if (sess->fe->capture_name != NULL &&
|
||||
txn->srv_cookie == NULL &&
|
||||
(val_end - att_beg >= s->fe->capture_namelen) &&
|
||||
memcmp(att_beg, s->fe->capture_name, s->fe->capture_namelen) == 0) {
|
||||
(val_end - att_beg >= sess->fe->capture_namelen) &&
|
||||
memcmp(att_beg, sess->fe->capture_name, sess->fe->capture_namelen) == 0) {
|
||||
int log_len = val_end - att_beg;
|
||||
if ((txn->srv_cookie = pool_alloc2(pool2_capture)) == NULL) {
|
||||
Alert("HTTP logging : out of memory.\n");
|
||||
}
|
||||
else {
|
||||
if (log_len > s->fe->capture_len)
|
||||
log_len = s->fe->capture_len;
|
||||
if (log_len > sess->fe->capture_len)
|
||||
log_len = sess->fe->capture_len;
|
||||
memcpy(txn->srv_cookie, att_beg, log_len);
|
||||
txn->srv_cookie[log_len] = 0;
|
||||
}
|
||||
@ -8783,7 +8789,7 @@ void debug_hdr(const char *dir, struct stream *s, const char *start, const char
|
||||
void http_init_txn(struct stream *s)
|
||||
{
|
||||
struct http_txn *txn = &s->txn;
|
||||
struct proxy *fe = s->fe;
|
||||
struct proxy *fe = strm_sess(s)->fe;
|
||||
|
||||
txn->flags = 0;
|
||||
txn->status = -1;
|
||||
@ -8826,6 +8832,7 @@ void http_init_txn(struct stream *s)
|
||||
void http_end_txn(struct stream *s)
|
||||
{
|
||||
struct http_txn *txn = &s->txn;
|
||||
struct proxy *fe = strm_sess(s)->fe;
|
||||
|
||||
/* release any possible compression context */
|
||||
if (s->flags & SF_COMP_READY)
|
||||
@ -8848,16 +8855,16 @@ void http_end_txn(struct stream *s)
|
||||
|
||||
if (txn->req.cap) {
|
||||
struct cap_hdr *h;
|
||||
for (h = s->fe->req_cap; h; h = h->next)
|
||||
for (h = fe->req_cap; h; h = h->next)
|
||||
pool_free2(h->pool, txn->req.cap[h->index]);
|
||||
memset(txn->req.cap, 0, s->fe->nb_req_cap * sizeof(void *));
|
||||
memset(txn->req.cap, 0, fe->nb_req_cap * sizeof(void *));
|
||||
}
|
||||
|
||||
if (txn->rsp.cap) {
|
||||
struct cap_hdr *h;
|
||||
for (h = s->fe->rsp_cap; h; h = h->next)
|
||||
for (h = fe->rsp_cap; h; h = h->next)
|
||||
pool_free2(h->pool, txn->rsp.cap[h->index]);
|
||||
memset(txn->rsp.cap, 0, s->fe->nb_rsp_cap * sizeof(void *));
|
||||
memset(txn->rsp.cap, 0, fe->nb_rsp_cap * sizeof(void *));
|
||||
}
|
||||
|
||||
}
|
||||
@ -8873,8 +8880,8 @@ void http_reset_txn(struct stream *s)
|
||||
*/
|
||||
s->current_rule_list = NULL;
|
||||
|
||||
s->be = s->fe;
|
||||
s->logs.logwait = s->fe->to_log;
|
||||
s->be = strm_sess(s)->fe;
|
||||
s->logs.logwait = strm_sess(s)->fe->to_log;
|
||||
s->logs.level = 0;
|
||||
stream_del_srv_conn(s);
|
||||
s->target = NULL;
|
||||
@ -8897,11 +8904,11 @@ void http_reset_txn(struct stream *s)
|
||||
if (unlikely(s->res.buf->i))
|
||||
s->res.buf->i = 0;
|
||||
|
||||
s->req.rto = s->fe->timeout.client;
|
||||
s->req.rto = strm_sess(s)->fe->timeout.client;
|
||||
s->req.wto = TICK_ETERNITY;
|
||||
|
||||
s->res.rto = TICK_ETERNITY;
|
||||
s->res.wto = s->fe->timeout.client;
|
||||
s->res.wto = strm_sess(s)->fe->timeout.client;
|
||||
|
||||
s->req.rex = TICK_ETERNITY;
|
||||
s->req.wex = TICK_ETERNITY;
|
||||
@ -10818,7 +10825,7 @@ static int
|
||||
smp_fetch_capture_header_req(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
|
||||
const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
struct proxy *fe = l4->fe;
|
||||
struct proxy *fe = strm_sess(l4)->fe;
|
||||
struct http_txn *txn = l7;
|
||||
int idx;
|
||||
|
||||
@ -10845,7 +10852,7 @@ static int
|
||||
smp_fetch_capture_header_res(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
|
||||
const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
struct proxy *fe = l4->fe;
|
||||
struct proxy *fe = strm_sess(l4)->fe;
|
||||
struct http_txn *txn = l7;
|
||||
int idx;
|
||||
|
||||
|
@ -1154,7 +1154,7 @@ resume_execution:
|
||||
req->analysers = 0;
|
||||
|
||||
s->be->be_counters.denied_req++;
|
||||
s->fe->fe_counters.denied_req++;
|
||||
sess->fe->fe_counters.denied_req++;
|
||||
if (sess->listener->counters)
|
||||
sess->listener->counters->denied_req++;
|
||||
|
||||
@ -1183,7 +1183,7 @@ resume_execution:
|
||||
if (key && (ts = stktable_get_entry(t, key))) {
|
||||
stream_track_stkctr(&s->stkctr[tcp_trk_idx(rule->action)], t, ts);
|
||||
stkctr_set_flags(&s->stkctr[tcp_trk_idx(rule->action)], STKCTR_TRACK_CONTENT);
|
||||
if (s->fe != s->be)
|
||||
if (sess->fe != s->be)
|
||||
stkctr_set_flags(&s->stkctr[tcp_trk_idx(rule->action)], STKCTR_TRACK_BACKEND);
|
||||
}
|
||||
}
|
||||
@ -1316,7 +1316,7 @@ resume_execution:
|
||||
rep->analysers = 0;
|
||||
|
||||
s->be->be_counters.denied_resp++;
|
||||
s->fe->fe_counters.denied_resp++;
|
||||
sess->fe->fe_counters.denied_resp++;
|
||||
if (sess->listener->counters)
|
||||
sess->listener->counters->denied_resp++;
|
||||
|
||||
@ -1373,11 +1373,11 @@ int tcp_exec_req_rules(struct stream *s)
|
||||
if (!conn)
|
||||
return result;
|
||||
|
||||
list_for_each_entry(rule, &s->fe->tcp_req.l4_rules, list) {
|
||||
list_for_each_entry(rule, &sess->fe->tcp_req.l4_rules, list) {
|
||||
ret = ACL_TEST_PASS;
|
||||
|
||||
if (rule->cond) {
|
||||
ret = acl_exec_cond(rule->cond, s->fe, s, NULL, SMP_OPT_DIR_REQ|SMP_OPT_FINAL);
|
||||
ret = acl_exec_cond(rule->cond, sess->fe, s, NULL, SMP_OPT_DIR_REQ|SMP_OPT_FINAL);
|
||||
ret = acl_pass(ret);
|
||||
if (rule->cond->pol == ACL_COND_UNLESS)
|
||||
ret = !ret;
|
||||
@ -1386,7 +1386,7 @@ int tcp_exec_req_rules(struct stream *s)
|
||||
if (ret) {
|
||||
/* we have a matching rule. */
|
||||
if (rule->action == TCP_ACT_REJECT) {
|
||||
s->fe->fe_counters.denied_conn++;
|
||||
sess->fe->fe_counters.denied_conn++;
|
||||
if (sess->listener->counters)
|
||||
sess->listener->counters->denied_conn++;
|
||||
|
||||
@ -1418,7 +1418,7 @@ int tcp_exec_req_rules(struct stream *s)
|
||||
}
|
||||
else {
|
||||
/* Custom keywords. */
|
||||
rule->action_ptr(rule, s->fe, s);
|
||||
rule->action_ptr(rule, sess->fe, s);
|
||||
|
||||
/* otherwise it's an accept */
|
||||
break;
|
||||
|
@ -960,8 +960,8 @@ int stream_set_backend(struct stream *s, struct proxy *be)
|
||||
* have to re-adjust the desired keep-alive/close mode to accommodate
|
||||
* both the frontend's and the backend's modes.
|
||||
*/
|
||||
if (s->fe->mode == PR_MODE_HTTP && be->mode == PR_MODE_HTTP &&
|
||||
((s->fe->options & PR_O_HTTP_MODE) != (be->options & PR_O_HTTP_MODE)))
|
||||
if (strm_sess(s)->fe->mode == PR_MODE_HTTP && be->mode == PR_MODE_HTTP &&
|
||||
((strm_sess(s)->fe->options & PR_O_HTTP_MODE) != (be->options & PR_O_HTTP_MODE)))
|
||||
http_adjust_conn_mode(s, &s->txn, &s->txn.req);
|
||||
|
||||
/* If an LB algorithm needs to access some pre-parsed body contents,
|
||||
|
123
src/stream.c
123
src/stream.c
@ -122,7 +122,7 @@ int stream_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
|
||||
goto out_free_stream;
|
||||
|
||||
s->sess->listener = l;
|
||||
s->fe = p;
|
||||
s->sess->fe = p;
|
||||
|
||||
s->si[0].flags = SI_FL_NONE;
|
||||
s->si[1].flags = SI_FL_ISBACK;
|
||||
@ -290,9 +290,9 @@ static void prepare_mini_sess_log_prefix(struct stream *s)
|
||||
end = date2str_log(trash.str + trash.len, &tm, &(s->logs.accept_date), trash.size - trash.len);
|
||||
trash.len = end - trash.str;
|
||||
if (sess->listener->name)
|
||||
chunk_appendf(&trash, "] %s/%s", s->fe->id, sess->listener->name);
|
||||
chunk_appendf(&trash, "] %s/%s", sess->fe->id, sess->listener->name);
|
||||
else
|
||||
chunk_appendf(&trash, "] %s/%d", s->fe->id, sess->listener->luid);
|
||||
chunk_appendf(&trash, "] %s/%d", sess->fe->id, sess->listener->luid);
|
||||
}
|
||||
|
||||
/* This function kills an existing embryonic stream. It stops the connection's
|
||||
@ -308,10 +308,10 @@ static void kill_mini_session(struct stream *s)
|
||||
unsigned int log = s->logs.logwait;
|
||||
const char *err_msg;
|
||||
|
||||
if (s->fe->options2 & PR_O2_LOGERRORS)
|
||||
if (sess->fe->options2 & PR_O2_LOGERRORS)
|
||||
level = LOG_ERR;
|
||||
|
||||
if (log && (s->fe->options & PR_O_NULLNOLOG)) {
|
||||
if (log && (sess->fe->options & PR_O_NULLNOLOG)) {
|
||||
/* with "option dontlognull", we don't log connections with no transfer */
|
||||
if (!conn->err_code ||
|
||||
conn->err_code == CO_ER_PRX_EMPTY || conn->err_code == CO_ER_PRX_ABORT ||
|
||||
@ -330,9 +330,9 @@ static void kill_mini_session(struct stream *s)
|
||||
prepare_mini_sess_log_prefix(s);
|
||||
err_msg = conn_err_code_str(conn);
|
||||
if (err_msg)
|
||||
send_log(s->fe, level, "%s: %s\n", trash.str, err_msg);
|
||||
send_log(sess->fe, level, "%s: %s\n", trash.str, err_msg);
|
||||
else
|
||||
send_log(s->fe, level, "%s: unknown connection error (code=%d flags=%08x)\n",
|
||||
send_log(sess->fe, level, "%s: unknown connection error (code=%d flags=%08x)\n",
|
||||
trash.str, conn->err_code, conn->flags);
|
||||
}
|
||||
|
||||
@ -340,7 +340,7 @@ static void kill_mini_session(struct stream *s)
|
||||
conn_force_close(conn);
|
||||
conn_free(conn);
|
||||
|
||||
s->fe->feconn--;
|
||||
sess->fe->feconn--;
|
||||
stream_store_counters(s);
|
||||
|
||||
if (!(sess->listener->options & LI_O_UNLIMITED))
|
||||
@ -354,9 +354,9 @@ static void kill_mini_session(struct stream *s)
|
||||
if (!LIST_ISEMPTY(&global_listener_queue))
|
||||
dequeue_all_listeners(&global_listener_queue);
|
||||
|
||||
if (!LIST_ISEMPTY(&s->fe->listener_queue) &&
|
||||
(!s->fe->fe_sps_lim || freq_ctr_remain(&s->fe->fe_sess_per_sec, s->fe->fe_sps_lim, 0) > 0))
|
||||
dequeue_all_listeners(&s->fe->listener_queue);
|
||||
if (!LIST_ISEMPTY(&sess->fe->listener_queue) &&
|
||||
(!sess->fe->fe_sps_lim || freq_ctr_remain(&sess->fe->fe_sess_per_sec, sess->fe->fe_sps_lim, 0) > 0))
|
||||
dequeue_all_listeners(&sess->fe->listener_queue);
|
||||
|
||||
task_delete(s->task);
|
||||
task_free(s->task);
|
||||
@ -423,7 +423,7 @@ int stream_complete(struct stream *s)
|
||||
{
|
||||
struct session *sess = s->sess;
|
||||
struct listener *l = sess->listener;
|
||||
struct proxy *p = s->fe;
|
||||
struct proxy *p = sess->fe;
|
||||
struct http_txn *txn;
|
||||
struct task *t = s->task;
|
||||
struct connection *conn = __objt_conn(s->target);
|
||||
@ -448,7 +448,7 @@ int stream_complete(struct stream *s)
|
||||
* This changes later when switching rules are executed or
|
||||
* when the default backend is assigned.
|
||||
*/
|
||||
s->be = s->fe;
|
||||
s->be = sess->fe;
|
||||
s->comp_algo = NULL;
|
||||
s->req.buf = s->res.buf = NULL;
|
||||
|
||||
@ -482,7 +482,7 @@ int stream_complete(struct stream *s)
|
||||
*/
|
||||
si_attach_conn(&s->si[0], conn);
|
||||
|
||||
if (likely(s->fe->options2 & PR_O2_INDEPSTR))
|
||||
if (likely(sess->fe->options2 & PR_O2_INDEPSTR))
|
||||
s->si[0].flags |= SI_FL_INDEP_STR;
|
||||
|
||||
/* pre-initialize the other side's stream interface to an INIT state. The
|
||||
@ -491,7 +491,7 @@ int stream_complete(struct stream *s)
|
||||
si_reset(&s->si[1]);
|
||||
si_detach(&s->si[1]);
|
||||
|
||||
if (likely(s->fe->options2 & PR_O2_INDEPSTR))
|
||||
if (likely(sess->fe->options2 & PR_O2_INDEPSTR))
|
||||
s->si[1].flags |= SI_FL_INDEP_STR;
|
||||
|
||||
stream_init_srv_conn(s);
|
||||
@ -517,7 +517,7 @@ int stream_complete(struct stream *s)
|
||||
s->res.flags |= CF_ISRESP;
|
||||
s->res.analysers = 0;
|
||||
|
||||
if (s->fe->options2 & PR_O2_NODELAY) {
|
||||
if (sess->fe->options2 & PR_O2_NODELAY) {
|
||||
s->req.flags |= CF_NEVER_WAIT;
|
||||
s->res.flags |= CF_NEVER_WAIT;
|
||||
}
|
||||
@ -591,7 +591,7 @@ int stream_complete(struct stream *s)
|
||||
static void stream_free(struct stream *s)
|
||||
{
|
||||
struct http_txn *txn = &s->txn;
|
||||
struct proxy *fe = s->fe;
|
||||
struct proxy *fe = strm_sess(s)->fe;
|
||||
struct bref *bref, *back;
|
||||
struct connection *cli_conn = objt_conn(s->si[0].end);
|
||||
int i;
|
||||
@ -815,7 +815,7 @@ void stream_process_counters(struct stream *s)
|
||||
bytes = s->req.total - s->logs.bytes_in;
|
||||
s->logs.bytes_in = s->req.total;
|
||||
if (bytes) {
|
||||
s->fe->fe_counters.bytes_in += bytes;
|
||||
sess->fe->fe_counters.bytes_in += bytes;
|
||||
|
||||
s->be->be_counters.bytes_in += bytes;
|
||||
|
||||
@ -847,7 +847,7 @@ void stream_process_counters(struct stream *s)
|
||||
bytes = s->res.total - s->logs.bytes_out;
|
||||
s->logs.bytes_out = s->res.total;
|
||||
if (bytes) {
|
||||
s->fe->fe_counters.bytes_out += bytes;
|
||||
sess->fe->fe_counters.bytes_out += bytes;
|
||||
|
||||
s->be->be_counters.bytes_out += bytes;
|
||||
|
||||
@ -1071,7 +1071,7 @@ static void sess_establish(struct stream *s)
|
||||
if (s->be->mode == PR_MODE_TCP) { /* let's allow immediate data connection in this case */
|
||||
/* if the user wants to log as soon as possible, without counting
|
||||
* bytes from the server, then this is the right moment. */
|
||||
if (!LIST_ISEMPTY(&s->fe->logformat) && !(s->logs.logwait & LW_BYTES)) {
|
||||
if (!LIST_ISEMPTY(&strm_sess(s)->fe->logformat) && !(s->logs.logwait & LW_BYTES)) {
|
||||
s->logs.t_close = s->logs.t_connect; /* to get a valid end date */
|
||||
s->do_log(s);
|
||||
}
|
||||
@ -1081,7 +1081,7 @@ static void sess_establish(struct stream *s)
|
||||
rep->flags |= CF_READ_DONTWAIT; /* a single read is enough to get response headers */
|
||||
}
|
||||
|
||||
rep->analysers |= s->fe->fe_rsp_ana | s->be->be_rsp_ana;
|
||||
rep->analysers |= strm_sess(s)->fe->fe_rsp_ana | s->be->be_rsp_ana;
|
||||
rep->flags |= CF_READ_ATTACHED; /* producer is now attached */
|
||||
if (req->flags & CF_WAKE_CONNECT) {
|
||||
req->flags |= CF_WAKE_ONCE;
|
||||
@ -1274,7 +1274,7 @@ static void sess_set_term_flags(struct stream *s)
|
||||
if (!(s->flags & SF_FINST_MASK)) {
|
||||
if (s->si[1].state < SI_ST_REQ) {
|
||||
|
||||
s->fe->fe_counters.failed_req++;
|
||||
strm_sess(s)->fe->fe_counters.failed_req++;
|
||||
if (strm_sess(s)->listener->counters)
|
||||
strm_sess(s)->listener->counters->failed_req++;
|
||||
|
||||
@ -1379,6 +1379,7 @@ static void sess_prepare_conn_req(struct stream *s)
|
||||
static int process_switching_rules(struct stream *s, struct channel *req, int an_bit)
|
||||
{
|
||||
struct persist_rule *prst_rule;
|
||||
struct proxy *fe = strm_sess(s)->fe;
|
||||
|
||||
req->analysers &= ~an_bit;
|
||||
req->analyse_exp = TICK_ETERNITY;
|
||||
@ -1396,11 +1397,11 @@ static int process_switching_rules(struct stream *s, struct channel *req, int an
|
||||
if (!(s->flags & SF_BE_ASSIGNED)) {
|
||||
struct switching_rule *rule;
|
||||
|
||||
list_for_each_entry(rule, &s->fe->switching_rules, list) {
|
||||
list_for_each_entry(rule, &fe->switching_rules, list) {
|
||||
int ret = 1;
|
||||
|
||||
if (rule->cond) {
|
||||
ret = acl_exec_cond(rule->cond, s->fe, s, &s->txn, SMP_OPT_DIR_REQ|SMP_OPT_FINAL);
|
||||
ret = acl_exec_cond(rule->cond, fe, s, &s->txn, SMP_OPT_DIR_REQ|SMP_OPT_FINAL);
|
||||
ret = acl_pass(ret);
|
||||
if (rule->cond->pol == ACL_COND_UNLESS)
|
||||
ret = !ret;
|
||||
@ -1436,12 +1437,12 @@ static int process_switching_rules(struct stream *s, struct channel *req, int an
|
||||
* backend if any.
|
||||
*/
|
||||
if (!(s->flags & SF_BE_ASSIGNED))
|
||||
if (!stream_set_backend(s, s->fe->defbe.be ? s->fe->defbe.be : s->be))
|
||||
if (!stream_set_backend(s, fe->defbe.be ? fe->defbe.be : s->be))
|
||||
goto sw_failed;
|
||||
}
|
||||
|
||||
/* we don't want to run the TCP or HTTP filters again if the backend has not changed */
|
||||
if (s->fe == s->be) {
|
||||
if (fe == s->be) {
|
||||
s->req.analysers &= ~AN_REQ_INSPECT_BE;
|
||||
s->req.analysers &= ~AN_REQ_HTTP_PROCESS_BE;
|
||||
}
|
||||
@ -1867,7 +1868,7 @@ struct task *process_stream(struct task *t)
|
||||
stream_int_report_error(si_f);
|
||||
if (!(req->analysers) && !(res->analysers)) {
|
||||
s->be->be_counters.cli_aborts++;
|
||||
s->fe->fe_counters.cli_aborts++;
|
||||
sess->fe->fe_counters.cli_aborts++;
|
||||
if (srv)
|
||||
srv->counters.cli_aborts++;
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
@ -1888,7 +1889,7 @@ struct task *process_stream(struct task *t)
|
||||
srv->counters.failed_resp++;
|
||||
if (!(req->analysers) && !(res->analysers)) {
|
||||
s->be->be_counters.srv_aborts++;
|
||||
s->fe->fe_counters.srv_aborts++;
|
||||
sess->fe->fe_counters.srv_aborts++;
|
||||
if (srv)
|
||||
srv->counters.srv_aborts++;
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
@ -2036,7 +2037,7 @@ struct task *process_stream(struct task *t)
|
||||
}
|
||||
|
||||
if (ana_list & AN_REQ_HTTP_PROCESS_FE) {
|
||||
if (!http_process_req_common(s, req, AN_REQ_HTTP_PROCESS_FE, s->fe))
|
||||
if (!http_process_req_common(s, req, AN_REQ_HTTP_PROCESS_FE, sess->fe))
|
||||
break;
|
||||
UPDATE_ANALYSERS(req->analysers, ana_list, ana_back, AN_REQ_HTTP_PROCESS_FE);
|
||||
}
|
||||
@ -2235,28 +2236,28 @@ struct task *process_stream(struct task *t)
|
||||
req->analysers = 0;
|
||||
if (req->flags & CF_READ_ERROR) {
|
||||
s->be->be_counters.cli_aborts++;
|
||||
s->fe->fe_counters.cli_aborts++;
|
||||
sess->fe->fe_counters.cli_aborts++;
|
||||
if (srv)
|
||||
srv->counters.cli_aborts++;
|
||||
s->flags |= SF_ERR_CLICL;
|
||||
}
|
||||
else if (req->flags & CF_READ_TIMEOUT) {
|
||||
s->be->be_counters.cli_aborts++;
|
||||
s->fe->fe_counters.cli_aborts++;
|
||||
sess->fe->fe_counters.cli_aborts++;
|
||||
if (srv)
|
||||
srv->counters.cli_aborts++;
|
||||
s->flags |= SF_ERR_CLITO;
|
||||
}
|
||||
else if (req->flags & CF_WRITE_ERROR) {
|
||||
s->be->be_counters.srv_aborts++;
|
||||
s->fe->fe_counters.srv_aborts++;
|
||||
sess->fe->fe_counters.srv_aborts++;
|
||||
if (srv)
|
||||
srv->counters.srv_aborts++;
|
||||
s->flags |= SF_ERR_SRVCL;
|
||||
}
|
||||
else {
|
||||
s->be->be_counters.srv_aborts++;
|
||||
s->fe->fe_counters.srv_aborts++;
|
||||
sess->fe->fe_counters.srv_aborts++;
|
||||
if (srv)
|
||||
srv->counters.srv_aborts++;
|
||||
s->flags |= SF_ERR_SRVTO;
|
||||
@ -2268,28 +2269,28 @@ struct task *process_stream(struct task *t)
|
||||
res->analysers = 0;
|
||||
if (res->flags & CF_READ_ERROR) {
|
||||
s->be->be_counters.srv_aborts++;
|
||||
s->fe->fe_counters.srv_aborts++;
|
||||
sess->fe->fe_counters.srv_aborts++;
|
||||
if (srv)
|
||||
srv->counters.srv_aborts++;
|
||||
s->flags |= SF_ERR_SRVCL;
|
||||
}
|
||||
else if (res->flags & CF_READ_TIMEOUT) {
|
||||
s->be->be_counters.srv_aborts++;
|
||||
s->fe->fe_counters.srv_aborts++;
|
||||
sess->fe->fe_counters.srv_aborts++;
|
||||
if (srv)
|
||||
srv->counters.srv_aborts++;
|
||||
s->flags |= SF_ERR_SRVTO;
|
||||
}
|
||||
else if (res->flags & CF_WRITE_ERROR) {
|
||||
s->be->be_counters.cli_aborts++;
|
||||
s->fe->fe_counters.cli_aborts++;
|
||||
sess->fe->fe_counters.cli_aborts++;
|
||||
if (srv)
|
||||
srv->counters.cli_aborts++;
|
||||
s->flags |= SF_ERR_CLICL;
|
||||
}
|
||||
else {
|
||||
s->be->be_counters.cli_aborts++;
|
||||
s->fe->fe_counters.cli_aborts++;
|
||||
sess->fe->fe_counters.cli_aborts++;
|
||||
if (srv)
|
||||
srv->counters.cli_aborts++;
|
||||
s->flags |= SF_ERR_CLITO;
|
||||
@ -2336,8 +2337,8 @@ struct task *process_stream(struct task *t)
|
||||
(objt_conn(si_f->end) && __objt_conn(si_f->end)->xprt && __objt_conn(si_f->end)->xprt->rcv_pipe) &&
|
||||
(objt_conn(si_b->end) && __objt_conn(si_b->end)->xprt && __objt_conn(si_b->end)->xprt->snd_pipe) &&
|
||||
(pipes_used < global.maxpipes) &&
|
||||
(((s->fe->options2|s->be->options2) & PR_O2_SPLIC_REQ) ||
|
||||
(((s->fe->options2|s->be->options2) & PR_O2_SPLIC_AUT) &&
|
||||
(((sess->fe->options2|s->be->options2) & PR_O2_SPLIC_REQ) ||
|
||||
(((sess->fe->options2|s->be->options2) & PR_O2_SPLIC_AUT) &&
|
||||
(req->flags & CF_STREAMER_FAST)))) {
|
||||
req->flags |= CF_KERN_SPLICING;
|
||||
}
|
||||
@ -2357,8 +2358,8 @@ struct task *process_stream(struct task *t)
|
||||
if (unlikely((req->flags & (CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CLOSE|CF_SHUTR)) ==
|
||||
(CF_AUTO_CLOSE|CF_SHUTR))) {
|
||||
channel_shutw_now(req);
|
||||
if (tick_isset(s->fe->timeout.clientfin)) {
|
||||
res->wto = s->fe->timeout.clientfin;
|
||||
if (tick_isset(sess->fe->timeout.clientfin)) {
|
||||
res->wto = sess->fe->timeout.clientfin;
|
||||
res->wex = tick_add(now_ms, res->wto);
|
||||
}
|
||||
}
|
||||
@ -2385,8 +2386,8 @@ struct task *process_stream(struct task *t)
|
||||
if (si_f->flags & SI_FL_NOHALF)
|
||||
si_f->flags |= SI_FL_NOLINGER;
|
||||
si_shutr(si_f);
|
||||
if (tick_isset(s->fe->timeout.clientfin)) {
|
||||
res->wto = s->fe->timeout.clientfin;
|
||||
if (tick_isset(sess->fe->timeout.clientfin)) {
|
||||
res->wto = sess->fe->timeout.clientfin;
|
||||
res->wex = tick_add(now_ms, res->wto);
|
||||
}
|
||||
}
|
||||
@ -2491,14 +2492,14 @@ struct task *process_stream(struct task *t)
|
||||
req->rto = req->wto = res->rto = res->wto =
|
||||
s->be->timeout.tunnel;
|
||||
|
||||
if ((req->flags & CF_SHUTR) && tick_isset(s->fe->timeout.clientfin))
|
||||
res->wto = s->fe->timeout.clientfin;
|
||||
if ((req->flags & CF_SHUTR) && tick_isset(sess->fe->timeout.clientfin))
|
||||
res->wto = sess->fe->timeout.clientfin;
|
||||
if ((req->flags & CF_SHUTW) && tick_isset(s->be->timeout.serverfin))
|
||||
res->rto = s->be->timeout.serverfin;
|
||||
if ((res->flags & CF_SHUTR) && tick_isset(s->be->timeout.serverfin))
|
||||
req->wto = s->be->timeout.serverfin;
|
||||
if ((res->flags & CF_SHUTW) && tick_isset(s->fe->timeout.clientfin))
|
||||
req->rto = s->fe->timeout.clientfin;
|
||||
if ((res->flags & CF_SHUTW) && tick_isset(sess->fe->timeout.clientfin))
|
||||
req->rto = sess->fe->timeout.clientfin;
|
||||
|
||||
req->rex = tick_add(now_ms, req->rto);
|
||||
req->wex = tick_add(now_ms, req->wto);
|
||||
@ -2514,8 +2515,8 @@ struct task *process_stream(struct task *t)
|
||||
(objt_conn(si_f->end) && __objt_conn(si_f->end)->xprt && __objt_conn(si_f->end)->xprt->snd_pipe) &&
|
||||
(objt_conn(si_b->end) && __objt_conn(si_b->end)->xprt && __objt_conn(si_b->end)->xprt->rcv_pipe) &&
|
||||
(pipes_used < global.maxpipes) &&
|
||||
(((s->fe->options2|s->be->options2) & PR_O2_SPLIC_RTR) ||
|
||||
(((s->fe->options2|s->be->options2) & PR_O2_SPLIC_AUT) &&
|
||||
(((sess->fe->options2|s->be->options2) & PR_O2_SPLIC_RTR) ||
|
||||
(((sess->fe->options2|s->be->options2) & PR_O2_SPLIC_AUT) &&
|
||||
(res->flags & CF_STREAMER_FAST)))) {
|
||||
res->flags |= CF_KERN_SPLICING;
|
||||
}
|
||||
@ -2545,8 +2546,8 @@ struct task *process_stream(struct task *t)
|
||||
if (unlikely((res->flags & (CF_SHUTW|CF_SHUTW_NOW)) == CF_SHUTW_NOW &&
|
||||
channel_is_empty(res))) {
|
||||
si_shutw(si_f);
|
||||
if (tick_isset(s->fe->timeout.clientfin)) {
|
||||
req->rto = s->fe->timeout.clientfin;
|
||||
if (tick_isset(sess->fe->timeout.clientfin)) {
|
||||
req->rto = sess->fe->timeout.clientfin;
|
||||
req->rex = tick_add(now_ms, req->rto);
|
||||
}
|
||||
}
|
||||
@ -2610,7 +2611,7 @@ struct task *process_stream(struct task *t)
|
||||
if (likely((si_f->state != SI_ST_CLO) ||
|
||||
(si_b->state > SI_ST_INI && si_b->state < SI_ST_CLO))) {
|
||||
|
||||
if ((s->fe->options & PR_O_CONTSTATS) && (s->flags & SF_BE_ASSIGNED))
|
||||
if ((sess->fe->options & PR_O_CONTSTATS) && (s->flags & SF_BE_ASSIGNED))
|
||||
stream_process_counters(s);
|
||||
|
||||
if (si_f->state == SI_ST_EST && obj_type(si_f->end) != OBJ_TYPE_APPCTX)
|
||||
@ -2686,7 +2687,7 @@ struct task *process_stream(struct task *t)
|
||||
return t; /* nothing more to do */
|
||||
}
|
||||
|
||||
s->fe->feconn--;
|
||||
sess->fe->feconn--;
|
||||
if (s->flags & SF_BE_ASSIGNED)
|
||||
s->be->beconn--;
|
||||
jobs--;
|
||||
@ -2701,9 +2702,9 @@ struct task *process_stream(struct task *t)
|
||||
if (!LIST_ISEMPTY(&global_listener_queue))
|
||||
dequeue_all_listeners(&global_listener_queue);
|
||||
|
||||
if (!LIST_ISEMPTY(&s->fe->listener_queue) &&
|
||||
(!s->fe->fe_sps_lim || freq_ctr_remain(&s->fe->fe_sess_per_sec, s->fe->fe_sps_lim, 0) > 0))
|
||||
dequeue_all_listeners(&s->fe->listener_queue);
|
||||
if (!LIST_ISEMPTY(&sess->fe->listener_queue) &&
|
||||
(!sess->fe->fe_sps_lim || freq_ctr_remain(&sess->fe->fe_sess_per_sec, sess->fe->fe_sps_lim, 0) > 0))
|
||||
dequeue_all_listeners(&sess->fe->listener_queue);
|
||||
}
|
||||
|
||||
if (unlikely((global.mode & MODE_DEBUG) &&
|
||||
@ -2725,10 +2726,10 @@ struct task *process_stream(struct task *t)
|
||||
if (n < 1 || n > 5)
|
||||
n = 0;
|
||||
|
||||
if (s->fe->mode == PR_MODE_HTTP) {
|
||||
s->fe->fe_counters.p.http.rsp[n]++;
|
||||
if (sess->fe->mode == PR_MODE_HTTP) {
|
||||
sess->fe->fe_counters.p.http.rsp[n]++;
|
||||
if (s->comp_algo && (s->flags & SF_COMP_READY))
|
||||
s->fe->fe_counters.p.http.comp_rsp++;
|
||||
sess->fe->fe_counters.p.http.comp_rsp++;
|
||||
}
|
||||
if ((s->flags & SF_BE_ASSIGNED) &&
|
||||
(s->be->mode == PR_MODE_HTTP)) {
|
||||
@ -2740,9 +2741,9 @@ struct task *process_stream(struct task *t)
|
||||
}
|
||||
|
||||
/* let's do a final log if we need it */
|
||||
if (!LIST_ISEMPTY(&s->fe->logformat) && s->logs.logwait &&
|
||||
if (!LIST_ISEMPTY(&sess->fe->logformat) && s->logs.logwait &&
|
||||
!(s->flags & SF_MONITOR) &&
|
||||
(!(s->fe->options & PR_O_NULLNOLOG) || req->total)) {
|
||||
(!(sess->fe->options & PR_O_NULLNOLOG) || req->total)) {
|
||||
s->do_log(s);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user