[MEDIUM] session: initialize server-side timeouts after connect()

It was particularly embarrassing that the server timeout was assigned
to buffers during an accept() just to be potentially changed later in
case of a use_backend rule. The frontend side has nothing to do with
server timeouts.

Now we initialize them right after the connect() succeeds. Later this
should change for a unique stream-interface timeout setting only.
diff --git a/src/frontend.c b/src/frontend.c
index a51231e..cdd46ce 100644
--- a/src/frontend.c
+++ b/src/frontend.c
@@ -351,7 +351,7 @@
 	}
 
 	s->req->rto = s->fe->timeout.client;
-	s->req->wto = s->be->timeout.server;
+	s->req->wto = TICK_ETERNITY;
 
 	if (unlikely((s->rep = pool_alloc2(pool2_buffer)) == NULL))
 		goto out_fail_rep; /* no memory */
@@ -363,7 +363,7 @@
 	s->si[0].ob = s->si[1].ib = s->rep;
 	s->rep->analysers = 0;
 
-	s->rep->rto = s->be->timeout.server;
+	s->rep->rto = TICK_ETERNITY;
 	s->rep->wto = s->fe->timeout.client;
 
 	s->req->rex = TICK_ETERNITY;
diff --git a/src/proto_http.c b/src/proto_http.c
index b533c2d..a1ff02c 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -6746,9 +6746,9 @@
 	}
 
 	s->req->rto = s->fe->timeout.client;
-	s->req->wto = s->be->timeout.server;
+	s->req->wto = TICK_ETERNITY;
 
-	s->rep->rto = s->be->timeout.server;
+	s->rep->rto = TICK_ETERNITY;
 	s->rep->wto = s->fe->timeout.client;
 
 	s->req->rex = TICK_ETERNITY;
diff --git a/src/proxy.c b/src/proxy.c
index 6b03877..98ff94d 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -719,7 +719,6 @@
 	proxy_inc_be_ctr(be);
 
 	/* assign new parameters to the session from the new backend */
-	s->rep->rto = s->req->wto = be->timeout.server;
 	s->conn_retries = be->conn_retries;
 	s->si[1].flags &= ~SI_FL_INDEP_STR;
 	if (be->options2 & PR_O2_INDEPSTR)
diff --git a/src/session.c b/src/session.c
index ec8d07b..08bb4c3 100644
--- a/src/session.c
+++ b/src/session.c
@@ -347,6 +347,11 @@
 
 	rep->analysers |= s->fe->fe_rsp_ana | s->be->be_rsp_ana;
 	rep->flags |= BF_READ_ATTACHED; /* producer is now attached */
+	if (si->connect) {
+		/* real connections have timeouts */
+		req->wto = s->be->timeout.server;
+		rep->rto = s->be->timeout.server;
+	}
 	req->wex = TICK_ETERNITY;
 }