From d04e858db0e8072529b176321c1c31aa10c82e59 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 31 May 2010 12:31:35 +0200 Subject: [PATCH] [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. --- src/frontend.c | 4 ++-- src/proto_http.c | 4 ++-- src/proxy.c | 1 - src/session.c | 5 +++++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/frontend.c b/src/frontend.c index a51231e508..cdd46cef49 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -351,7 +351,7 @@ int frontend_accept(struct listener *l, int cfd, struct sockaddr_storage *addr) } 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 @@ int frontend_accept(struct listener *l, int cfd, struct sockaddr_storage *addr) 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 b533c2d341..a1ff02c84a 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -6746,9 +6746,9 @@ void http_reset_txn(struct session *s) } 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 6b038777d2..98ff94db36 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -719,7 +719,6 @@ int session_set_backend(struct session *s, struct proxy *be) 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 ec8d07b38e..08bb4c315e 100644 --- a/src/session.c +++ b/src/session.c @@ -347,6 +347,11 @@ void sess_establish(struct session *s, struct stream_interface *si) 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; }