[experimental-ims] bbc0bc4 Start preparing hash-lookup for streaming objects
Poul-Henning Kamp
phk at FreeBSD.org
Thu Dec 18 10:27:41 CET 2014
commit bbc0bc445732fd451286f5bcce172fe7ffd4aa3c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Mar 15 08:11:20 2012 +0000
Start preparing hash-lookup for streaming objects
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 4ad05ff..c9498b6 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -654,6 +654,8 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req)
AZ(HSH_Deref(&wrk->stats, req->objcore, NULL));
req->objcore = NULL;
}
+ assert(bo->refcount == 2);
+ VBO_DerefBusyObj(wrk, &bo);
VBO_DerefBusyObj(wrk, &req->busyobj);
req->director = NULL;
req->storage_hint = NULL;
@@ -906,8 +908,7 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req)
bo->fetch_task.func = FetchBody;
bo->fetch_task.priv = bo;
- /* Gain a reference for FetchBody() */
- VBO_RefBusyObj(bo);
+ assert(bo->refcount == 2); /* one for each thread */
if (Pool_Task(wrk->pool, &bo->fetch_task, POOL_NO_QUEUE))
FetchBody(wrk, bo);
@@ -1264,6 +1265,7 @@ cnt_pass(struct sess *sp, struct worker *wrk, struct req *req)
req->busyobj = VBO_GetBusyObj(wrk);
req->busyobj->vsl->wid = sp->vsl_id;
+ req->busyobj->refcount = 2;
http_Setup(req->busyobj->bereq, req->busyobj->ws, req->busyobj->vsl);
http_FilterReq(sp, HTTPH_R_PASS);
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 06d7e50..60bf207 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -58,7 +58,9 @@
#include "cache.h"
+
#include "hash/hash_slinger.h"
+#include "vmb.h"
#include "vsha256.h"
static const struct hash_slinger *hash;
@@ -326,15 +328,17 @@ HSH_Lookup(struct sess *sp)
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
assert(oc->objhead == oh);
- if (oc->flags & OC_F_NOTYET)
+ /* We ignore failed oc's, they're no use, ever. */
+ if (oc->flags & OC_F_FAILED)
continue;
- if (oc->flags & OC_F_BUSY) {
+ if (oc->flags & (OC_F_BUSY | OC_F_NOTYET)) {
CHECK_OBJ_NOTNULL(oc->busyobj, BUSYOBJ_MAGIC);
if (req->hash_ignore_busy)
continue;
- if (oc->busyobj->vary != NULL &&
+ if (!(oc->flags & OC_F_NOTYET) &&
+ oc->busyobj->vary != NULL &&
!VRY_Match(req, oc->busyobj->vary))
continue;
@@ -440,15 +444,17 @@ HSH_Lookup(struct sess *sp)
AZ(req->busyobj);
req->busyobj = VBO_GetBusyObj(wrk);
+ oc->busyobj = req->busyobj;
req->busyobj->vsl->wid = sp->vsl_id;
+ req->busyobj->refcount = 2; /* One for headers, one for body*/
VRY_Validate(req->vary_b);
if (req->vary_l != NULL)
req->busyobj->vary = req->vary_b;
else
req->busyobj->vary = NULL;
- oc->busyobj = req->busyobj;
+ VMB();
oc->flags &= ~OC_F_NOTYET;
return (oc);
}
More information about the varnish-commit
mailing list