[master] d1f1a6d Gently shuffle things around a bit.
Poul-Henning Kamp
phk at FreeBSD.org
Tue Feb 25 12:33:25 CET 2014
commit d1f1a6dd90d9f73ca33d6a76b42be7e3a9431ea0
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Fri Feb 21 09:00:16 2014 +0000
Gently shuffle things around a bit.
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index eeda901..1471a64 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -234,6 +234,8 @@ EXP_Rearm(struct object *o, double now, double ttl, double grace, double keep)
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
assert(oc->refcnt > 0);
+ AN(oc->flags & OC_F_EXP);
+
if (!isnan(ttl))
o->exp.ttl = now + ttl - o->exp.t_origin;
if (!isnan(grace))
@@ -253,7 +255,6 @@ EXP_Rearm(struct object *o, double now, double ttl, double grace, double keep)
CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
Lck_Lock(&lru->mtx);
- AN(oc->flags & OC_F_EXP);
if (!isnan(now) && when <= now)
oc->flags |= OC_F_DYING;
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 4e4b229..cdea235 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -56,10 +56,11 @@ vbf_release_req(struct busyobj *bo)
}
/*--------------------------------------------------------------------
+ * Turn the beresp into a obj
*/
static int
-vbf_bereq2obj(struct worker *wrk, struct busyobj *bo)
+vbf_beresp2obj(struct worker *wrk, struct busyobj *bo)
{
unsigned l;
char *b;
@@ -157,8 +158,6 @@ vbf_bereq2obj(struct worker *wrk, struct busyobj *bo)
else
obj->last_modified = floor(bo->exp.t_origin);
- assert(WRW_IsReleased(wrk));
-
return (0);
}
@@ -302,16 +301,16 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo)
i = V1F_fetch_hdr(wrk, bo, bo->req);
}
- if (bo->do_pass && bo->req != NULL)
- vbf_release_req(bo); /* XXX : retry ?? */
-
- AZ(bo->req);
-
if (i) {
AZ(bo->vbc);
return (F_STP_ERROR);
}
+ if (bo->do_pass && bo->req != NULL)
+ vbf_release_req(bo); /* XXX : retry ?? */
+
+ AZ(bo->req);
+
AN(bo->vbc);
http_VSL_log(bo->beresp);
@@ -463,13 +462,15 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
if (bo->htc.body_status == BS_NONE)
bo->do_stream = 0;
- if (vbf_bereq2obj(wrk, bo)) {
+ if (vbf_beresp2obj(wrk, bo)) {
bo->stats = NULL;
(void)VFP_Error(bo, "Could not get storage");
VDI_CloseFd(&bo->vbc);
return (F_STP_DONE);
}
+ assert(WRW_IsReleased(wrk));
+
obj = bo->fetch_obj;
/*
@@ -536,11 +537,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
if (!bo->do_stream && bo->state != BOS_FAILED)
HSH_Unbusy(&wrk->stats, obj->objcore);
- if (bo->state != BOS_FAILED && !(obj->objcore->flags & OC_F_PRIVATE)) {
- EXP_Insert(obj->objcore);
- AN(obj->objcore->ban);
- }
-
HSH_Complete(obj->objcore);
assert(bo->refcount >= 1);
@@ -615,10 +611,6 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
VBO_setstate(bo, BOS_FETCHING);
HSH_Unbusy(&wrk->stats, obj->objcore);
- if (!(obj->objcore->flags & OC_F_PRIVATE)) {
- EXP_Insert(obj->objcore);
- AN(obj->objcore->ban);
- }
st = NULL;
al = 0;
@@ -683,19 +675,17 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
xxxassert(wrk->handling == VCL_RET_DELIVER);
+ if (bo->req != NULL)
+ vbf_release_req(bo);
+
http_PrintfHeader(bo->beresp, "Content-Length: %jd", (intmax_t)0);
http_PrintfHeader(bo->beresp, "X-XXXPHK: yes");
- if (vbf_bereq2obj(wrk, bo)) {
+ if (vbf_beresp2obj(wrk, bo)) {
INCOMPL();
}
HSH_Unbusy(&wrk->stats, bo->fetch_obj->objcore);
-
- if (!(bo->fetch_obj->objcore->flags & OC_F_PRIVATE)) {
- EXP_Insert(bo->fetch_obj->objcore);
- AN(bo->fetch_obj->objcore->ban);
- }
VBO_setstate(bo, BOS_FINISHED);
HSH_Complete(bo->fetch_obj->objcore);
return (F_STP_DONE);
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index b7eba44..9d5f9d1 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -678,8 +678,12 @@ HSH_Unbusy(struct dstat *ds, struct objcore *oc)
if (oh->waitinglist != NULL)
hsh_rush(ds, oh);
Lck_Unlock(&oh->mtx);
- if (!(oc->flags & OC_F_PRIVATE))
+ if (!(oc->flags & OC_F_PRIVATE)) {
BAN_NewObjCore(oc);
+ EXP_Insert(oc);
+ AN(oc->flags & OC_F_EXP);
+ AN(oc->ban);
+ }
}
/*---------------------------------------------------------------------
More information about the varnish-commit
mailing list