[master] 6a5fff0 Use ObjGetattr() for OA_ESIBITS

Poul-Henning Kamp phk at FreeBSD.org
Wed Jul 30 12:33:47 CEST 2014


commit 6a5fff085e796a2a57c73c0bc89b2ccabe4849dc
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Jul 30 10:33:32 2014 +0000

    Use ObjGetattr() for OA_ESIBITS

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 9952289..8ea97d8 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -564,9 +564,7 @@ struct object {
 	unsigned		changed_gzip:1;
 
 	/* Bit positions in the gzip stream */
-	ssize_t			gzip_start;
-	ssize_t			gzip_last;
-	ssize_t			gzip_stop;
+	ssize_t			gzip_bits[3];
 
 	ssize_t			len;
 
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index b985efc..d74371a 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -496,6 +496,8 @@ ESI_DeliverChild(struct req *req)
 	struct storage *st;
 	struct object *obj;
 	ssize_t start, last, stop, lpad;
+	void *vp;
+	ssize_t l, gzip_bits[3];
 	u_char cc;
 	uint32_t icrc;
 	uint32_t ilen;
@@ -519,9 +521,12 @@ ESI_DeliverChild(struct req *req)
 	AN(dbits);
 	obj = req->obj;
 	CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
-	start = obj->gzip_start;
-	last = obj->gzip_last;
-	stop = obj->gzip_stop;
+	l = ObjGetattr(obj->objcore, &req->wrk->stats, OA_GZIPBITS, &vp);
+	assert(l == sizeof gzip_bits);
+	memcpy(gzip_bits, vp, l);
+	start = gzip_bits[0];
+	last = gzip_bits[1];
+	stop = gzip_bits[2];
 	assert(start > 0 && start < obj->len * 8);
 	assert(last > 0 && last < obj->len * 8);
 	assert(stop > 0 && stop < obj->len * 8);
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index df5b906..2430b16 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -594,9 +594,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 	}
 
 	obj->gziped = bo->ims_obj->gziped;
-	obj->gzip_start = bo->ims_obj->gzip_start;
-	obj->gzip_last = bo->ims_obj->gzip_last;
-	obj->gzip_stop = bo->ims_obj->gzip_stop;
+	memcpy(obj->gzip_bits, bo->ims_obj->gzip_bits, sizeof obj->gzip_bits);
 
 	AZ(WS_Overflowed(bo->ws_o));
 	if (bo->do_stream) {
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 66e0845..0521a5f 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -395,9 +395,9 @@ VGZ_UpdateObj(const struct vgz *vg, struct object *obj)
 
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
-	obj->gzip_start	= vg->vz.start_bit;
-	obj->gzip_last	= vg->vz.last_bit;
-	obj->gzip_stop	= vg->vz.stop_bit;
+	obj->gzip_bits[0] = vg->vz.start_bit;
+	obj->gzip_bits[1] = vg->vz.last_bit;
+	obj->gzip_bits[2] = vg->vz.stop_bit;
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index d393411..e9c0812 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -229,6 +229,9 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, void **ptr)
 	case OA_VXID:
 		*ptr = &o->vxid;
 		return (sizeof o->vxid);
+	case OA_GZIPBITS:
+		*ptr = o->gzip_bits;
+		return (sizeof o->gzip_bits);
 	case OA_ESIDATA:
 		if (o->esidata == NULL)
 			return (-1);



More information about the varnish-commit mailing list