[MEDIUM] use buffer->wex instead of buffer->cex for connect timeout

It's a shame not to use buffer->wex for connection timeouts since by
definition it cannot be used till the connection is not established.
Using it instead of ->cex also makes the buffer processing more
symmetric.
diff --git a/include/types/buffers.h b/include/types/buffers.h
index 0c3bb37..f149ddb 100644
--- a/include/types/buffers.h
+++ b/include/types/buffers.h
@@ -66,8 +66,7 @@
 struct buffer {
 	unsigned int flags;             /* BF_* */
 	int rex;                        /* expiration date for a read, in ticks */
-	int wex;                        /* expiration date for a write, in ticks */
-	int cex;                        /* expiration date for a connect, in ticks */
+	int wex;                        /* expiration date for a write or connect, in ticks */
 	int rto;                        /* read timeout, in ticks */
 	int wto;                        /* write timeout, in ticks */
 	int cto;                        /* connect timeout, in ticks */
diff --git a/src/backend.c b/src/backend.c
index 2d5be17..f9b6dd1 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -1826,7 +1826,7 @@
 			s->be->lbprm.server_take_conn(s->srv);
 	}
 
-	s->req->cex = tick_add_ifset(now_ms, s->be->timeout.connect);
+	s->req->wex = tick_add_ifset(now_ms, s->be->timeout.connect);
 	return SN_ERR_NONE;  /* connection is OK */
 }
 
@@ -1844,7 +1844,7 @@
 
 	if (t->conn_retries < 0) {
 		/* if not retryable anymore, let's abort */
-		t->req->cex = TICK_ETERNITY;
+		t->req->wex = TICK_ETERNITY;
 		srv_close_with_err(t, conn_err, SN_FINST_C,
 				   503, error_message(t, HTTP_ERR_503));
 		if (t->srv)
@@ -1888,7 +1888,7 @@
 			return 1;
 	    
 		case SN_ERR_INTERNAL:
-			t->req->cex = TICK_ETERNITY;
+			t->req->wex = TICK_ETERNITY;
 			srv_close_with_err(t, SN_ERR_INTERNAL, SN_FINST_C,
 					   500, error_message(t, HTTP_ERR_500));
 			if (t->srv)
@@ -1959,7 +1959,7 @@
 			goto redispatch;
 		}
 
-		t->req->cex = TICK_ETERNITY;
+		t->req->wex = TICK_ETERNITY;
 		srv_close_with_err(t, SN_ERR_SRVTO, SN_FINST_Q,
 				   503, error_message(t, HTTP_ERR_503));
 
@@ -1969,7 +1969,7 @@
 
 	case SRV_STATUS_NOSRV:
 		/* note: it is guaranteed that t->srv == NULL here */
-		t->req->cex = TICK_ETERNITY;
+		t->req->wex = TICK_ETERNITY;
 		srv_close_with_err(t, SN_ERR_SRVTO, SN_FINST_C,
 				   503, error_message(t, HTTP_ERR_503));
 
@@ -1977,14 +1977,14 @@
 		return 1;
 
 	case SRV_STATUS_QUEUED:
-		t->req->cex = tick_add_ifset(now_ms, t->be->timeout.queue);
+		t->req->wex = tick_add_ifset(now_ms, t->be->timeout.queue);
 		t->srv_state = SV_STIDLE;
 		/* do nothing else and do not wake any other session up */
 		return 1;
 
 	case SRV_STATUS_INTERNAL:
 	default:
-		t->req->cex = TICK_ETERNITY;
+		t->req->wex = TICK_ETERNITY;
 		srv_close_with_err(t, SN_ERR_INTERNAL, SN_FINST_C,
 				   500, error_message(t, HTTP_ERR_500));
 		if (t->srv)
diff --git a/src/client.c b/src/client.c
index 67c6dc7..8c63387 100644
--- a/src/client.c
+++ b/src/client.c
@@ -354,7 +354,6 @@
 
 		s->req->rex = TICK_ETERNITY;
 		s->req->wex = TICK_ETERNITY;
-		s->req->cex = TICK_ETERNITY;
 		s->rep->rex = TICK_ETERNITY;
 		s->rep->wex = TICK_ETERNITY;
 		s->txn.exp = TICK_ETERNITY;
diff --git a/src/proto_http.c b/src/proto_http.c
index 808dcee..9a1cdf4 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -745,12 +745,11 @@
 		 */
 
 		if ((s->rep->flags & (BF_MAY_FORWARD|BF_SHUTR)) == 0 &&
-		    (tick_isset(s->req->cex) || tick_isset(s->req->wex) || tick_isset(s->rep->rex)))
+		    (tick_isset(s->req->wex) || tick_isset(s->rep->rex)))
 			s->req->rex = TICK_ETERNITY;
 
 		t->expire = tick_first(tick_first(s->req->rex, s->req->wex),
 				       tick_first(s->rep->rex, s->rep->wex));
-		t->expire = tick_first(t->expire, s->req->cex);
 		if (s->analysis & AN_REQ_ANY) {
 			if (s->analysis & AN_REQ_INSPECT)
 				t->expire = tick_first(t->expire, s->inspect_exp);
@@ -2472,9 +2471,9 @@
 			/* flush the request so that we can drop the connection early
 			 * if the client closes first.
 			 */
-			req->cex = tick_add_ifset(now_ms, t->be->timeout.tarpit);
-			if (!req->cex)
-				req->cex = now_ms;
+			req->wex = tick_add_ifset(now_ms, t->be->timeout.tarpit);
+			if (!req->wex)
+				req->wex = now_ms;
 		}
 
 		/* OK let's go on with the BODY now */
