[CLEANUP] grouped all timeouts in one structure
All known timeouts in a proxy have been grouped into a
"timeout" sub-structure.
diff --git a/src/backend.c b/src/backend.c
index 57b421c..6aa7eaf 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -1329,7 +1329,7 @@
s->srv->cur_sess_max = s->srv->cur_sess;
}
- if (!tv_add_ifset(&s->req->cex, &now, &s->be->contimeout))
+ if (!tv_add_ifset(&s->req->cex, &now, &s->be->timeout.connect))
tv_eternity(&s->req->cex);
return SN_ERR_NONE; /* connection is OK */
}
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 8bb787e..93088a7 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -498,10 +498,10 @@
defproxy.maxconn = cfg_maxpconn;
defproxy.conn_retries = CONN_RETRIES;
defproxy.logfac1 = defproxy.logfac2 = -1; /* log disabled */
- tv_eternity(&defproxy.clitimeout);
- tv_eternity(&defproxy.contimeout);
- tv_eternity(&defproxy.srvtimeout);
- tv_eternity(&defproxy.appsession_timeout);
+ tv_eternity(&defproxy.timeout.client);
+ tv_eternity(&defproxy.timeout.connect);
+ tv_eternity(&defproxy.timeout.server);
+ tv_eternity(&defproxy.timeout.appsession);
tv_eternity(&defproxy.timeout.queue);
tv_eternity(&defproxy.timeout.tarpit);
}
@@ -580,10 +580,10 @@
/* Timeouts are defined as -1, so we cannot use the zeroed area
* as a default value.
*/
- tv_eternity(&curproxy->clitimeout);
- tv_eternity(&curproxy->srvtimeout);
- tv_eternity(&curproxy->contimeout);
- tv_eternity(&curproxy->appsession_timeout);
+ tv_eternity(&curproxy->timeout.client);
+ tv_eternity(&curproxy->timeout.server);
+ tv_eternity(&curproxy->timeout.connect);
+ tv_eternity(&curproxy->timeout.appsession);
tv_eternity(&curproxy->timeout.queue);
tv_eternity(&curproxy->timeout.tarpit);
@@ -643,7 +643,7 @@
}
if (curproxy->cap & PR_CAP_FE) {
- curproxy->clitimeout = defproxy.clitimeout;
+ curproxy->timeout.client = defproxy.timeout.client;
curproxy->timeout.tarpit = defproxy.timeout.tarpit;
curproxy->uri_auth = defproxy.uri_auth;
curproxy->mon_net = defproxy.mon_net;
@@ -656,8 +656,8 @@
}
if (curproxy->cap & PR_CAP_BE) {
- curproxy->contimeout = defproxy.contimeout;
- curproxy->srvtimeout = defproxy.srvtimeout;
+ curproxy->timeout.connect = defproxy.timeout.connect;
+ curproxy->timeout.server = defproxy.timeout.server;
curproxy->timeout.queue = defproxy.timeout.queue;
curproxy->source_addr = defproxy.source_addr;
}
@@ -882,9 +882,9 @@
return -1;
}
if (val > 0)
- __tv_from_ms(&curproxy->appsession_timeout, val);
+ __tv_from_ms(&curproxy->timeout.appsession, val);
else
- tv_eternity(&curproxy->appsession_timeout);
+ tv_eternity(&curproxy->timeout.appsession);
if (appsession_hash_init(&(curproxy->htbl_proxy), destroy) == 0) {
Alert("parsing [%s:%d] : out of memory.\n", file, linenum);
@@ -2682,9 +2682,9 @@
}
if ((curproxy->mode == PR_MODE_TCP || curproxy->mode == PR_MODE_HTTP) &&
- (((curproxy->cap & PR_CAP_FE) && !tv_isset(&curproxy->clitimeout)) ||
+ (((curproxy->cap & PR_CAP_FE) && !tv_isset(&curproxy->timeout.client)) ||
((curproxy->cap & PR_CAP_BE) && (curproxy->srv) &&
- (!tv_isset(&curproxy->contimeout) || !tv_isset(&curproxy->srvtimeout))))) {
+ (!tv_isset(&curproxy->timeout.connect) || !tv_isset(&curproxy->timeout.server))))) {
Warning("parsing %s : missing timeouts for %s '%s'.\n"
" | While not properly invalid, you will certainly encounter various problems\n"
" | with such a configuration. To fix this, please ensure that all following\n"
@@ -2705,10 +2705,10 @@
*/
if (tv_isset(&defproxy.timeout.tarpit))
curproxy->timeout.tarpit = defproxy.timeout.tarpit;
- else if (tv_isset(&curproxy->contimeout))
- curproxy->timeout.tarpit = curproxy->contimeout;
- else if (tv_isset(&defproxy.contimeout))
- curproxy->timeout.tarpit = defproxy.contimeout;
+ else if (tv_isset(&curproxy->timeout.connect))
+ curproxy->timeout.tarpit = curproxy->timeout.connect;
+ else if (tv_isset(&defproxy.timeout.connect))
+ curproxy->timeout.tarpit = defproxy.timeout.connect;
}
if ((curproxy->cap & PR_CAP_BE) &&
(!tv_isset(&curproxy->timeout.queue) ||
@@ -2718,10 +2718,10 @@
*/
if (tv_isset(&defproxy.timeout.queue))
curproxy->timeout.queue = defproxy.timeout.queue;
- else if (tv_isset(&curproxy->contimeout))
- curproxy->timeout.queue = curproxy->contimeout;
- else if (tv_isset(&defproxy.contimeout))
- curproxy->timeout.queue = defproxy.contimeout;
+ else if (tv_isset(&curproxy->timeout.connect))
+ curproxy->timeout.queue = curproxy->timeout.connect;
+ else if (tv_isset(&defproxy.timeout.connect))
+ curproxy->timeout.queue = defproxy.timeout.connect;
}
}
@@ -2826,7 +2826,7 @@
if (curproxy->options & PR_O_TCP_NOLING)
listener->options |= LI_O_NOLINGER;
listener->maxconn = curproxy->maxconn;
- listener->timeout = &curproxy->clitimeout;
+ listener->timeout = &curproxy->timeout.client;
listener->accept = event_accept;
listener->private = curproxy;
diff --git a/src/client.c b/src/client.c
index 73c8895..2505db3 100644
--- a/src/client.c
+++ b/src/client.c
@@ -348,17 +348,17 @@
if (s->cli_state == CL_STHEADERS) /* reserve some space for header rewriting */
s->req->rlim -= MAXREWRITE;
- s->req->rto = s->fe->clitimeout;
- s->req->wto = s->be->srvtimeout;
- s->req->cto = s->be->contimeout;
+ s->req->rto = s->fe->timeout.client;
+ s->req->wto = s->be->timeout.server;
+ s->req->cto = s->be->timeout.connect;
if ((s->rep = pool_alloc2(pool2_buffer)) == NULL)
goto out_fail_rep; /* no memory */
buffer_init(s->rep);
- s->rep->rto = s->be->srvtimeout;
- s->rep->wto = s->fe->clitimeout;
+ s->rep->rto = s->be->timeout.server;
+ s->rep->wto = s->fe->timeout.client;
tv_eternity(&s->rep->cto);
fd_insert(cfd);
@@ -397,13 +397,13 @@
tv_eternity(&s->rep->wex);
tv_eternity(&t->expire);
- if (tv_isset(&s->fe->clitimeout)) {
+ if (tv_isset(&s->fe->timeout.client)) {
if (EV_FD_ISSET(cfd, DIR_RD)) {
- tv_add(&s->req->rex, &now, &s->fe->clitimeout);
+ tv_add(&s->req->rex, &now, &s->fe->timeout.client);
t->expire = s->req->rex;
}
if (EV_FD_ISSET(cfd, DIR_WR)) {
- tv_add(&s->rep->wex, &now, &s->fe->clitimeout);
+ tv_add(&s->rep->wex, &now, &s->fe->timeout.client);
t->expire = s->rep->wex;
}
}
diff --git a/src/proto_http.c b/src/proto_http.c
index 55c67c1..7d36b0a 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -1603,7 +1603,7 @@
* full. We cannot loop here since stream_sock_read will disable it only if
* req->l == rlim-data
*/
- if (!tv_add_ifset(&req->rex, &now, &t->fe->clitimeout))
+ if (!tv_add_ifset(&req->rex, &now, &t->fe->timeout.client))
tv_eternity(&req->rex);
}
return t->cli_state != CL_STHEADERS;
@@ -1879,8 +1879,8 @@
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->rep->rto = t->req->wto = t->be->timeout.server;
+ t->req->cto = t->be->timeout.connect;
t->conn_retries = t->be->conn_retries;
t->flags |= SN_BE_ASSIGNED;
break;
@@ -1900,8 +1900,8 @@
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->rep->rto = t->req->wto = t->be->timeout.server;
+ t->req->cto = t->be->timeout.connect;
t->conn_retries = t->be->conn_retries;
t->flags |= SN_BE_ASSIGNED;
}
@@ -2024,8 +2024,8 @@
t->logs.t_request = tv_ms_elapsed(&t->logs.tv_accept, &now);
- if (!tv_isset(&t->fe->clitimeout) ||
- (t->srv_state < SV_STDATA && tv_isset(&t->be->srvtimeout))) {
+ if (!tv_isset(&t->fe->timeout.client) ||
+ (t->srv_state < SV_STDATA && tv_isset(&t->be->timeout.server))) {
/* If the client has no timeout, or if the server is not ready yet,
* and we know for sure that it can expire, then it's cleaner to
* disable the timeout on the client side so that too low values
@@ -2108,7 +2108,7 @@
/* We must ensure that the read part is still alive when switching
* to shutw */
EV_FD_SET(t->cli_fd, DIR_RD);
- tv_add_ifset(&req->rex, &now, &t->fe->clitimeout);
+ tv_add_ifset(&req->rex, &now, &t->fe->timeout.client);
t->cli_state = CL_STSHUTW;
//fprintf(stderr,"%p:%s(%d), c=%d, s=%d\n", t, __FUNCTION__, __LINE__, t->cli_state, t->cli_state);
return 1;
@@ -2138,7 +2138,7 @@
/* We must ensure that the read part is still alive when switching
* to shutw */
EV_FD_SET(t->cli_fd, DIR_RD);
- tv_add_ifset(&req->rex, &now, &t->fe->clitimeout);
+ tv_add_ifset(&req->rex, &now, &t->fe->timeout.client);
t->cli_state = CL_STSHUTW;
if (!(t->flags & SN_ERR_MASK))
@@ -2163,8 +2163,8 @@
} else {
/* there's still some space in the buffer */
if (EV_FD_COND_S(t->cli_fd, DIR_RD)) {
- if (!tv_isset(&t->fe->clitimeout) ||
- (t->srv_state < SV_STDATA && tv_isset(&t->be->srvtimeout)))
+ if (!tv_isset(&t->fe->timeout.client) ||
+ (t->srv_state < SV_STDATA && tv_isset(&t->be->timeout.server)))
/* If the client has no timeout, or if the server not ready yet, and we
* know for sure that it can expire, then it's cleaner to disable the
* timeout on the client side so that too low values cannot make the
@@ -2172,7 +2172,7 @@
*/
tv_eternity(&req->rex);
else
- tv_add(&req->rex, &now, &t->fe->clitimeout);
+ tv_add(&req->rex, &now, &t->fe->timeout.client);
}
}
@@ -2186,7 +2186,7 @@
/* buffer not empty */
if (EV_FD_COND_S(t->cli_fd, DIR_WR)) {
/* restart writing */
- if (tv_add_ifset(&rep->wex, &now, &t->fe->clitimeout)) {
+ if (tv_add_ifset(&rep->wex, &now, &t->fe->timeout.client)) {
/* FIXME: to prevent the client from expiring read timeouts during writes,
* we refresh it. */
req->rex = rep->wex;
@@ -2258,7 +2258,7 @@
/* buffer not empty */
if (EV_FD_COND_S(t->cli_fd, DIR_WR)) {
/* restart writing */
- if (!tv_add_ifset(&rep->wex, &now, &t->fe->clitimeout))
+ if (!tv_add_ifset(&rep->wex, &now, &t->fe->timeout.client))
tv_eternity(&rep->wex);
}
}
@@ -2318,7 +2318,7 @@
} else {
/* there's still some space in the buffer */
if (EV_FD_COND_S(t->cli_fd, DIR_RD)) {
- if (!tv_add_ifset(&req->rex, &now, &t->fe->clitimeout))
+ if (!tv_add_ifset(&req->rex, &now, &t->fe->timeout.client))
tv_eternity(&req->rex);
//fprintf(stderr,"%p:%s(%d), c=%d, s=%d\n", t, __FUNCTION__, __LINE__, t->cli_state, t->cli_state);
}
@@ -2357,14 +2357,14 @@
#if 0
fprintf(stderr,"%s:%d fe->clito=%d.%d, fe->conto=%d.%d, fe->srvto=%d.%d\n",
__FUNCTION__, __LINE__,
- t->fe->clitimeout.tv_sec, t->fe->clitimeout.tv_usec,
- t->fe->contimeout.tv_sec, t->fe->contimeout.tv_usec,
- t->fe->srvtimeout.tv_sec, t->fe->srvtimeout.tv_usec);
+ t->fe->timeout.client.tv_sec, t->fe->timeout.client.tv_usec,
+ t->fe->timeout.connect.tv_sec, t->fe->timeout.connect.tv_usec,
+ t->fe->timeout.server.tv_sec, t->fe->timeout.server.tv_usec);
fprintf(stderr,"%s:%d be->clito=%d.%d, be->conto=%d.%d, be->srvto=%d.%d\n",
__FUNCTION__, __LINE__,
- t->be->clitimeout.tv_sec, t->be->clitimeout.tv_usec,
- t->be->contimeout.tv_sec, t->be->contimeout.tv_usec,
- t->be->srvtimeout.tv_sec, t->be->srvtimeout.tv_usec);
+ t->be->timeout.client.tv_sec, t->be->timeout.client.tv_usec,
+ t->be->timeout.connect.tv_sec, t->be->timeout.connect.tv_usec,
+ t->be->timeout.server.tv_sec, t->be->timeout.server.tv_usec);
fprintf(stderr,"%s:%d req->cto=%d.%d, req->rto=%d.%d, req->wto=%d.%d\n",
__FUNCTION__, __LINE__,
@@ -2543,7 +2543,7 @@
tv_eternity(&req->wex);
} else /* need the right to write */ {
EV_FD_SET(t->srv_fd, DIR_WR);
- if (tv_add_ifset(&req->wex, &now, &t->be->srvtimeout)) {
+ if (tv_add_ifset(&req->wex, &now, &t->be->timeout.server)) {
/* FIXME: to prevent the server from expiring read timeouts during writes,
* we refresh it. */
rep->rex = req->wex;
@@ -2554,7 +2554,7 @@
if (t->be->mode == PR_MODE_TCP) { /* let's allow immediate data connection in this case */
EV_FD_SET(t->srv_fd, DIR_RD);
- if (!tv_add_ifset(&rep->rex, &now, &t->be->srvtimeout))
+ if (!tv_add_ifset(&rep->rex, &now, &t->be->timeout.server))
tv_eternity(&rep->rex);
t->srv_state = SV_STDATA;
@@ -2641,7 +2641,7 @@
* full. We cannot loop here since stream_sock_read will disable it only if
* rep->l == rlim-data
*/
- if (!tv_add_ifset(&rep->rex, &now, &t->be->srvtimeout))
+ if (!tv_add_ifset(&rep->rex, &now, &t->be->timeout.server))
tv_eternity(&rep->rex);
}
@@ -2746,7 +2746,7 @@
/* We must ensure that the read part is still
* alive when switching to shutw */
EV_FD_SET(t->srv_fd, DIR_RD);
- tv_add_ifset(&rep->rex, &now, &t->be->srvtimeout);
+ tv_add_ifset(&rep->rex, &now, &t->be->timeout.server);
shutdown(t->srv_fd, SHUT_WR);
t->srv_state = SV_STSHUTW;
@@ -2766,7 +2766,7 @@
/* We must ensure that the read part is still alive
* when switching to shutw */
EV_FD_SET(t->srv_fd, DIR_RD);
- tv_add_ifset(&rep->rex, &now, &t->be->srvtimeout);
+ tv_add_ifset(&rep->rex, &now, &t->be->timeout.server);
t->srv_state = SV_STSHUTW;
if (!(t->flags & SN_ERR_MASK))
@@ -2787,7 +2787,7 @@
else if (likely(req->l)) {
if (EV_FD_COND_S(t->srv_fd, DIR_WR)) {
/* restart writing */
- if (tv_add_ifset(&req->wex, &now, &t->be->srvtimeout)) {
+ if (tv_add_ifset(&req->wex, &now, &t->be->timeout.server)) {
/* FIXME: to prevent the server from expiring read timeouts during writes,
* we refresh it. */
rep->rex = req->wex;
@@ -3089,7 +3089,7 @@
/* We must ensure that the read part is still alive when switching
* to shutw */
EV_FD_SET(t->srv_fd, DIR_RD);
- tv_add_ifset(&rep->rex, &now, &t->be->srvtimeout);
+ tv_add_ifset(&rep->rex, &now, &t->be->timeout.server);
shutdown(t->srv_fd, SHUT_WR);
t->srv_state = SV_STSHUTW;
@@ -3159,7 +3159,7 @@
/* We must ensure that the read part is still alive when switching
* to shutw */
EV_FD_SET(t->srv_fd, DIR_RD);
- tv_add_ifset(&rep->rex, &now, &t->be->srvtimeout);
+ tv_add_ifset(&rep->rex, &now, &t->be->timeout.server);
t->srv_state = SV_STSHUTW;
return 1;
@@ -3183,7 +3183,7 @@
/* We must ensure that the read part is still alive when switching
* to shutw */
EV_FD_SET(t->srv_fd, DIR_RD);
- tv_add_ifset(&rep->rex, &now, &t->be->srvtimeout);
+ tv_add_ifset(&rep->rex, &now, &t->be->timeout.server);
t->srv_state = SV_STSHUTW;
if (!(t->flags & SN_ERR_MASK))
t->flags |= SN_ERR_SRVTO;
@@ -3202,7 +3202,7 @@
else { /* buffer not empty, there are still data to be transferred */
if (EV_FD_COND_S(t->srv_fd, DIR_WR)) {
/* restart writing */
- if (tv_add_ifset(&req->wex, &now, &t->be->srvtimeout)) {
+ if (tv_add_ifset(&req->wex, &now, &t->be->timeout.server)) {
/* FIXME: to prevent the server from expiring read timeouts during writes,
* we refresh it. */
rep->rex = req->wex;
@@ -3220,7 +3220,7 @@
}
else {
if (EV_FD_COND_S(t->srv_fd, DIR_RD)) {
- if (!tv_add_ifset(&rep->rex, &now, &t->be->srvtimeout))
+ if (!tv_add_ifset(&rep->rex, &now, &t->be->timeout.server))
tv_eternity(&rep->rex);
}
}
@@ -3296,7 +3296,7 @@
else { /* buffer not empty */
if (EV_FD_COND_S(t->srv_fd, DIR_WR)) {
/* restart writing */
- if (!tv_add_ifset(&req->wex, &now, &t->be->srvtimeout))
+ if (!tv_add_ifset(&req->wex, &now, &t->be->timeout.server))
tv_eternity(&req->wex);
}
}
@@ -3369,7 +3369,7 @@
}
else {
if (EV_FD_COND_S(t->srv_fd, DIR_RD)) {
- if (!tv_add_ifset(&rep->rex, &now, &t->be->srvtimeout))
+ if (!tv_add_ifset(&rep->rex, &now, &t->be->timeout.server))
tv_eternity(&rep->rex);
}
}
@@ -3490,8 +3490,8 @@
* frontend, and the beconn will be updated later.
*/
- t->rep->rto = t->req->wto = t->be->srvtimeout;
- t->req->cto = t->be->contimeout;
+ t->rep->rto = t->req->wto = t->be->timeout.server;
+ t->req->cto = t->be->timeout.connect;
t->conn_retries = t->be->conn_retries;
last_hdr = 1;
break;
@@ -3611,8 +3611,8 @@
* frontend, and the beconn will be updated later.
*/
- t->rep->rto = t->req->wto = t->be->srvtimeout;
- t->req->cto = t->be->contimeout;
+ t->rep->rto = t->req->wto = t->be->timeout.server;
+ t->req->cto = t->be->timeout.connect;
t->conn_retries = t->be->conn_retries;
done = 1;
break;
@@ -4009,7 +4009,7 @@
}/* end while(srv) */
}/* end else if server == NULL */
- tv_add(&asession_temp->expire, &now, &t->be->appsession_timeout);
+ tv_add(&asession_temp->expire, &now, &t->be->timeout.appsession);
}/* end if ((t->proxy->appsession_name != NULL) ... */
}
@@ -4463,7 +4463,7 @@
if (asession_temp->serverid[0] == '\0')
memcpy(asession_temp->serverid, t->srv->id, server_id_len);
- tv_add(&asession_temp->expire, &now, &t->be->appsession_timeout);
+ tv_add(&asession_temp->expire, &now, &t->be->timeout.appsession);
#if defined(DEBUG_HASH)
appsession_hash_dump(&(t->be->htbl_proxy));
@@ -4625,7 +4625,7 @@
pool_free2(apools.sessid, local_asession.sessid);
}
- tv_add(&asession_temp->expire, &now, &t->be->appsession_timeout);
+ tv_add(&asession_temp->expire, &now, &t->be->timeout.appsession);
asession_temp->request_count++;
#if defined(DEBUG_HASH)
diff --git a/src/proxy.c b/src/proxy.c
index 8263964..1b12844 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -97,8 +97,8 @@
name = args[0];
if (!strcmp(args[0], "client") || !strcmp(args[0], "clitimeout")) {
name = "client";
- tv = &proxy->clitimeout;
- td = &defpx->clitimeout;
+ tv = &proxy->timeout.client;
+ td = &defpx->timeout.client;
cap = PR_CAP_FE;
} else if (!strcmp(args[0], "tarpit")) {
tv = &proxy->timeout.tarpit;
@@ -106,17 +106,17 @@
cap = PR_CAP_FE;
} else if (!strcmp(args[0], "server") || !strcmp(args[0], "srvtimeout")) {
name = "server";
- tv = &proxy->srvtimeout;
- td = &defpx->srvtimeout;
+ tv = &proxy->timeout.server;
+ td = &defpx->timeout.server;
cap = PR_CAP_BE;
} else if (!strcmp(args[0], "connect") || !strcmp(args[0], "contimeout")) {
name = "connect";
- tv = &proxy->contimeout;
- td = &defpx->contimeout;
+ tv = &proxy->timeout.connect;
+ td = &defpx->timeout.connect;
cap = PR_CAP_BE;
} else if (!strcmp(args[0], "appsession")) {
- tv = &proxy->appsession_timeout;
- td = &defpx->appsession_timeout;
+ tv = &proxy->timeout.appsession;
+ td = &defpx->timeout.appsession;
cap = PR_CAP_BE;
} else if (!strcmp(args[0], "queue")) {
tv = &proxy->timeout.queue;