Commit ce3ca928 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

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.
parent 33a22425
......@@ -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);
......
......@@ -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);
}
......
......@@ -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 */
......
......@@ -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);
......
......@@ -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 &&
......
......@@ -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",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment