[master] ce3ca92 Fix a detail I didn't catch during code review:
Poul-Henning Kamp
phk at varnish-cache.org
Sun Feb 19 11:01:09 CET 2012
commit ce3ca9285b1987203674a4445e058ce30ac750b6
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sun Feb 19 09:59:59 2012 +0000
Fix a detail I didn't catch during code review:
When WRW is used to send stuff to the backend 'req->t_resp' is not
an appropriate base for the timeouts.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 3797047..7eb3372 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -889,7 +889,7 @@ int Pool_Task(struct pool *pp, struct pool_task *task, enum pool_how how);
int WRW_Error(const struct worker *w);
void WRW_Chunked(struct worker *w);
void WRW_EndChunk(struct worker *w);
-void WRW_Reserve(struct worker *w, int *fd);
+void WRW_Reserve(struct worker *w, int *fd, double t0);
unsigned WRW_Flush(struct worker *w);
unsigned WRW_FlushRelease(struct worker *w);
unsigned WRW_Write(struct worker *w, const void *ptr, int len);
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 2c4d3d0..00279c2 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -113,7 +113,7 @@ ved_include(struct sess *sp, const char *src, const char *host)
WS_Reset(sp->req->ws, sp_ws_wm);
WS_Reset(w->aws, wrk_ws_wm); /* XXX ? */
- WRW_Reserve(sp->wrk, &sp->fd);
+ WRW_Reserve(sp->wrk, &sp->fd, sp->req->t_resp);
if (sp->req->res_mode & RES_CHUNKED)
WRW_Chunked(sp->wrk);
}
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 48db272..adc5af3 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -424,7 +424,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
VDI_AddHostHeader(wrk->busyobj->bereq, vc);
(void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */
- WRW_Reserve(wrk, &vc->fd);
+ WRW_Reserve(wrk, &vc->fd, sp->t_req); /* XXX t_resp ? */
(void)http_Write(wrk, hp, 0); /* XXX: stats ? */
/* Deal with any message-body the request might have */
diff --git a/bin/varnishd/cache/cache_pipe.c b/bin/varnishd/cache/cache_pipe.c
index 6f1fbcb..688d87d 100644
--- a/bin/varnishd/cache/cache_pipe.c
+++ b/bin/varnishd/cache/cache_pipe.c
@@ -78,7 +78,7 @@ PipeSession(struct sess *sp)
sp->wrk->busyobj->vbc = vc; /* For panic dumping */
(void)VTCP_blocking(vc->fd);
- WRW_Reserve(w, &vc->fd);
+ WRW_Reserve(w, &vc->fd, sp->t_req);
sp->wrk->acct_tmp.hdrbytes +=
http_Write(w, sp->wrk->busyobj->bereq, 0);
diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index bbb648c..f1e0553 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -237,7 +237,7 @@ RES_WriteObj(struct sess *sp)
req = sp->req;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
- WRW_Reserve(sp->wrk, &sp->fd);
+ WRW_Reserve(sp->wrk, &sp->fd, sp->req->t_resp);
if (req->obj->response == 200 &&
req->http->conds &&
diff --git a/bin/varnishd/cache/cache_wrw.c b/bin/varnishd/cache/cache_wrw.c
index 3685bec..a8140f5 100644
--- a/bin/varnishd/cache/cache_wrw.c
+++ b/bin/varnishd/cache/cache_wrw.c
@@ -56,6 +56,7 @@ struct wrw {
ssize_t liov;
ssize_t cliov;
unsigned ciov; /* Chunked header marker */
+ double t0;
};
/*--------------------------------------------------------------------
@@ -69,7 +70,7 @@ WRW_Error(const struct worker *wrk)
}
void
-WRW_Reserve(struct worker *wrk, int *fd)
+WRW_Reserve(struct worker *wrk, int *fd, double t0)
{
struct wrw *wrw;
unsigned u;
@@ -93,6 +94,7 @@ WRW_Reserve(struct worker *wrk, int *fd)
wrw->liov = 0;
wrw->niov = 0;
wrw->wfd = fd;
+ wrw->t0 = t0;
wrk->wrw = wrw;
}
@@ -176,8 +178,7 @@ WRW_Flush(struct worker *wrk)
* counter to prevent slowlaris attacks
*/
- if (VTIM_real() - wrk->sp->req->t_resp >
- cache_param->send_timeout) {
+ if (VTIM_real() - wrw->t0 > cache_param->send_timeout) {
WSL(wrk->vsl, SLT_Debug, *wrw->wfd,
"Hit total send timeout, "
"wrote = %zd/%zd; not retrying",
More information about the varnish-commit
mailing list