[master] 5eeabe7 BAN_CheckObject() can pretty far with a struct objcore, so postpone the object instantiation until needed.
Poul-Henning Kamp
phk at FreeBSD.org
Wed Jul 16 11:59:11 CEST 2014
commit 5eeabe7d0313b2b383c7dea8873663ff244da5ed
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Jul 16 09:58:30 2014 +0000
BAN_CheckObject() can pretty far with a struct objcore, so postpone
the object instantiation until needed.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index cc91eae..cded88d 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -776,7 +776,7 @@ void BAN_Init(void);
void BAN_Shutdown(void);
void BAN_NewObjCore(struct objcore *oc);
void BAN_DestroyObj(struct objcore *oc);
-int BAN_CheckObject(const struct object *o, struct req *sp);
+int BAN_CheckObject(struct worker *, struct objcore *, struct req *);
void BAN_Reload(const uint8_t *ban, unsigned len);
struct ban *BAN_TailRef(void);
void BAN_Compile(void);
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 7388acb..e6c3ced 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -899,19 +899,20 @@ ban_evaluate(const uint8_t *bs, const struct http *objhttp,
* 1 Ban matched, object removed from ban list.
*/
-static int
-ban_check_object(const struct object *o, struct vsl_log *vsl,
- const struct http *req_http)
+int
+BAN_CheckObject(struct worker *wrk, struct objcore *oc, struct req *req)
{
struct ban *b;
- struct objcore *oc;
+ struct vsl_log *vsl;
+ struct object *o;
struct ban * volatile b0;
unsigned tests;
- CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- CHECK_OBJ_NOTNULL(req_http, HTTP_MAGIC);
- oc = o->objcore;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+ CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+
+ vsl = req->vsl;
+
CHECK_OBJ_NOTNULL(oc->ban, BAN_MAGIC);
/* First do an optimistic unlocked check */
@@ -929,6 +930,10 @@ ban_check_object(const struct object *o, struct vsl_log *vsl,
if (b0 == oc->ban)
return (0);
+ /* Now we need the object */
+ o = ObjGetObj(oc, &wrk->stats);
+ CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
+
/*
* This loop is safe without locks, because we know we hold
* a refcount on a ban somewhere in the list and we do not
@@ -939,7 +944,7 @@ ban_check_object(const struct object *o, struct vsl_log *vsl,
CHECK_OBJ_NOTNULL(b, BAN_MAGIC);
if (b->flags & BANS_FLAG_COMPLETED)
continue;
- if (ban_evaluate(b->spec, o->http, req_http, &tests))
+ if (ban_evaluate(b->spec, o->http, req->http, &tests))
break;
}
@@ -969,13 +974,6 @@ ban_check_object(const struct object *o, struct vsl_log *vsl,
}
}
-int
-BAN_CheckObject(const struct object *o, struct req *req)
-{
-
- return (ban_check_object(o, req->vsl, req->http) > 0);
-}
-
static void
ban_cleantail(void)
{
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index c626117..68e0ae1 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -423,11 +423,12 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
if (oc->exp.ttl <= 0.)
continue;
+ if (BAN_CheckObject(wrk, oc, req))
+ continue;
+
o = ObjGetObj(oc, &wrk->stats);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
- if (BAN_CheckObject(o, req))
- continue;
if (o->vary != NULL && !VRY_Match(req, o->vary))
continue;
More information about the varnish-commit
mailing list