Commit 99193208 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Use the time we get the content from the backend as the origin time of objects.

Before, the origin time for the objects was defined as the time we
received the full request from the client that initiated the
fetch. Now we use the time we received the response headers from the
backend.
parent d31fa839
......@@ -532,7 +532,6 @@ struct busyobj {
*/
unsigned refcount;
int retries;
double t_fetch;
struct req *req;
uint8_t *vary;
......@@ -1240,7 +1239,7 @@ int WS_Overflowed(const struct ws *ws);
void *WS_Printf(struct ws *ws, const char *fmt, ...) __printflike(2, 3);
/* rfc2616.c */
void RFC2616_Ttl(struct busyobj *);
void RFC2616_Ttl(struct busyobj *, double now);
enum body_status RFC2616_Body(struct busyobj *, struct dstat *);
unsigned RFC2616_Req_Gzip(const struct http *);
int RFC2616_Do_Cond(const struct req *sp);
......
......@@ -148,8 +148,6 @@ VBO_GetBusyObj(struct worker *wrk, const struct req *req)
bo->vcl = req->vcl;
VCL_Ref(bo->vcl);
bo->t_fetch = req->t_req;
assert(!isnan(bo->t_fetch) && bo->t_fetch != 0.);
bo->t_first = bo->t_prev = NAN;
return (bo);
......
......@@ -347,7 +347,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
* What does RFC2616 think about TTL ?
*/
EXP_Clr(&bo->exp);
RFC2616_Ttl(bo);
RFC2616_Ttl(bo, now);
/* private objects have negative TTL */
if (bo->fetch_objcore->flags & OC_F_PRIVATE)
......@@ -670,7 +670,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
HTTP_Setup(bo->beresp, bo->ws, bo->vsl, SLT_BerespMethod);
http_SetResp(bo->beresp, "HTTP/1.1", 503, "Backend fetch failed");
bo->exp.t_origin = VTIM_real();
bo->exp.t_origin = bo->t_prev;
bo->exp.ttl = 0;
bo->exp.grace = 0;
bo->exp.keep = 0;
......
......@@ -63,7 +63,7 @@
*/
void
RFC2616_Ttl(struct busyobj *bo)
RFC2616_Ttl(struct busyobj *bo, double now)
{
unsigned max_age, age;
double h_date, h_expires;
......@@ -76,8 +76,8 @@ RFC2616_Ttl(struct busyobj *bo)
hp = bo->beresp;
assert(bo->t_fetch != 0.0 && !isnan(bo->t_fetch));
expp->t_origin = bo->t_fetch;
assert(now != 0.0 && !isnan(now));
expp->t_origin = now;
expp->ttl = cache_param->default_ttl;
expp->grace = cache_param->default_grace;
......@@ -154,16 +154,16 @@ RFC2616_Ttl(struct busyobj *bo)
}
if (h_date == 0 ||
fabs(h_date - bo->t_fetch) < cache_param->clock_skew) {
fabs(h_date - now) < cache_param->clock_skew) {
/*
* If we have no Date: header or if it is
* sufficiently close to our clock we will
* trust Expires: relative to our own clock.
*/
if (h_expires < bo->t_fetch)
if (h_expires < now)
expp->ttl = 0;
else
expp->ttl = h_expires - bo->t_fetch;
expp->ttl = h_expires - now;
break;
} else {
/*
......@@ -179,7 +179,7 @@ RFC2616_Ttl(struct busyobj *bo)
/* calculated TTL, Our time, Date, Expires, max-age, age */
VSLb(bo->vsl, SLT_TTL,
"RFC %.0f %.0f %.0f %.0f %.0f %.0f %.0f %u",
expp->ttl, -1., -1., bo->t_fetch,
expp->ttl, -1., -1., now,
expp->t_origin, h_date, h_expires, max_age);
}
......
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