Commit 8e8a8942 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Give busyobj its own "t_fetch" timestamp, (== req->t_req) and

only pass req to FetchHdr if we intend to send the body over.
parent c8c3d314
......@@ -501,6 +501,7 @@ struct busyobj {
* is recycled.
*/
unsigned refcount;
double t_fetch;
uint8_t *vary;
unsigned is_gzip;
......@@ -815,7 +816,7 @@ struct storage *FetchStorage(struct busyobj *, ssize_t sz);
int FetchError(struct busyobj *, const char *error);
int FetchError2(struct busyobj *, const char *error, const char *more);
int FetchHdr(struct worker *wrk, struct busyobj *bo, struct req *req,
int need_host_hdr, int sendbody);
int need_host_hdr);
void FetchBody(struct worker *w, void *bo);
void Fetch_Init(void);
......
......@@ -145,6 +145,8 @@ VBO_GetBusyObj(struct worker *wrk, struct req *req)
bo->vcl = req->vcl;
VCL_Ref(bo->vcl);
bo->t_fetch = req->t_req;
return (bo);
}
......
......@@ -358,7 +358,7 @@ fetch_iter_req_body(struct req *req, void *priv, void *ptr, size_t l)
int
FetchHdr(struct worker *wrk, struct busyobj *bo, struct req *req,
int need_host_hdr, int sendbody)
int need_host_hdr)
{
struct vbc *vc;
struct http *hp;
......@@ -368,15 +368,11 @@ FetchHdr(struct worker *wrk, struct busyobj *bo, struct req *req,
struct http_conn *htc;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_ORNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
htc = &bo->htc;
AN(req->director);
AZ(req->obj);
CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
AN(req->objcore->flags & OC_F_BUSY);
AN(bo->director);
hp = bo->bereq;
......@@ -398,18 +394,16 @@ FetchHdr(struct worker *wrk, struct busyobj *bo, struct req *req,
VDI_AddHostHeader(bo->bereq, vc);
(void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */
WRW_Reserve(wrk, &vc->fd, bo->vsl, req->t_req); /* XXX t_resp ? */
WRW_Reserve(wrk, &vc->fd, bo->vsl, bo->t_fetch);
(void)HTTP1_Write(wrk, hp, 0); /* XXX: stats ? */
/* Deal with any message-body the request might (still) have */
i = 0;
if (sendbody) {
if (req != NULL) {
i = HTTP1_IterateReqBody(req, fetch_iter_req_body, NULL);
if (req->req_body_status == REQ_BODY_DONE)
retry = -1;
} else {
i = HTTP1_DiscardReqBody(req);
}
if (WRW_FlushRelease(wrk) || i != 0) {
......
......@@ -371,8 +371,8 @@ cnt_fetch(struct worker *wrk, struct req *req)
req->acct_req.fetch++;
i = FetchHdr(wrk, bo, req, need_host_hdr,
req->objcore->objhead == NULL);
i = FetchHdr(wrk, bo, req->objcore->objhead == NULL ? req : NULL,
need_host_hdr);
/*
* If we recycle a backend connection, there is a finite chance
* that the backend closed it before we get a request to it.
......@@ -380,10 +380,13 @@ cnt_fetch(struct worker *wrk, struct req *req)
*/
if (i == 1) {
VSC_C_main->backend_retry++;
i = FetchHdr(wrk, bo, req, need_host_hdr,
req->objcore->objhead == NULL);
i = FetchHdr(wrk, bo,
req->objcore->objhead == NULL ? req : NULL, need_host_hdr);
}
if (req->objcore->objhead != NULL)
(void)HTTP1_DiscardReqBody(req); // XXX
if (i) {
wrk->handling = VCL_RET_ERROR;
req->err_code = 503;
......
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