[MEDIUM] merge inspect_exp and txn->exp into request buffer

Since we may have several analysers on a buffer, it's more
convenient to have the analyser timeout attached to the
buffer itself.
diff --git a/include/types/buffers.h b/include/types/buffers.h
index d5177d7..f516ffe 100644
--- a/include/types/buffers.h
+++ b/include/types/buffers.h
@@ -87,6 +87,7 @@
 	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 */
diff --git a/include/types/proto_http.h b/include/types/proto_http.h
index 441b8dc..c9a28f7 100644
--- a/include/types/proto_http.h
+++ b/include/types/proto_http.h
@@ -243,7 +243,6 @@
 	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.
diff --git a/include/types/session.h b/include/types/session.h
index 65bb5e6..3035956 100644
--- a/include/types/session.h
+++ b/include/types/session.h
@@ -172,7 +172,6 @@
 	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 */
diff --git a/src/client.c b/src/client.c
index 3e1272e..a6c8ebf 100644
--- a/src/client.c
+++ b/src/client.c
@@ -353,10 +353,10 @@
 
 		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);
diff --git a/src/proto_http.c b/src/proto_http.c
index ac58950..91492b4 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -767,12 +767,8 @@
 
 		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 @@
 		 */
 		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 @@
 		/* 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 @@
 		 * - 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 @@
 				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 @@
 						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 @@
 		 * 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 @@
 			}
 
 			/* 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 @@
 			}
 
 			/* 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 @@
 		 ****************************************************************/
 
 		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 @@
 			/* 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;
 		}
 	}
 
diff --git a/src/proto_uxst.c b/src/proto_uxst.c
index 1fe2807..a56ab5d 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -496,8 +496,10 @@
 
 		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;