[master] 3aff0b4 Use ObjGetattr() for OA_ESIDATA
Poul-Henning Kamp
phk at FreeBSD.org
Wed Jul 30 11:55:23 CEST 2014
commit 3aff0b4f04b5cc82e57d4e362a698228ad9f5198
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Jul 30 09:55:06 2014 +0000
Use ObjGetattr() for OA_ESIDATA
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 38fff60..9952289 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1060,7 +1060,7 @@ void ObjUpdateMeta(struct objcore *);
void ObjFreeObj(struct objcore *, struct dstat *);
struct lru *ObjGetLRU(const struct objcore *);
ssize_t ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr,
- void *ptr, ssize_t len);
+ void **ptr);
/* cache_panic.c */
void PAN_Init(void);
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index df87210..b985efc 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -252,6 +252,7 @@ void
ESI_Deliver(struct req *req)
{
struct storage *st;
+ void *vp;
uint8_t *p, *e, *q, *r;
unsigned off;
ssize_t l, l2, l_icrc = 0;
@@ -264,11 +265,10 @@ ESI_Deliver(struct req *req)
int i;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
- st = req->obj->esidata;
- AN(st);
-
- p = st->ptr;
- e = st->ptr + st->len;
+ l = ObjGetattr(req->obj->objcore, &req->wrk->stats, OA_ESIDATA, &vp);
+ assert(l > 0);
+ p = vp;
+ e = p + l;
if (*p == VEC_GZ) {
isgzip = 1;
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index b138fd1..d393411 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -214,19 +214,26 @@ ObjGetLRU(const struct objcore *oc)
}
ssize_t
-ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr,
- void *ptr, ssize_t len)
+ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, void **ptr)
{
struct object *o;
+ void *dummy;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+ AN(ds);
+ if (ptr == NULL)
+ ptr = &dummy;
o = ObjGetObj(oc, ds);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
switch (attr) {
case OA_VXID:
- assert(len == sizeof o->vxid);
- memcpy(ptr, &o->vxid, sizeof o->vxid);
+ *ptr = &o->vxid;
return (sizeof o->vxid);
+ case OA_ESIDATA:
+ if (o->esidata == NULL)
+ return (-1);
+ *ptr = o->esidata->ptr;
+ return (o->esidata->len);
default:
break;
}
@@ -236,8 +243,10 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr,
unsigned
ObjGetXID(struct objcore *oc, struct dstat *ds)
{
+ void *p;
uint32_t u;
- assert(ObjGetattr(oc, ds, OA_VXID, &u, sizeof u) == sizeof u);
+ assert(ObjGetattr(oc, ds, OA_VXID, &p) == sizeof u);
+ memcpy(&u, p, sizeof u);
return (u);
}
More information about the varnish-commit
mailing list