]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] merge inspect_exp and txn->exp into request buffer
authorWilly Tarreau <w@1wt.eu>
Sun, 17 Aug 2008 16:03:28 +0000 (18:03 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 17 Aug 2008 16:03:28 +0000 (18:03 +0200)
Since we may have several analysers on a buffer, it's more
convenient to have the analyser timeout attached to the
buffer itself.

include/types/buffers.h
include/types/proto_http.h
include/types/session.h
src/client.c
src/proto_http.c
src/proto_uxst.c

index d5177d7051077308811feb0989b7c6c327cce0be..f516ffe14e51f63549e48767f012b5a87ec8cb0d 100644 (file)
@@ -87,6 +87,7 @@ struct buffer {
        char *r, *w, *lr;               /* read ptr, write ptr, last read */
        char *rlim;                     /* read limit, used for header rewriting */
        unsigned int analysers;         /* bit field indicating what to do on the buffer */
+       int analyse_exp;                /* expiration date for current analysers (if set) */
        unsigned char xfer_large;       /* number of consecutive large xfers */
        unsigned char xfer_small;       /* number of consecutive small xfers */
        unsigned long long total;       /* total data read */
index 441b8dcbd6bb1548b027ef499bfaeffa34518bf1..c9a28f7e28ccc72034c4f4b50cf39b8dd596fb01 100644 (file)
@@ -243,7 +243,6 @@ struct http_txn {
        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 */
-       int exp;                        /* expiration date for the transaction (generally a request), int ticks */
 };
 
 /* This structure is used by http_find_header() to return values of headers.
index 65bb5e657a86005286097e0f34cba4f16f78689e..30359560729bb9f2e7b68dfd2383bdb931ed736b 100644 (file)
@@ -172,7 +172,6 @@ struct session {
        struct server *prev_srv;                /* the server the was running on, after a redispatch, otherwise NULL */
        struct pendconn *pend_pos;              /* if not NULL, points to the position in the pending queue */
        struct http_txn txn;                    /* current HTTP transaction being processed. Should become a list. */
-       int inspect_exp;                        /* expiration date for data to be inspected, in ticks */
        struct {
                int logwait;                    /* log fields waiting to be collected : LW_* */
                struct timeval accept_date;     /* date of the accept() in user date */
index 3e1272e0cc061095ccaa52c55a36a2c11fa95d2f..a6c8ebfb81d4498fcd645f22060159068bbcf07f 100644 (file)
@@ -353,10 +353,10 @@ int event_accept(int fd) {
 
                s->req->rex = TICK_ETERNITY;
                s->req->wex = TICK_ETERNITY;
+               s->req->analyse_exp = TICK_ETERNITY;
                s->rep->rex = TICK_ETERNITY;
                s->rep->wex = TICK_ETERNITY;
-               s->txn.exp = TICK_ETERNITY;
-               s->inspect_exp = TICK_ETERNITY;
+               s->rep->analyse_exp = TICK_ETERNITY;
                t->expire = TICK_ETERNITY;
 
                fd_insert(cfd);
index ac5895047dff9067b7433c487eeec85d58b981ce..91492b4e23ffaf52fe61e45cc813000887e178c9 100644 (file)
@@ -767,12 +767,8 @@ void process_session(struct task *t, int *next)
 
                t->expire = tick_first(tick_first(s->req->rex, s->req->wex),
                                       tick_first(s->rep->rex, s->rep->wex));
-               if (s->req->analysers) {
-                       if (s->req->analysers & AN_REQ_INSPECT)
-                               t->expire = tick_first(t->expire, s->inspect_exp);
-                       else if (s->req->analysers & AN_REQ_HTTP_HDR)
-                               t->expire = tick_first(t->expire, s->txn.exp);
-               }
+               if (s->req->analysers)
+                       t->expire = tick_first(t->expire, s->req->analyse_exp);
 
                /* restore t to its place in the task list */
                task_queue(t);
@@ -1661,7 +1657,6 @@ int process_request(struct session *t)
                 */
                if (req->flags & BF_READ_ERROR) {
                        req->analysers = 0;
-                       t->inspect_exp = TICK_ETERNITY;
                        t->fe->failed_req++;
                        if (!(t->flags & SN_ERR_MASK))
                                t->flags |= SN_ERR_CLICL;
@@ -1673,7 +1668,6 @@ int process_request(struct session *t)
                /* Abort if client read timeout has expired */
                else if (req->flags & BF_READ_TIMEOUT) {
                        req->analysers = 0;
-                       t->inspect_exp = TICK_ETERNITY;
                        t->fe->failed_req++;
                        if (!(t->flags & SN_ERR_MASK))
                                t->flags |= SN_ERR_CLITO;
@@ -1692,8 +1686,7 @@ int process_request(struct session *t)
                 * - if one rule returns KO, then return KO
                 */
 
-               if (req->flags & (BF_READ_NULL | BF_SHUTR) ||
-                   tick_is_expired(t->inspect_exp, now_ms))
+               if (req->flags & (BF_READ_NULL | BF_SHUTR) || tick_is_expired(req->analyse_exp, now_ms))
                        partial = 0;
                else
                        partial = ACL_PARTIAL;
@@ -1705,8 +1698,8 @@ int process_request(struct session *t)
                                ret = acl_exec_cond(rule->cond, t->fe, t, NULL, ACL_DIR_REQ | partial);
                                if (ret == ACL_PAT_MISS) {
                                        /* just set the request timeout once at the beginning of the request */
-                                       if (!tick_isset(t->inspect_exp))
-                                               t->inspect_exp = tick_add_ifset(now_ms, t->fe->tcp_req.inspect_delay);
+                                       if (!tick_isset(req->analyse_exp))
+                                               req->analyse_exp = tick_add_ifset(now_ms, t->fe->tcp_req.inspect_delay);
                                        return 0;
                                }
 
@@ -1728,7 +1721,6 @@ int process_request(struct session *t)
                                                t->flags |= SN_ERR_PRXCOND;
                                        if (!(t->flags & SN_FINST_MASK))
                                                t->flags |= SN_FINST_R;
-                                       t->inspect_exp = TICK_ETERNITY;
                                        return 0;
                                }
                                /* otherwise accept */
@@ -1740,7 +1732,7 @@ int process_request(struct session *t)
                 * we have an explicit accept, so we apply the default accept.
                 */
                req->analysers &= ~AN_REQ_INSPECT;
-               t->inspect_exp = TICK_ETERNITY;
+               req->analyse_exp = TICK_ETERNITY;
        }
 
        if (req->analysers & AN_REQ_HTTP_HDR) {
@@ -1834,7 +1826,7 @@ int process_request(struct session *t)
                        }
 
                        /* 3: has the read timeout expired ? */
-                       else if (req->flags & BF_READ_TIMEOUT || tick_is_expired(txn->exp, now_ms)) {
+                       else if (req->flags & BF_READ_TIMEOUT || tick_is_expired(req->analyse_exp, now_ms)) {
                                /* read timeout : give up with an error message. */
                                txn->status = 408;
                                client_retnclose(t, error_message(t, HTTP_ERR_408));
@@ -1862,8 +1854,8 @@ int process_request(struct session *t)
                        }
 
                        /* just set the request timeout once at the beginning of the request */
-                       if (!tick_isset(t->txn.exp))
-                               t->txn.exp = tick_add_ifset(now_ms, t->fe->timeout.httpreq);
+                       if (!tick_isset(req->analyse_exp))
+                               req->analyse_exp = tick_add_ifset(now_ms, t->fe->timeout.httpreq);
 
                        /* we're not ready yet */
                        return 0;
@@ -1877,6 +1869,7 @@ int process_request(struct session *t)
                 ****************************************************************/
 
                req->analysers &= ~AN_REQ_HTTP_HDR;
+               req->analyse_exp = TICK_ETERNITY;
 
                /* ensure we keep this pointer to the beginning of the message */
                msg->sol = req->data + msg->som;
@@ -2573,6 +2566,7 @@ int process_request(struct session *t)
                        /* The situation will not evolve, so let's give up on the analysis. */
                        t->logs.tv_request = now;  /* update the request timer to reflect full request */
                        req->analysers &= ~AN_REQ_HTTP_BODY;
+                       req->analyse_exp = TICK_ETERNITY;
                }
        }
 
index 1fe2807c2d64c03865ff50563e46f3cf802a6ad2..a56ab5d275391280e858a6d3d31b779f1ae9d836 100644 (file)
@@ -496,8 +496,10 @@ int uxst_event_accept(int fd) {
 
                s->req->rex = TICK_ETERNITY;
                s->req->wex = TICK_ETERNITY;
+               s->req->analyse_exp = TICK_ETERNITY;
                s->rep->rex = TICK_ETERNITY;
                s->rep->wex = TICK_ETERNITY;
+               s->rep->analyse_exp = TICK_ETERNITY;
 
                s->req->wto = TICK_ETERNITY;
                s->req->cto = TICK_ETERNITY;