[master] e294481 Add an explicit OC_F_INCOMPLETE flag to limit the amount of code that needs to know about oc->busyobj semantics
Poul-Henning Kamp
phk at FreeBSD.org
Mon Dec 14 21:34:27 CET 2015
commit e29448145caf8d2df363912871c01a079b46bc2d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Dec 14 20:33:50 2015 +0000
Add an explicit OC_F_INCOMPLETE flag to limit the amount of code
that needs to know about oc->busyobj semantics
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 7f51968..918d620 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -404,6 +404,7 @@ struct objcore {
uint16_t flags;
#define OC_F_BUSY (1<<1)
#define OC_F_PASS (1<<2)
+#define OC_F_INCOMPLETE (1<<3)
#define OC_F_PRIVATE (1<<8)
#define OC_F_FAILED (1<<9)
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index 65236b7..5c27d07 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -231,7 +231,7 @@ EXP_Touch(struct objcore *oc, double now)
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
- if (oc->busyobj != NULL)
+ if (oc->flags & OC_F_INCOMPLETE)
return;
if (now - oc->last_lru < cache_param->lru_interval)
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index aa516bf..917109a 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -307,8 +307,8 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv,
http_Unset(req->resp, H_Content_Encoding);
req->resp_len = -1;
- if (req->objcore->busyobj != NULL)
- return (0); /* Incomplete, no idea about length */
+ if (req->objcore->flags & OC_F_INCOMPLETE)
+ return (0); /* No idea about length */
p = ObjGetattr(req->wrk, req->objcore, OA_GZIPBITS, &dl);
if (p == NULL || dl != 32)
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index d93320d..85da4f0 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -75,7 +75,7 @@ hsh_NewObjCore(struct worker *wrk)
ALLOC_OBJ(oc, OBJCORE_MAGIC);
XXXAN(oc);
wrk->stats->n_objectcore++;
- oc->flags |= OC_F_BUSY;
+ oc->flags |= OC_F_BUSY | OC_F_INCOMPLETE;
return (oc);
}
@@ -650,6 +650,7 @@ HSH_Fail(struct objcore *oc)
Lck_Lock(&oh->mtx);
oc->flags |= OC_F_FAILED;
+ oc->flags &= ~OC_F_INCOMPLETE;
oc->busyobj = NULL;
Lck_Unlock(&oh->mtx);
}
@@ -669,6 +670,7 @@ HSH_Complete(struct objcore *oc)
Lck_Lock(&oh->mtx);
oc->busyobj = NULL;
+ oc->flags &= ~OC_F_INCOMPLETE;
Lck_Unlock(&oh->mtx);
}
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 5dd890e..b76c069 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -670,7 +670,7 @@ VRT_r_resp_is_streaming(VRT_CTX)
if (ctx->req->objcore == NULL)
return (0); /* When called from vcl_synth */
CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC);
- return (ctx->req->objcore->busyobj != NULL ? 1 : 0);
+ return (ctx->req->objcore->flags & OC_F_INCOMPLETE ? 1 : 0);
}
/*--------------------------------------------------------------------*/
More information about the varnish-commit
mailing list