From: Willy Tarreau Date: Sun, 18 Mar 2007 17:34:41 +0000 (+0100) Subject: [MINOR] move some flags from session.h to proto_http.h X-Git-Tag: v1.3.8~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d300596bbcbed0b6709ec27bf7af1b862f331ee;p=thirdparty%2Fhaproxy.git [MINOR] move some flags from session.h to proto_http.h Some session flags were clearly related to HTTP transactions. A new 'flags' field has been added to http_txn, and the associated flags moved to proto_http.h. --- diff --git a/include/proto/proto_http.h b/include/proto/proto_http.h index 297c5b9367..298d30d074 100644 --- a/include/proto/proto_http.h +++ b/include/proto/proto_http.h @@ -82,6 +82,15 @@ void check_response_for_cacheability(struct session *t, struct buffer *rtr); int stats_check_uri_auth(struct session *t, struct proxy *backend); void init_proto_http(); +/* used to clear the cookie flags when a transaction failed on the server + * designed by the cookie. We clear the CK_VALID bit and set the CK_DOWN. + */ +static inline void http_flush_cookie_flags(struct http_txn *txn) +{ + if ((txn->flags & TX_CK_MASK) == TX_CK_VALID) + txn->flags ^= (TX_CK_VALID | TX_CK_DOWN); +} + #endif /* _PROTO_PROTO_HTTP_H */ /* diff --git a/include/types/proto_http.h b/include/types/proto_http.h index 58a89ffceb..a6709aa4ec 100644 --- a/include/types/proto_http.h +++ b/include/types/proto_http.h @@ -53,6 +53,41 @@ #define SV_STSHUTW 5 #define SV_STCLOSE 6 +/* + * Transaction flags moved from session + */ + + +/* action flags */ +#define TX_CLDENY 0x00000001 /* a client header matches a deny regex */ +#define TX_CLALLOW 0x00000002 /* a client header matches an allow regex */ +#define TX_SVDENY 0x00000004 /* a server header matches a deny regex */ +#define TX_SVALLOW 0x00000008 /* a server header matches an allow regex */ +#define TX_CLTARPIT 0x00000010 /* the session is tarpitted (anti-dos) */ +/* unused: 0x00000020 */ + +/* transaction flags dedicated to cookies : bits values 0x40, 0x80 (0-3 shift 6) */ +#define TX_CK_NONE 0x00000000 /* this session had no cookie */ +#define TX_CK_INVALID 0x00000040 /* this session had a cookie which matches no server */ +#define TX_CK_DOWN 0x00000080 /* this session had cookie matching a down server */ +#define TX_CK_VALID 0x000000C0 /* this session had cookie matching a valid server */ +#define TX_CK_MASK 0x000000C0 /* mask to get this session's cookie flags */ +#define TX_CK_SHIFT 6 /* bit shift */ + +/* cookie information, bits values 0x100 to 0x800 (0-8 shift 8) */ +#define TX_SCK_NONE 0x00000000 /* no set-cookie seen for the server cookie */ +#define TX_SCK_DELETED 0x00000100 /* existing set-cookie deleted or changed */ +#define TX_SCK_INSERTED 0x00000200 /* new set-cookie inserted or changed existing one */ +#define TX_SCK_SEEN 0x00000400 /* set-cookie seen for the server cookie */ +#define TX_SCK_MASK 0x00000700 /* mask to get the set-cookie field */ +#define TX_SCK_ANY 0x00000800 /* at least one set-cookie seen (not to be counted) */ +#define TX_SCK_SHIFT 8 /* bit shift */ + +/* cacheability management, bits values 0x1000 to 0x3000 (0-3 shift 12) */ +#define TX_CACHEABLE 0x00001000 /* at least part of the response is cacheable */ +#define TX_CACHE_COOK 0x00002000 /* a cookie in the response is cacheable */ +#define TX_CACHE_SHIFT 12 /* bit shift */ + /* The HTTP parser is more complex than it looks like, because we have to * support multi-line headers and any number of spaces between the colon and @@ -204,6 +239,7 @@ struct http_txn { char *cli_cookie; /* cookie presented by the client, in capture mode */ char *srv_cookie; /* cookie presented by the server, in capture mode */ int status; /* HTTP status from the server, negative if from proxy */ + unsigned int flags; /* transaction flags */ }; diff --git a/include/types/session.h b/include/types/session.h index 99f8819b83..1011c9a023 100644 --- a/include/types/session.h +++ b/include/types/session.h @@ -41,19 +41,13 @@ /* various session flags, bits values 0x01 to 0x20 (shift 0) */ #define SN_DIRECT 0x00000001 /* connection made on the server matching the client cookie */ -#define SN_CLDENY 0x00000002 /* a client header matches a deny regex */ -#define SN_CLALLOW 0x00000004 /* a client header matches an allow regex */ -#define SN_SVDENY 0x00000008 /* a server header matches a deny regex */ -#define SN_SVALLOW 0x00000010 /* a server header matches an allow regex */ -#define SN_BE_ASSIGNED 0x00000020 /* a backend was assigned. Conns are accounted. */ - -/* session flags dedicated to cookies : bits values 0x40, 0x80 (0-3 shift 6) */ -#define SN_CK_NONE 0x00000000 /* this session had no cookie */ -#define SN_CK_INVALID 0x00000040 /* this session had a cookie which matches no server */ -#define SN_CK_DOWN 0x00000080 /* this session had cookie matching a down server */ -#define SN_CK_VALID 0x000000C0 /* this session had cookie matching a valid server */ -#define SN_CK_MASK 0x000000C0 /* mask to get this session's cookie flags */ -#define SN_CK_SHIFT 6 /* bit shift */ +#define SN_ASSIGNED 0x00000002 /* no need to assign a server to this session */ +#define SN_ADDR_SET 0x00000004 /* this session's server address has been set */ +#define SN_BE_ASSIGNED 0x00000008 /* a backend was assigned. Conns are accounted. */ +#define SN_CONN_CLOSED 0x00000010 /* "Connection: close" was present or added */ +#define SN_MONITOR 0x00000020 /* this session comes from a monitoring system */ +#define SN_SELF_GEN 0x00000040 /* the proxy generates data for the client (eg: stats) */ +/* unused: 0x00000080 */ /* session termination conditions, bits values 0x100 to 0x700 (0-7 shift 8) */ #define SN_ERR_NONE 0x00000000 @@ -66,6 +60,7 @@ #define SN_ERR_INTERNAL 0x00000700 /* the proxy encountered an internal error */ #define SN_ERR_MASK 0x00000700 /* mask to get only session error flags */ #define SN_ERR_SHIFT 8 /* bit shift */ +/* unused: 0x00000800 */ /* session state at termination, bits values 0x1000 to 0x7000 (0-7 shift 12) */ #define SN_FINST_R 0x00001000 /* session ended during client request */ @@ -77,28 +72,7 @@ #define SN_FINST_T 0x00007000 /* session ended tarpitted */ #define SN_FINST_MASK 0x00007000 /* mask to get only final session state flags */ #define SN_FINST_SHIFT 12 /* bit shift */ - -/* cookie information, bits values 0x10000 to 0x80000 (0-8 shift 16) */ -#define SN_SCK_NONE 0x00000000 /* no set-cookie seen for the server cookie */ -#define SN_SCK_DELETED 0x00010000 /* existing set-cookie deleted or changed */ -#define SN_SCK_INSERTED 0x00020000 /* new set-cookie inserted or changed existing one */ -#define SN_SCK_SEEN 0x00040000 /* set-cookie seen for the server cookie */ -#define SN_SCK_MASK 0x00070000 /* mask to get the set-cookie field */ -#define SN_SCK_ANY 0x00080000 /* at least one set-cookie seen (not to be counted) */ -#define SN_SCK_SHIFT 16 /* bit shift */ - -/* cacheability management, bits values 0x100000 to 0x300000 (0-3 shift 20) */ -#define SN_CACHEABLE 0x00100000 /* at least part of the response is cacheable */ -#define SN_CACHE_COOK 0x00200000 /* a cookie in the response is cacheable */ -#define SN_CACHE_SHIFT 20 /* bit shift */ - -/* various other session flags, bits values 0x400000 and above */ -#define SN_CONN_CLOSED 0x00000800 /* "Connection: close" was present or added */ -#define SN_MONITOR 0x00400000 /* this session comes from a monitoring system */ -#define SN_ASSIGNED 0x00800000 /* no need to assign a server to this session */ -#define SN_ADDR_SET 0x01000000 /* this session's server address has been set */ -#define SN_SELF_GEN 0x02000000 /* the proxy generates data for the client (eg: stats) */ -#define SN_CLTARPIT 0x04000000 /* the session is tarpitted (anti-dos) */ +/* unused: 0x00008000 */ /* WARNING: if new fields are added, they must be initialized in event_accept() diff --git a/src/backend.c b/src/backend.c index 68f2925761..0918a0b676 100644 --- a/src/backend.c +++ b/src/backend.c @@ -639,10 +639,7 @@ int srv_retryable_connect(struct session *t) t->flags &= ~(SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET); t->srv = NULL; /* it's left to the dispatcher to choose a server */ - if ((t->flags & SN_CK_MASK) == SN_CK_VALID) { - t->flags &= ~SN_CK_MASK; - t->flags |= SN_CK_DOWN; - } + http_flush_cookie_flags(&t->txn); return 0; } diff --git a/src/checks.c b/src/checks.c index 054571e068..ed0873a675 100644 --- a/src/checks.c +++ b/src/checks.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -71,10 +72,7 @@ void set_server_down(struct server *s) */ sess->flags &= ~(SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET); sess->srv = NULL; /* it's left to the dispatcher to choose a server */ - if ((sess->flags & SN_CK_MASK) == SN_CK_VALID) { - sess->flags &= ~SN_CK_MASK; - sess->flags |= SN_CK_DOWN; - } + http_flush_cookie_flags(&sess->txn); pendconn_free(pc); task_wakeup(&rq, sess->task); xferred++; diff --git a/src/client.c b/src/client.c index 1a1ccca18a..ea33240ad4 100644 --- a/src/client.c +++ b/src/client.c @@ -195,6 +195,7 @@ int event_accept(int fd) { p->cum_feconn++; /* cum_beconn will be increased once assigned */ txn = &s->txn; + txn->flags = 0; txn->req.cap = NULL; txn->rsp.cap = NULL; txn->hdr_idx.v = NULL; diff --git a/src/log.c b/src/log.c index a67a46d58f..b07d54be0e 100644 --- a/src/log.c +++ b/src/log.c @@ -410,8 +410,8 @@ void sess_log(struct session *s) txn->srv_cookie ? txn->srv_cookie : "-", sess_term_cond[(s->flags & SN_ERR_MASK) >> SN_ERR_SHIFT], sess_fin_state[(s->flags & SN_FINST_MASK) >> SN_FINST_SHIFT], - (be->beprm->options & PR_O_COOK_ANY) ? sess_cookie[(s->flags & SN_CK_MASK) >> SN_CK_SHIFT] : '-', - (be->beprm->options & PR_O_COOK_ANY) ? sess_set_cookie[(s->flags & SN_SCK_MASK) >> SN_SCK_SHIFT] : '-', + (be->beprm->options & PR_O_COOK_ANY) ? sess_cookie[(txn->flags & TX_CK_MASK) >> TX_CK_SHIFT] : '-', + (be->beprm->options & PR_O_COOK_ANY) ? sess_set_cookie[(txn->flags & TX_SCK_MASK) >> TX_SCK_SHIFT] : '-', actconn, fe->feconn, be->beprm->beconn, s->srv ? s->srv->cur_sess : 0, s->logs.srv_queue_size, s->logs.prx_queue_size, tmpline); } diff --git a/src/proto_http.c b/src/proto_http.c index 7ed6929819..eb2c0d5646 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -1450,7 +1450,7 @@ int process_cli(struct session *t) } /* has the request been denied ? */ - if (t->flags & SN_CLDENY) { + if (txn->flags & TX_CLDENY) { /* no need to go further */ txn->status = 403; /* let's log the request time */ @@ -1585,7 +1585,7 @@ int process_cli(struct session *t) * the fields will stay coherent and the URI will not move. * This should only be performed in the backend. */ - if (!(t->flags & (SN_CLDENY|SN_CLTARPIT))) + if (!(txn->flags & (TX_CLDENY|TX_CLTARPIT))) manage_client_side_cookies(t, req); @@ -1667,7 +1667,7 @@ int process_cli(struct session *t) * timeout. If unset, then set it to zero because we really want it * to expire at one moment. */ - if (t->flags & SN_CLTARPIT) { + if (txn->flags & TX_CLTARPIT) { t->req->l = 0; /* flush the request so that we can drop the connection early * if the client closes first. @@ -1986,6 +1986,7 @@ int process_srv(struct session *t) { int s = t->srv_state; int c = t->cli_state; + struct http_txn *txn = &t->txn; struct buffer *req = t->req; struct buffer *rep = t->rep; int conn_err; @@ -2009,7 +2010,7 @@ int process_srv(struct session *t) /* note that this must not return any error because it would be able to * overwrite the client_retnclose() output. */ - if (t->flags & SN_CLTARPIT) + if (txn->flags & TX_CLTARPIT) srv_close_with_err(t, SN_ERR_CLICL, SN_FINST_T, 0, NULL); else srv_close_with_err(t, SN_ERR_CLICL, t->pend_pos ? SN_FINST_Q : SN_FINST_C, 0, NULL); @@ -2017,7 +2018,7 @@ int process_srv(struct session *t) return 1; } else { - if (t->flags & SN_CLTARPIT) { + if (txn->flags & TX_CLTARPIT) { /* This connection is being tarpitted. The CLIENT side has * already set the connect expiration date to the right * timeout. We just have to check that it has not expired. @@ -2124,9 +2125,9 @@ int process_srv(struct session *t) t->flags &= ~(SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET); t->srv = NULL; /* it's left to the dispatcher to choose a server */ - if ((t->flags & SN_CK_MASK) == SN_CK_VALID) { - t->flags &= ~SN_CK_MASK; - t->flags |= SN_CK_DOWN; + if ((txn->flags & TX_CK_MASK) == TX_CK_VALID) { + txn->flags &= ~TX_CK_MASK; + txn->flags |= TX_CK_DOWN; } /* first, get a connection */ @@ -2227,7 +2228,6 @@ int process_srv(struct session *t) */ int cur_idx; - struct http_txn *txn = &t->txn; struct http_msg *msg = &txn->rsp; struct proxy *cur_proxy; @@ -2469,7 +2469,7 @@ int process_srv(struct session *t) */ if (likely(txn->meth != HTTP_METH_POST) && unlikely(t->be->beprm->options & PR_O_CHK_CACHE)) - t->flags |= SN_CACHEABLE | SN_CACHE_COOK; + txn->flags |= TX_CACHEABLE | TX_CACHE_COOK; break; default: break; @@ -2528,7 +2528,7 @@ int process_srv(struct session *t) } /* has the response been denied ? */ - if (t->flags & SN_SVDENY) { + if (txn->flags & TX_SVDENY) { if (t->srv) { t->srv->cur_sess--; t->srv->failed_secu++; @@ -2634,7 +2634,7 @@ int process_srv(struct session *t) if (hdr_idx_add(len - 2, 1, &txn->hdr_idx, txn->hdr_idx.tail) < 0) goto return_bad_resp; - t->flags |= SN_SCK_INSERTED; + txn->flags |= TX_SCK_INSERTED; /* Here, we will tell an eventual cache on the client side that we don't * want it to cache this reply because HTTP/1.0 caches also cache cookies ! @@ -2665,8 +2665,8 @@ int process_srv(struct session *t) * We'll block the response if security checks have caught * nasty things such as a cacheable cookie. */ - if (((t->flags & (SN_CACHEABLE | SN_CACHE_COOK | SN_SCK_ANY)) == - (SN_CACHEABLE | SN_CACHE_COOK | SN_SCK_ANY)) && + if (((txn->flags & (TX_CACHEABLE | TX_CACHE_COOK | TX_SCK_ANY)) == + (TX_CACHEABLE | TX_CACHE_COOK | TX_SCK_ANY)) && (t->be->beprm->options & PR_O_CHK_CACHE)) { /* we're in presence of a cacheable response containing @@ -3569,9 +3569,9 @@ int apply_filter_to_req_headers(struct session *t, struct buffer *req, struct hd old_idx = 0; while (!last_hdr) { - if (unlikely(t->flags & (SN_CLDENY | SN_CLTARPIT))) + if (unlikely(txn->flags & (TX_CLDENY | TX_CLTARPIT))) return 1; - else if (unlikely(t->flags & SN_CLALLOW) && + else if (unlikely(txn->flags & TX_CLALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY || exp->action == ACT_TARPIT)) @@ -3622,18 +3622,18 @@ int apply_filter_to_req_headers(struct session *t, struct buffer *req, struct hd break; case ACT_ALLOW: - t->flags |= SN_CLALLOW; + txn->flags |= TX_CLALLOW; last_hdr = 1; break; case ACT_DENY: - t->flags |= SN_CLDENY; + txn->flags |= TX_CLDENY; last_hdr = 1; t->be->beprm->denied_req++; break; case ACT_TARPIT: - t->flags |= SN_CLTARPIT; + txn->flags |= TX_CLTARPIT; last_hdr = 1; t->be->beprm->denied_req++; break; @@ -3693,9 +3693,9 @@ int apply_filter_to_req_line(struct session *t, struct buffer *req, struct hdr_e int len, delta; - if (unlikely(t->flags & (SN_CLDENY | SN_CLTARPIT))) + if (unlikely(txn->flags & (TX_CLDENY | TX_CLTARPIT))) return 1; - else if (unlikely(t->flags & SN_CLALLOW) && + else if (unlikely(txn->flags & TX_CLALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY || exp->action == ACT_TARPIT)) @@ -3742,18 +3742,18 @@ int apply_filter_to_req_line(struct session *t, struct buffer *req, struct hdr_e break; case ACT_ALLOW: - t->flags |= SN_CLALLOW; + txn->flags |= TX_CLALLOW; done = 1; break; case ACT_DENY: - t->flags |= SN_CLDENY; + txn->flags |= TX_CLDENY; t->be->beprm->denied_req++; done = 1; break; case ACT_TARPIT: - t->flags |= SN_CLTARPIT; + txn->flags |= TX_CLTARPIT; t->be->beprm->denied_req++; done = 1; break; @@ -3800,8 +3800,9 @@ int apply_filter_to_req_line(struct session *t, struct buffer *req, struct hdr_e */ int apply_filters_to_request(struct session *t, struct buffer *req, struct hdr_exp *exp) { + struct http_txn *txn = &t->txn; /* iterate through the filters in the outer loop */ - while (exp && !(t->flags & (SN_CLDENY|SN_CLTARPIT))) { + while (exp && !(txn->flags & (TX_CLDENY|TX_CLTARPIT))) { int ret; /* @@ -3810,7 +3811,7 @@ int apply_filters_to_request(struct session *t, struct buffer *req, struct hdr_e * the evaluation. */ - if ((t->flags & SN_CLALLOW) && + if ((txn->flags & TX_CLALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY || exp->action == ACT_TARPIT || exp->action == ACT_PASS)) { exp = exp->next; @@ -4014,23 +4015,24 @@ void manage_client_side_cookies(struct session *t, struct buffer *req) !memcmp(p3, srv->cookie, delim - p3)) { if (srv->state & SRV_RUNNING || t->be->beprm->options & PR_O_PERSIST) { /* we found the server and it's usable */ - t->flags &= ~SN_CK_MASK; - t->flags |= SN_CK_VALID | SN_DIRECT | SN_ASSIGNED; + txn->flags &= ~TX_CK_MASK; + txn->flags |= TX_CK_VALID; + t->flags |= SN_DIRECT | SN_ASSIGNED; t->srv = srv; break; } else { /* we found a server, but it's down */ - t->flags &= ~SN_CK_MASK; - t->flags |= SN_CK_DOWN; + txn->flags &= ~TX_CK_MASK; + txn->flags |= TX_CK_DOWN; } } srv = srv->next; } - if (!srv && !(t->flags & SN_CK_DOWN)) { + if (!srv && !(txn->flags & TX_CK_DOWN)) { /* no server matched this cookie */ - t->flags &= ~SN_CK_MASK; - t->flags |= SN_CK_INVALID; + txn->flags &= ~TX_CK_MASK; + txn->flags |= TX_CK_INVALID; } /* depending on the cookie mode, we may have to either : @@ -4123,13 +4125,14 @@ void manage_client_side_cookies(struct session *t, struct buffer *req) if (strcmp(srv->id, asession_temp->serverid) == 0) { if (srv->state & SRV_RUNNING || t->be->beprm->options & PR_O_PERSIST) { /* we found the server and it's usable */ - t->flags &= ~SN_CK_MASK; - t->flags |= SN_CK_VALID | SN_DIRECT | SN_ASSIGNED; + txn->flags &= ~TX_CK_MASK; + txn->flags |= TX_CK_VALID; + t->flags |= SN_DIRECT | SN_ASSIGNED; t->srv = srv; break; } else { - t->flags &= ~SN_CK_MASK; - t->flags |= SN_CK_DOWN; + txn->flags &= ~TX_CK_MASK; + txn->flags |= TX_CK_DOWN; } } srv = srv->next; @@ -4194,9 +4197,9 @@ int apply_filter_to_resp_headers(struct session *t, struct buffer *rtr, struct h old_idx = 0; while (!last_hdr) { - if (unlikely(t->flags & SN_SVDENY)) + if (unlikely(txn->flags & TX_SVDENY)) return 1; - else if (unlikely(t->flags & SN_SVALLOW) && + else if (unlikely(txn->flags & TX_SVALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY)) return 0; @@ -4225,12 +4228,12 @@ int apply_filter_to_resp_headers(struct session *t, struct buffer *rtr, struct h if (regexec(exp->preg, cur_ptr, MAX_MATCH, pmatch, 0) == 0) { switch (exp->action) { case ACT_ALLOW: - t->flags |= SN_SVALLOW; + txn->flags |= TX_SVALLOW; last_hdr = 1; break; case ACT_DENY: - t->flags |= SN_SVDENY; + txn->flags |= TX_SVDENY; last_hdr = 1; break; @@ -4287,9 +4290,9 @@ int apply_filter_to_sts_line(struct session *t, struct buffer *rtr, struct hdr_e int len, delta; - if (unlikely(t->flags & SN_SVDENY)) + if (unlikely(txn->flags & TX_SVDENY)) return 1; - else if (unlikely(t->flags & SN_SVALLOW) && + else if (unlikely(txn->flags & TX_SVALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY)) return 0; @@ -4314,12 +4317,12 @@ int apply_filter_to_sts_line(struct session *t, struct buffer *rtr, struct hdr_e if (regexec(exp->preg, cur_ptr, MAX_MATCH, pmatch, 0) == 0) { switch (exp->action) { case ACT_ALLOW: - t->flags |= SN_SVALLOW; + txn->flags |= TX_SVALLOW; done = 1; break; case ACT_DENY: - t->flags |= SN_SVDENY; + txn->flags |= TX_SVDENY; done = 1; break; @@ -4364,8 +4367,9 @@ int apply_filter_to_sts_line(struct session *t, struct buffer *rtr, struct hdr_e */ int apply_filters_to_response(struct session *t, struct buffer *rtr, struct hdr_exp *exp) { + struct http_txn *txn = &t->txn; /* iterate through the filters in the outer loop */ - while (exp && !(t->flags & SN_SVDENY)) { + while (exp && !(txn->flags & TX_SVDENY)) { int ret; /* @@ -4374,7 +4378,7 @@ int apply_filters_to_response(struct session *t, struct buffer *rtr, struct hdr_ * the evaluation. */ - if ((t->flags & SN_SVALLOW) && + if ((txn->flags & TX_SVALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY || exp->action == ACT_PASS)) { exp = exp->next; @@ -4445,7 +4449,7 @@ void manage_server_side_cookies(struct session *t, struct buffer *rtr) } /* OK, right now we know we have a set-cookie at cur_ptr */ - t->flags |= SN_SCK_ANY; + txn->flags |= TX_SCK_ANY; /* maybe we only wanted to see if there was a set-cookie */ @@ -4506,7 +4510,7 @@ void manage_server_side_cookies(struct session *t, struct buffer *rtr) if ((p2 - p1 == t->be->beprm->cookie_len) && (t->be->beprm->cookie_name != NULL) && (memcmp(p1, t->be->beprm->cookie_name, p2 - p1) == 0)) { /* Cool... it's the right one */ - t->flags |= SN_SCK_SEEN; + txn->flags |= TX_SCK_SEEN; /* If the cookie is in insert mode on a known server, we'll delete * this occurrence because we'll insert another one later. @@ -4522,7 +4526,7 @@ void manage_server_side_cookies(struct session *t, struct buffer *rtr) cur_next += delta; txn->rsp.eoh += delta; - t->flags |= SN_SCK_DELETED; + txn->flags |= TX_SCK_DELETED; } else if ((t->srv) && (t->srv->cookie) && (t->be->beprm->options & PR_O_COOK_RW)) { @@ -4534,7 +4538,7 @@ void manage_server_side_cookies(struct session *t, struct buffer *rtr) cur_next += delta; txn->rsp.eoh += delta; - t->flags |= SN_SCK_INSERTED | SN_SCK_DELETED; + txn->flags |= TX_SCK_INSERTED | TX_SCK_DELETED; } else if ((t->srv) && (t->srv->cookie) && (t->be->beprm->options & PR_O_COOK_PFX)) { @@ -4547,7 +4551,7 @@ void manage_server_side_cookies(struct session *t, struct buffer *rtr) txn->rsp.eoh += delta; p3[t->srv->cklen] = COOKIE_DELIM; - t->flags |= SN_SCK_INSERTED | SN_SCK_DELETED; + txn->flags |= TX_SCK_INSERTED | TX_SCK_DELETED; } } /* next, let's see if the cookie is our appcookie */ @@ -4623,7 +4627,7 @@ void check_response_for_cacheability(struct session *t, struct buffer *rtr) char *cur_ptr, *cur_end, *cur_next; int cur_idx; - if (!t->flags & SN_CACHEABLE) + if (!txn->flags & TX_CACHEABLE) return; /* Iterate through the headers. @@ -4647,7 +4651,7 @@ void check_response_for_cacheability(struct session *t, struct buffer *rtr) if ((cur_end - cur_ptr >= 16) && strncasecmp(cur_ptr, "Pragma: no-cache", 16) == 0) { - t->flags &= ~SN_CACHEABLE & ~SN_CACHE_COOK; + txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK; return; } @@ -4677,7 +4681,7 @@ void check_response_for_cacheability(struct session *t, struct buffer *rtr) if ((cur_end - p1 >= 21) && strncasecmp(p1, "no-cache=\"set-cookie", 20) == 0 && (p1[20] == '"' || p1[20] == ',')) - t->flags &= ~SN_CACHE_COOK; + txn->flags &= ~TX_CACHE_COOK; continue; } @@ -4686,12 +4690,12 @@ void check_response_for_cacheability(struct session *t, struct buffer *rtr) ((p2 - p1 == 8) && strncasecmp(p1, "no-store", 8) == 0) || ((p2 - p1 == 9) && strncasecmp(p1, "max-age=0", 9) == 0) || ((p2 - p1 == 10) && strncasecmp(p1, "s-maxage=0", 10) == 0)) { - t->flags &= ~SN_CACHEABLE & ~SN_CACHE_COOK; + txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK; return; } if ((p2 - p1 == 6) && strncasecmp(p1, "public", 6) == 0) { - t->flags |= SN_CACHEABLE | SN_CACHE_COOK; + txn->flags |= TX_CACHEABLE | TX_CACHE_COOK; continue; } } @@ -4704,6 +4708,7 @@ void check_response_for_cacheability(struct session *t, struct buffer *rtr) */ void get_srv_from_appsession(struct session *t, const char *begin, int len) { + struct http_txn *txn = &t->txn; appsess *asession_temp = NULL; appsess local_asession; char *request_line; @@ -4770,13 +4775,14 @@ void get_srv_from_appsession(struct session *t, const char *begin, int len) if (strcmp(srv->id, asession_temp->serverid) == 0) { if (srv->state & SRV_RUNNING || t->be->beprm->options & PR_O_PERSIST) { /* we found the server and it's usable */ - t->flags &= ~SN_CK_MASK; - t->flags |= SN_CK_VALID | SN_DIRECT | SN_ASSIGNED; + txn->flags &= ~TX_CK_MASK; + txn->flags |= TX_CK_VALID; + t->flags |= SN_DIRECT | SN_ASSIGNED; t->srv = srv; break; } else { - t->flags &= ~SN_CK_MASK; - t->flags |= SN_CK_DOWN; + txn->flags &= ~TX_CK_MASK; + txn->flags |= TX_CK_DOWN; } } srv = srv->next;