[master] 14b7e6e Move t_req from sp to req, and give sp a t_rx for the handover from acceptor to center.
Poul-Henning Kamp
phk at varnish-cache.org
Thu Jun 14 10:28:39 CEST 2012
commit 14b7e6e94ab1acbfa1768d96fa52633b163a64e9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Jun 14 08:27:57 2012 +0000
Move t_req from sp to req, and give sp a t_rx for the handover from
acceptor to center.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index cdd85be..4319b70 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -590,6 +590,7 @@ struct req {
uint64_t req_bodybytes;
char *ws_req; /* WS above request data */
+ double t_req;
double t_resp;
struct http_conn htc[1];
@@ -673,7 +674,7 @@ struct sess {
/* Timestamps, all on TIM_real() timescale */
double t_open; /* fd accepted */
double t_idle; /* fd accepted or resp sent */
- double t_req;
+ double t_rx;
#if defined(HAVE_EPOLL_CTL)
struct epoll_event ev;
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 6f2ce1f..fb116bf 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -271,7 +271,7 @@ vbe_Healthy(const struct vdi_simple *vs, const struct sess *sp)
if (threshold == 0 || VTAILQ_EMPTY(&backend->troublelist))
return (1);
- now = sp->t_req;
+ now = sp->req->t_req;
old = NULL;
retval = 1;
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 32f67e5..d063466 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -83,11 +83,6 @@ static unsigned xids;
* WAIT
* Collect the request from the client.
*
- * We "abuse" sp->t_req a bit here: On input it means "request reception
- * started at xxx" and is used to trigger timeouts. On return it means
- * "we had full request headers by xxx" and is used for reporting by
- * later steps.
- *
DOT subgraph xcluster_wait {
DOT wait [
DOT shape=box
@@ -112,6 +107,8 @@ cnt_wait(struct sess *sp, struct worker *wrk, struct req *req)
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+ assert(!isnan(sp->t_rx));
+
if (req == NULL) {
SES_GetReq(sp);
req = sp->req;
@@ -128,9 +125,9 @@ cnt_wait(struct sess *sp, struct worker *wrk, struct req *req)
AZ(req->obj);
AZ(req->esi_level);
assert(req->xid == 0);
+ req->t_req = sp->t_rx;
req->t_resp = NAN;
- assert(!isnan(sp->t_req));
tmo = (int)(1e3 * cache_param->timeout_linger);
while (1) {
pfd[0].fd = sp->fd;
@@ -145,7 +142,7 @@ cnt_wait(struct sess *sp, struct worker *wrk, struct req *req)
i = HTC_Complete(req->htc);
if (i == 1) {
/* Got it, run with it */
- sp->t_req = now;
+ req->t_req = now;
sp->step = STP_START;
return (0);
} else if (i == -1) {
@@ -164,7 +161,7 @@ cnt_wait(struct sess *sp, struct worker *wrk, struct req *req)
when = sp->t_idle + cache_param->timeout_linger;
tmo = (int)(1e3 * (when - now));
if (when < now || tmo == 0) {
- sp->t_req = NAN;
+ sp->t_rx = NAN;
wrk->stats.sess_herd++;
SES_Charge(sp);
SES_ReleaseReq(sp);
@@ -173,7 +170,7 @@ cnt_wait(struct sess *sp, struct worker *wrk, struct req *req)
}
} else {
/* Working on it */
- when = sp->t_req + cache_param->timeout_req;
+ when = sp->t_rx + cache_param->timeout_req;
tmo = (int)(1e3 * (when - now));
if (when < now || tmo == 0) {
why = "req timeout";
@@ -404,9 +401,9 @@ cnt_done(struct sess *sp, struct worker *wrk, struct req *req)
if (req->xid == 0) {
req->t_resp = sp->t_idle;
} else {
- dp = req->t_resp - sp->t_req;
+ dp = req->t_resp - req->t_req;
da = sp->t_idle - req->t_resp;
- dh = sp->t_req - sp->t_open;
+ dh = req->t_req - sp->t_open;
/* XXX: Add StatReq == StatSess */
/* XXX: Workaround for pipe */
if (sp->fd >= 0) {
@@ -414,12 +411,12 @@ cnt_done(struct sess *sp, struct worker *wrk, struct req *req)
(uintmax_t)req->req_bodybytes);
}
VSLb(sp->req->vsl, SLT_ReqEnd, "%u %.9f %.9f %.9f %.9f %.9f",
- req->xid, sp->t_req, sp->t_idle, dh, dp, da);
+ req->xid, req->t_req, sp->t_idle, dh, dp, da);
}
req->xid = 0;
VSL_Flush(sp->req->vsl, 0);
- sp->t_req = NAN;
+ req->t_req = NAN;
req->t_resp = NAN;
req->req_bodybytes = 0;
@@ -448,12 +445,14 @@ cnt_done(struct sess *sp, struct worker *wrk, struct req *req)
WS_Reset(req->ws, NULL);
WS_Reset(wrk->aws, NULL);
- sp->t_req = sp->t_idle;
i = HTC_Reinit(req->htc);
if (i == 1) {
+ req->t_req = sp->t_idle;
wrk->stats.sess_pipeline++;
sp->step = STP_START;
} else {
+ sp->t_rx = sp->t_idle;
+ req->t_req = NAN;
if (Tlen(req->htc->rxbuf))
wrk->stats.sess_readahead++;
sp->step = STP_WAIT;
@@ -510,7 +509,7 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req)
}
CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);
req->obj->xid = req->xid;
- req->obj->exp.entered = sp->t_req;
+ req->obj->exp.entered = req->t_req;
h = req->obj->http;
@@ -972,7 +971,7 @@ cnt_first(struct sess *sp, struct worker *wrk)
wrk->acct_tmp.sess++;
- sp->t_req = sp->t_open;
+ sp->t_rx = sp->t_open;
sp->t_idle = sp->t_open;
sp->step = STP_WAIT;
return (0);
@@ -1495,7 +1494,7 @@ cnt_start(struct sess *sp, struct worker *wrk, struct req *req)
AZ(req->obj);
AZ(req->vcl);
AZ(req->esi_level);
- assert(!isnan(sp->t_req));
+ assert(!isnan(req->t_req));
assert(req->sp == sp);
/* Update stats of various sorts */
diff --git a/bin/varnishd/cache/cache_dir_dns.c b/bin/varnishd/cache/cache_dir_dns.c
index ee411dc..068c2b9 100644
--- a/bin/varnishd/cache/cache_dir_dns.c
+++ b/bin/varnishd/cache/cache_dir_dns.c
@@ -203,7 +203,7 @@ vdi_dns_cache_has(const struct sess *sp,
struct vdi_dns_hostgroup *hostgr2;
VTAILQ_FOREACH_SAFE(hostgr, &vs->cachelist, list, hostgr2) {
CHECK_OBJ_NOTNULL(hostgr, VDI_DNSDIR_MAGIC);
- if (hostgr->ttl <= sp->t_req) {
+ if (hostgr->ttl <= sp->req->t_req) {
if (rwlock)
vdi_dns_pop_cache(vs, hostgr);
return (0);
@@ -233,7 +233,7 @@ vdi_dns_cache_list_add(const struct sess *sp,
}
CHECK_OBJ_NOTNULL(new, VDI_DNSDIR_MAGIC);
assert(new->hostname != 0);
- new->ttl = sp->t_req + vs->ttl;
+ new->ttl = sp->req->t_req + vs->ttl;
VTAILQ_INSERT_HEAD(&vs->cachelist, new, list);
vs->ncachelist++;
}
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index bc0e52c..7ccba0a 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -476,7 +476,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
VDI_AddHostHeader(bo->bereq, vc);
(void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */
- WRW_Reserve(wrk, &vc->fd, bo->vsl, sp->t_req); /* XXX t_resp ? */
+ WRW_Reserve(wrk, &vc->fd, bo->vsl, req->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_hash.c b/bin/varnishd/cache/cache_hash.c
index bc94352..79efc69 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -363,14 +363,14 @@ HSH_Lookup(struct sess *sp)
continue;
/* If still valid, use it */
- if (EXP_Ttl(req, o) >= sp->t_req)
+ if (EXP_Ttl(req, o) >= req->t_req)
break;
/*
* Remember any matching objects inside their grace period
* and if there are several, use the least expired one.
*/
- if (EXP_Grace(req, o) >= sp->t_req) {
+ if (EXP_Grace(req, o) >= req->t_req) {
if (grace_oc == NULL ||
grace_ttl < o->exp.entered + o->exp.ttl) {
grace_oc = oc;
diff --git a/bin/varnishd/cache/cache_pipe.c b/bin/varnishd/cache/cache_pipe.c
index c486a23..fda21f4 100644
--- a/bin/varnishd/cache/cache_pipe.c
+++ b/bin/varnishd/cache/cache_pipe.c
@@ -80,7 +80,7 @@ PipeSession(struct sess *sp)
bo->vbc = vc; /* For panic dumping */
(void)VTCP_blocking(vc->fd);
- WRW_Reserve(wrk, &vc->fd, bo->vsl, sp->t_req);
+ WRW_Reserve(wrk, &vc->fd, bo->vsl, sp->req->t_req);
sp->wrk->acct_tmp.hdrbytes +=
http_Write(wrk, bo->bereq, 0);
diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c
index 60bb6a9..ece413d 100644
--- a/bin/varnishd/cache/cache_rfc2616.c
+++ b/bin/varnishd/cache/cache_rfc2616.c
@@ -323,7 +323,7 @@ RFC2616_Do_Cond(const struct sess *sp)
if (!sp->req->obj->last_modified)
return (0);
ims = VTIM_parse(p);
- if (ims > sp->t_req) /* [RFC2616 14.25] */
+ if (ims > sp->req->t_req) /* [RFC2616 14.25] */
return (0);
if (sp->req->obj->last_modified > ims)
return (0);
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index e3ec28a..f236389 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -90,7 +90,7 @@ ses_setup(struct sess *sp)
sp->sockaddr.ss_family = sp->mysockaddr.ss_family = PF_UNSPEC;
sp->t_open = NAN;
sp->t_idle = NAN;
- sp->t_req = NAN;
+ sp->t_rx = NAN;
}
/*--------------------------------------------------------------------
@@ -208,7 +208,7 @@ SES_Handle(struct sess *sp, double now)
{
sp->step = STP_WAIT;
- sp->t_req = now;
+ sp->t_rx = now;
(void)SES_Schedule(sp);
}
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 37fb7a0..7a88447 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -153,7 +153,7 @@ VRT_l_beresp_saintmode(const struct sess *sp, double a)
ALLOC_OBJ(new, TROUBLE_MAGIC);
AN(new);
memcpy(new->digest, sp->req->digest, sizeof new->digest);
- new->timeout = sp->t_req + a;
+ new->timeout = sp->req->t_req + a;
/* Insert the new item on the list before the first item with a
* timeout at a later date (ie: sort by which entry will time out
@@ -396,8 +396,8 @@ static void
vrt_wsp_exp(const struct sess *sp, unsigned xid, const struct exp *e)
{
VSLb(sp->req->vsl, SLT_TTL, "%u VCL %.0f %.0f %.0f %.0f %.0f",
- xid, e->ttl - (sp->t_req - e->entered), e->grace, e->keep,
- sp->t_req, e->age + (sp->t_req - e->entered));
+ xid, e->ttl - (sp->req->t_req - e->entered), e->grace, e->keep,
+ sp->req->t_req, e->age + (sp->req->t_req - e->entered));
}
VRT_DO_EXP(req, sp->req->exp, ttl, 0, )
@@ -407,7 +407,8 @@ VRT_DO_EXP(req, sp->req->exp, keep, 0, )
VRT_DO_EXP(obj, sp->req->obj->exp, grace, 0,
EXP_Rearm(sp->req->obj);
vrt_wsp_exp(sp, sp->req->obj->xid, &sp->req->obj->exp);)
-VRT_DO_EXP(obj, sp->req->obj->exp, ttl, (sp->t_req - sp->req->obj->exp.entered),
+VRT_DO_EXP(obj, sp->req->obj->exp, ttl,
+ (sp->req->t_req - sp->req->obj->exp.entered),
EXP_Rearm(sp->req->obj);
vrt_wsp_exp(sp, sp->req->obj->xid, &sp->req->obj->exp);)
VRT_DO_EXP(obj, sp->req->obj->exp, keep, 0,
More information about the varnish-commit
mailing list