[MAJOR] timeouts and retries could be ignored when switching backend
authorWilly Tarreau <w@1wt.eu>
Tue, 18 Sep 2007 16:36:05 +0000 (18:36 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 15 Oct 2007 07:32:19 +0000 (09:32 +0200)
When switching from a frontend to a backend, the "retries" parameter
was not kept, resulting in the impossibility to reconnect after the
first connection failure. This problem was reported and analyzed by
Krzysztof Oledzki.

While fixing the code, it appeared that some of the backend's timeouts
were not updated in the session when using "use_backend" or "default_backend".
It seems this had no impact but just in case, it's better to set them as
they should have been.

src/proto_http.c

index 6d71dcd..9fe1039 100644 (file)
@@ -1905,6 +1905,11 @@ int process_cli(struct session *t)
                                                if (t->be->beconn > t->be->beconn_max)
                                                        t->be->beconn_max = t->be->beconn;
                                                t->be->cum_beconn++;
+
+                                               /* assign new parameters to the session from the new backend */
+                                               t->rep->rto = t->req->wto = t->be->srvtimeout;
+                                               t->req->cto = t->be->contimeout;
+                                               t->conn_retries = t->be->conn_retries;
                                                t->flags |= SN_BE_ASSIGNED;
                                                break;
                                        }
@@ -1921,6 +1926,11 @@ int process_cli(struct session *t)
                                if (t->be->beconn > t->be->beconn_max)
                                        t->be->beconn_max = t->be->beconn;
                                t->be->cum_beconn++;
+
+                               /* assign new parameters to the session from the new backend */
+                               t->rep->rto = t->req->wto = t->be->srvtimeout;
+                               t->req->cto = t->be->contimeout;
+                               t->conn_retries = t->be->conn_retries;
                                t->flags |= SN_BE_ASSIGNED;
                        }
                } while (t->be != cur_proxy);  /* we loop only if t->be has changed */
@@ -4037,6 +4047,7 @@ int apply_filter_to_req_headers(struct session *t, struct buffer *req, struct hd
 
                                t->rep->rto = t->req->wto = t->be->srvtimeout;
                                t->req->cto = t->be->contimeout;
+                               t->conn_retries = t->be->conn_retries;
                                last_hdr = 1;
                                break;
 
@@ -4157,6 +4168,7 @@ int apply_filter_to_req_line(struct session *t, struct buffer *req, struct hdr_e
 
                        t->rep->rto = t->req->wto = t->be->srvtimeout;
                        t->req->cto = t->be->contimeout;
+                       t->conn_retries = t->be->conn_retries;
                        done = 1;
                        break;