[PATCH] Utilize the oc->priv2 variable to store the pointer to the allocating stevedore for the default case (malloc and file)
Martin Blix Grydeland
martin at varnish-software.com
Mon Mar 12 16:17:34 CET 2012
Change the type of oc->priv2 from unsigned to uintptr_t (due to
padding this does not increase the size of objcore).
Change the default_oc_getlru to find the stevedore through the
oc->priv2 instead of having to go through (and page-in) the object.
---
bin/varnishd/cache/cache.h | 2 +-
bin/varnishd/storage/stevedore.c | 8 +++++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 99c66c3..ac5b1ac 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -371,7 +371,7 @@ struct objcore {
int refcnt;
struct objcore_methods *methods;
void *priv;
- unsigned priv2;
+ uintptr_t priv2;
struct objhead *objhead;
struct busyobj *busyobj;
double timer_when;
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index 3c62d8d..b4b9c7b 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -85,10 +85,10 @@ default_oc_freeobj(struct objcore *oc)
static struct lru *
default_oc_getlru(const struct objcore *oc)
{
- struct object *o;
+ struct stevedore *stv;
- CAST_OBJ_NOTNULL(o, oc->priv, OBJECT_MAGIC);
- return (o->objstore->stevedore->lru);
+ CAST_OBJ_NOTNULL(stv, (void *)oc->priv2, STEVEDORE_MAGIC);
+ return (stv->lru);
}
static struct objcore_methods default_oc_methods = {
@@ -300,6 +300,8 @@ stv_default_allocobj(struct stevedore *stv, struct busyobj *bo,
o = STV_MkObject(bo, ocp, st->ptr, ltot, soc);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
o->objstore = st;
+ if (o->objcore != NULL)
+ o->objcore->priv2 = (uintptr_t)stv;
return (o);
}
--
1.7.4.1
More information about the varnish-dev
mailing list