[master] 9d7bb01 Use private objcore's for req.body to reduce number of special cases.
Poul-Henning Kamp
phk at FreeBSD.org
Thu Nov 26 00:58:04 CET 2015
commit 9d7bb01f817f77eb69498f70dd2e24f0e2741dbb
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Nov 25 23:57:36 2015 +0000
Use private objcore's for req.body to reduce number of special cases.
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 662048d..b084680 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -964,6 +964,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+ AN(oc->flags & OC_F_BUSY);
CHECK_OBJ_ORNULL(oldoc, OBJCORE_MAGIC);
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index f841c53..d93320d 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -67,8 +67,8 @@ static struct objhead *private_oh;
/*---------------------------------------------------------------------*/
-struct objcore *
-HSH_NewObjCore(struct worker *wrk)
+static struct objcore *
+hsh_NewObjCore(struct worker *wrk)
{
struct objcore *oc;
@@ -104,7 +104,7 @@ hsh_prealloc(struct worker *wrk)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
if (wrk->nobjcore == NULL)
- wrk->nobjcore = HSH_NewObjCore(wrk);
+ wrk->nobjcore = hsh_NewObjCore(wrk);
CHECK_OBJ_NOTNULL(wrk->nobjcore, OBJCORE_MAGIC);
if (wrk->nobjhead == NULL) {
@@ -135,11 +135,11 @@ HSH_Private(struct worker *wrk)
CHECK_OBJ_NOTNULL(private_oh, OBJHEAD_MAGIC);
- oc = HSH_NewObjCore(wrk);
+ oc = hsh_NewObjCore(wrk);
AN(oc);
oc->refcnt = 1;
oc->objhead = private_oh;
- oc->flags |= OC_F_PRIVATE;
+ oc->flags |= OC_F_PRIVATE | OC_F_BUSY;
Lck_Lock(&private_oh->mtx);
VTAILQ_INSERT_TAIL(&private_oh->objcs, oc, list);
private_oh->refcnt++;
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index 7413329..06785d3 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -288,6 +288,7 @@ ObjGetSpace(struct worker *wrk, struct objcore *oc, ssize_t *sz, uint8_t **ptr)
VTAILQ_INSERT_TAIL(&o->list, st, list);
Lck_Unlock(&oc->busyobj->mtx);
} else {
+ AN(oc->flags & (OC_F_PRIVATE));
VTAILQ_INSERT_TAIL(&o->list, st, list);
}
*sz = st->space - st->len;
diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c
index 585a63e..ccd7a6a 100644
--- a/bin/varnishd/cache/cache_req_body.c
+++ b/bin/varnishd/cache/cache_req_body.c
@@ -178,11 +178,8 @@ VRB_Free(struct req *req)
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
- if (req->body_oc != NULL) {
- ObjFreeObj(req->wrk, req->body_oc);
- FREE_OBJ(req->body_oc);
- req->body_oc = NULL;
- }
+ if (req->body_oc != NULL)
+ AZ(HSH_DerefObjCore(req->wrk, &req->body_oc));
}
/*----------------------------------------------------------------------
@@ -228,7 +225,7 @@ VRB_Cache(struct req *req, ssize_t maxsize)
return (-1);
}
- req->body_oc = HSH_NewObjCore(req->wrk);
+ req->body_oc = HSH_Private(req->wrk);
AN(req->body_oc);
XXXAN(STV_NewObject(req->body_oc, req->wrk, TRANSIENT_STORAGE, 8));
diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h
index f8d7a08..736f1b5 100644
--- a/bin/varnishd/hash/hash_slinger.h
+++ b/bin/varnishd/hash/hash_slinger.h
@@ -74,7 +74,6 @@ void HSH_Purge(struct worker *, struct objhead *, double ttl, double grace,
void HSH_config(const char *h_arg);
struct busyobj *HSH_RefBusy(const struct objcore *oc);
struct objcore *HSH_Private(struct worker *wrk);
-struct objcore *HSH_NewObjCore(struct worker *wrk);
#ifdef VARNISH_CACHE_CHILD
More information about the varnish-commit
mailing list