[master] 4f47929 Add an objcore->getxid() method.

Poul-Henning Kamp phk at varnish-cache.org
Tue Dec 6 11:00:50 CET 2011


commit 4f47929731b3dc637c0ac756e2babb4787fcb9bb
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Dec 6 10:00:25 2011 +0000

    Add an objcore->getxid() method.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 46af4dd..327682c 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -395,12 +395,14 @@ struct storage {
  */
 
 typedef struct object *getobj_f(struct worker *wrk, struct objcore *oc);
+typedef unsigned getxid_f(struct worker *wrk, struct objcore *oc);
 typedef void updatemeta_f(struct objcore *oc);
 typedef void freeobj_f(struct objcore *oc);
 typedef struct lru *getlru_f(const struct objcore *oc);
 
 struct objcore_methods {
 	getobj_f	*getobj;
+	getxid_f	*getxid;
 	updatemeta_f	*updatemeta;
 	freeobj_f	*freeobj;
 	getlru_f	*getlru;
@@ -429,6 +431,16 @@ struct objcore {
 	struct ban		*ban;
 };
 
+static inline unsigned
+oc_getxid(struct worker *wrk, struct objcore *oc)
+{
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+
+	AN(oc->methods);
+	AN(oc->methods->getxid);
+	return (oc->methods->getxid(wrk, oc));
+}
+
 static inline struct object *
 oc_getobj(struct worker *wrk, struct objcore *oc)
 {
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index 23e3fc6..761a62e 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -401,7 +401,7 @@ exp_timer(struct sess *sp, void *priv)
 		CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
 		o = oc_getobj(sp->wrk, oc);
 		WSL(sp->wrk, SLT_ExpKill, 0, "%u %.0f",
-		    o->xid, EXP_Ttl(NULL, o) - t);
+		    oc_getxid(sp->wrk, oc), EXP_Ttl(NULL, o) - t);
 		(void)HSH_Deref(sp->wrk, oc, NULL);
 	}
 	NEEDLESS_RETURN(NULL);
@@ -414,10 +414,9 @@ exp_timer(struct sess *sp, void *priv)
  */
 
 int
-EXP_NukeOne(struct worker *w, struct lru *lru)
+EXP_NukeOne(struct worker *wrk, struct lru *lru)
 {
 	struct objcore *oc;
-	struct object *o;
 
 	/* Find the first currently unused object on the LRU.  */
 	Lck_Lock(&lru->mtx);
@@ -446,9 +445,8 @@ EXP_NukeOne(struct worker *w, struct lru *lru)
 		return (-1);
 
 	/* XXX: bad idea for -spersistent */
-	o = oc_getobj(w, oc);
-	WSL(w, SLT_ExpKill, 0, "%u LRU", o->xid);
-	(void)HSH_Deref(w, NULL, &o);
+	WSL(wrk, SLT_ExpKill, 0, "%u LRU", oc_getxid(wrk, oc));
+	(void)HSH_Deref(wrk, oc, NULL);
 	return (1);
 }
 
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index 5de0e27..a6156d4 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -48,6 +48,15 @@ static const struct stevedore * volatile stv_next;
  * Default objcore methods
  */
 
+static unsigned __match_proto__(getxid_f)
+default_oc_getxid(struct worker *wrk, struct objcore *oc)
+{
+	struct object *o;
+
+	o = oc_getobj(wrk, oc);
+	return (o->xid);
+}
+
 static struct object * __match_proto__(getobj_f)
 default_oc_getobj(struct worker *wrk, struct objcore *oc)
 {
@@ -84,6 +93,7 @@ default_oc_getlru(const struct objcore *oc)
 
 static struct objcore_methods default_oc_methods = {
 	.getobj = default_oc_getobj,
+	.getxid = default_oc_getxid,
 	.freeobj = default_oc_freeobj,
 	.getlru = default_oc_getlru,
 };



More information about the varnish-commit mailing list