[master] 321c2e3 Wean HSH_Lookup from struct object
Poul-Henning Kamp
phk at FreeBSD.org
Tue Aug 5 09:29:13 CEST 2014
commit 321c2e30f83d020f387831d94473ff98f533d60c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Aug 5 07:28:53 2014 +0000
Wean HSH_Lookup from struct object
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index e171d66..af290cd 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -490,7 +490,7 @@ struct busyobj {
enum busyobj_state_e state;
struct ws ws[1];
- char *ws_bo;
+ char *ws_bo;
struct vbc *vbc;
struct http *bereq0;
struct http *bereq;
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index ad1b874..712243b 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -343,10 +343,10 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
struct objhead *oh;
struct objcore *oc;
struct objcore *exp_oc;
- struct object *o, *exp_o;
double exp_t_origin;
int busy_found;
enum lookup_e retval;
+ uint8_t *vary;
AN(ocp);
*ocp = NULL;
@@ -391,10 +391,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
assert(oh->refcnt > 0);
busy_found = 0;
- exp_o = NULL;
exp_oc = NULL;
exp_t_origin = 0.0;
- o = NULL;
VTAILQ_FOREACH(oc, &oh->objcs, list) {
/* Must be at least our own ref + the objcore we examine */
assert(oh->refcnt > 1);
@@ -426,10 +424,9 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
if (BAN_CheckObject(wrk, oc, req))
continue;
- o = ObjGetObj(oc, &wrk->stats);
- CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
+ vary = ObjGetattr(oc, &wrk->stats, OA_VARY, NULL);
- if (o->vary != NULL && !VRY_Match(req, o->vary))
+ if (vary != NULL && !VRY_Match(req, vary))
continue;
if (EXP_Ttl(req, &oc->exp) >= req->t_req) {
@@ -448,13 +445,11 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
!(oc->flags & OC_F_PASS)) {
/* record the newest object */
exp_oc = oc;
- exp_o = o;
exp_t_origin = oc->exp.t_origin;
}
}
if (exp_oc != NULL) {
- AN(exp_o);
assert(oh->refcnt > 1);
assert(exp_oc->objhead == oh);
exp_oc->refcnt++;
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index b5a0faa..495599a 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -219,27 +219,32 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr,
ssize_t *len)
{
struct object *o;
+ ssize_t dummy;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AN(ds);
- AN(len);
+ if (len == NULL)
+ len = &dummy;
o = ObjGetObj(oc, ds);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
switch (attr) {
- case OA_VXID:
- *len = sizeof o->oa_vxid;
- return (o->oa_vxid);
- case OA_LASTMODIFIED:
- *len = sizeof o->oa_lastmodified;
- return (o->oa_lastmodified);
- case OA_GZIPBITS:
- *len = sizeof o->oa_gzipbits;
- return (o->oa_gzipbits);
case OA_ESIDATA:
if (o->esidata == NULL)
return (NULL);
*len = o->esidata->len;
return (o->esidata->ptr);
+ case OA_GZIPBITS:
+ *len = sizeof o->oa_gzipbits;
+ return (o->oa_gzipbits);
+ case OA_LASTMODIFIED:
+ *len = sizeof o->oa_lastmodified;
+ return (o->oa_lastmodified);
+ case OA_VARY:
+ *len = 4; // XXX: hack
+ return (o->vary);
+ case OA_VXID:
+ *len = sizeof o->oa_vxid;
+ return (o->oa_vxid);
default:
break;
}
@@ -256,15 +261,15 @@ ObjSetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr,
o = ObjGetObj(oc, ds);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
switch (attr) {
- case OA_VXID:
- assert(len == sizeof o->oa_vxid);
- return (o->oa_vxid);
case OA_GZIPBITS:
assert(len == sizeof o->oa_gzipbits);
return (o->oa_gzipbits);
case OA_LASTMODIFIED:
assert(len == sizeof o->oa_lastmodified);
return (o->oa_lastmodified);
+ case OA_VXID:
+ assert(len == sizeof o->oa_vxid);
+ return (o->oa_vxid);
default:
break;
}
More information about the varnish-commit
mailing list