@@ -3276,7 +3275,7 @@
 		if ((rep->flags & BF_SHUTW) ||
 			 ((req->flags & BF_SHUTR) &&
 			  (req->flags & BF_EMPTY || t->be->options & PR_O_ABRT_CLOSE))) { /* give up */
-			req->cex = TICK_ETERNITY;
+			req->wex = TICK_ETERNITY;
 			if (t->pend_pos)
 				t->logs.t_queue = tv_ms_elapsed(&t->logs.tv_accept, &now);
 			/* note that this must not return any error because it would be able to
@@ -3297,7 +3296,7 @@
 				 * already set the connect expiration date to the right
 				 * timeout. We just have to check that it has not expired.
 				 */
-				if (!tick_is_expired(req->cex, now_ms))
+				if (!tick_is_expired(req->wex, now_ms))
 					return 0;
 
 				/* We will set the queue timer to the time spent, just for
@@ -3306,7 +3305,7 @@
 				 * It will not cause trouble to the logs because we can exclude
 				 * the tarpitted connections by filtering on the 'PT' status flags.
 				 */
-				req->cex = TICK_ETERNITY;
+				req->wex = TICK_ETERNITY;
 				t->logs.t_queue = tv_ms_elapsed(&t->logs.tv_accept, &now);
 				srv_close_with_err(t, SN_ERR_PRXCOND, SN_FINST_T,
 						   500, error_message(t, HTTP_ERR_500));
@@ -3320,11 +3319,11 @@
 			 * to any other session to release it and wake us up again.
 			 */
 			if (t->pend_pos) {
-				if (!tick_is_expired(req->cex, now_ms)) {
+				if (!tick_is_expired(req->wex, now_ms)) {
 					return 0;
 				} else {
 					/* we've been waiting too long here */
-					req->cex = TICK_ETERNITY;
+					req->wex = TICK_ETERNITY;
 					t->logs.t_queue = tv_ms_elapsed(&t->logs.tv_accept, &now);
 					srv_close_with_err(t, SN_ERR_SRVTO, SN_FINST_Q,
 							   503, error_message(t, HTTP_ERR_503));
@@ -3415,7 +3414,7 @@
 		    ((req->flags & BF_SHUTR) &&
 		     ((req->flags & BF_EMPTY && !(req->flags & BF_WRITE_STATUS)) ||
 		      t->be->options & PR_O_ABRT_CLOSE))) { /* give up */
-			req->cex = TICK_ETERNITY;
+			req->wex = TICK_ETERNITY;
 			if (!(t->flags & SN_CONN_TAR)) {
 				/* if we are in turn-around, we have already closed the FD */
 				fd_delete(t->srv_fd);
@@ -3432,14 +3431,14 @@
 			trace_term(t, TT_HTTP_SRV_5);
 			goto update_state;
 		}
-		if (!(req->flags & BF_WRITE_STATUS) && !tick_is_expired(req->cex, now_ms)) {
+		if (!(req->flags & BF_WRITE_STATUS) && !tick_is_expired(req->wex, now_ms)) {
 			return 0; /* nothing changed */
 		}
 		else if (!(req->flags & BF_WRITE_STATUS) || (req->flags & BF_WRITE_ERROR)) {
 			/* timeout, asynchronous connect error or first write error */
 			if (t->flags & SN_CONN_TAR) {
 				/* We are doing a turn-around waiting for a new connection attempt. */
-				if (!tick_is_expired(req->cex, now_ms))
+				if (!tick_is_expired(req->wex, now_ms))
 					return 0;
 				t->flags &= ~SN_CONN_TAR;
 			}
@@ -3468,7 +3467,7 @@
 					 * time of 1 second. We will wait in the previous if block.
 					 */
 					t->flags |= SN_CONN_TAR;
-					req->cex = tick_add(now_ms, MS_TO_TICKS(1000));
+					req->wex = tick_add(now_ms, MS_TO_TICKS(1000));
 					return 0;
 				}
 			}
@@ -3565,7 +3564,7 @@
 			t->srv_state = SV_STDATA;
 			if (!(t->analysis & AN_RTR_ANY))
 				t->rep->flags |= BF_MAY_FORWARD;
-			req->cex = TICK_ETERNITY;
+			req->wex = TICK_ETERNITY;
 			goto update_state;
 		} /* else no error or write 0 */
 	}
diff --git a/src/proto_uxst.c b/src/proto_uxst.c
index 443586f..9e31e1d 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -497,7 +497,6 @@
 
 		s->req->rex = TICK_ETERNITY;
 		s->req->wex = TICK_ETERNITY;
-		s->req->cex = TICK_ETERNITY;
 		s->rep->rex = TICK_ETERNITY;
 		s->rep->wex = TICK_ETERNITY;
 
@@ -1460,7 +1459,6 @@
 
 		t->expire = tick_first(tick_first(s->req->rex, s->req->wex),
 				       tick_first(s->rep->rex, s->rep->wex));
-		t->expire = tick_first(t->expire, s->req->cex);
 
 		/* restore t to its place in the task list */
 		task_queue(t);