[experimental-ims] f5577b7 Move more stuff from worker to req
Geoff Simmons
geoff at varnish-cache.org
Tue Jan 10 00:03:33 CET 2012
commit f5577b72696ea7035c732293bd60fc0a5794932c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Dec 26 10:22:01 2011 +0000
Move more stuff from worker to req
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 372a32d..42562b5 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -328,17 +328,9 @@ struct worker {
struct busyobj *busyobj;
- /* This is only here so VRT can find it */
- const char *storage_hint;
-
/* Stream state */
struct stream_ctx *sctx;
- /* ESI delivery stuff */
- int gzip_resp;
- ssize_t l_crc;
- uint32_t crc;
-
/* Timeouts */
double connect_timeout;
double first_byte_timeout;
@@ -621,6 +613,14 @@ struct req {
struct objcore *objcore;
/* Lookup stuff */
struct SHA256Context *sha256ctx;
+ /* This is only here so VRT can find it */
+ const char *storage_hint;
+
+ /* ESI delivery stuff */
+ int gzip_resp;
+ ssize_t l_crc;
+ uint32_t crc;
+
};
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 7e9c77f..81a0c67 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -597,7 +597,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req)
AN(req->director);
AZ(wrk->busyobj->vbc);
AZ(wrk->busyobj->should_close);
- AZ(wrk->storage_hint);
+ AZ(req->storage_hint);
http_Setup(wrk->busyobj->beresp, wrk->ws);
@@ -678,7 +678,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req)
}
VBO_DerefBusyObj(wrk, &wrk->busyobj);
req->director = NULL;
- wrk->storage_hint = NULL;
+ req->storage_hint = NULL;
switch (req->handling) {
case VCL_RET_RESTART:
@@ -830,9 +830,9 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req)
if (wrk->busyobj->exp.ttl < cache_param->shortlived ||
req->objcore == NULL)
- wrk->storage_hint = TRANSIENT_STORAGE;
+ req->storage_hint = TRANSIENT_STORAGE;
- req->obj = STV_NewObject(wrk, wrk->storage_hint, l, nhttp);
+ req->obj = STV_NewObject(wrk, req->storage_hint, l, nhttp);
if (req->obj == NULL) {
/*
* Try to salvage the transaction by allocating a
@@ -853,7 +853,7 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req)
}
CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);
- wrk->storage_hint = NULL;
+ req->storage_hint = NULL;
if (wrk->busyobj->do_gzip ||
(wrk->busyobj->is_gzip && !wrk->busyobj->do_gunzip))
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 0c58395..a7e80cd 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -194,8 +194,8 @@ ved_pretend_gzip(const struct sess *sp, const uint8_t *p, ssize_t l)
(void)WRW_Write(sp->wrk, buf2, sizeof buf2);
}
(void)WRW_Write(sp->wrk, p, lx);
- sp->wrk->crc = crc32(sp->wrk->crc, p, lx);
- sp->wrk->l_crc += lx;
+ sp->req->crc = crc32(sp->req->crc, p, lx);
+ sp->req->l_crc += lx;
l -= lx;
p += lx;
}
@@ -251,18 +251,18 @@ ESI_Deliver(struct sess *sp)
/*
* Only the top level document gets to decide this.
*/
- sp->wrk->gzip_resp = 0;
+ sp->req->gzip_resp = 0;
if (isgzip && !(sp->wrk->res_mode & RES_GUNZIP)) {
assert(sizeof gzip_hdr == 10);
/* Send out the gzip header */
(void)WRW_Write(sp->wrk, gzip_hdr, 10);
- sp->wrk->l_crc = 0;
- sp->wrk->gzip_resp = 1;
- sp->wrk->crc = crc32(0L, Z_NULL, 0);
+ sp->req->l_crc = 0;
+ sp->req->gzip_resp = 1;
+ sp->req->crc = crc32(0L, Z_NULL, 0);
}
}
- if (isgzip && !sp->wrk->gzip_resp) {
+ if (isgzip && !sp->req->gzip_resp) {
vgz = VGZ_NewUngzip(sp->wrk, "U D E");
/* Feed a gzip header to gunzip to make it happy */
@@ -291,10 +291,10 @@ ESI_Deliver(struct sess *sp)
l_icrc = ved_decode_len(&p);
icrc = vbe32dec(p);
p += 4;
- if (sp->wrk->gzip_resp) {
- sp->wrk->crc = crc32_combine(
- sp->wrk->crc, icrc, l_icrc);
- sp->wrk->l_crc += l_icrc;
+ if (sp->req->gzip_resp) {
+ sp->req->crc = crc32_combine(
+ sp->req->crc, icrc, l_icrc);
+ sp->req->l_crc += l_icrc;
}
}
/*
@@ -308,14 +308,14 @@ ESI_Deliver(struct sess *sp)
l2 = st->len - off;
l -= l2;
- if (sp->wrk->gzip_resp && isgzip) {
+ if (sp->req->gzip_resp && isgzip) {
/*
* We have a gzip'ed VEC and delivers
* a gzip'ed ESI response.
*/
(void)WRW_Write(sp->wrk,
st->ptr + off, l2);
- } else if (sp->wrk->gzip_resp) {
+ } else if (sp->req->gzip_resp) {
/*
* A gzip'ed ESI response, but the VEC
* was not gzip'ed.
@@ -403,7 +403,7 @@ ESI_Deliver(struct sess *sp)
(void)WRW_Write(sp->wrk, obuf, obufl);
(void)VGZ_Destroy(&vgz, sp->vsl_id);
}
- if (sp->wrk->gzip_resp && sp->req->esi_level == 0) {
+ if (sp->req->gzip_resp && sp->req->esi_level == 0) {
/* Emit a gzip literal block with finish bit set */
tailbuf[0] = 0x01;
tailbuf[1] = 0x00;
@@ -412,10 +412,10 @@ ESI_Deliver(struct sess *sp)
tailbuf[4] = 0xff;
/* Emit CRC32 */
- vle32enc(tailbuf + 5, sp->wrk->crc);
+ vle32enc(tailbuf + 5, sp->req->crc);
/* MOD(2^32) length */
- vle32enc(tailbuf + 9, sp->wrk->l_crc);
+ vle32enc(tailbuf + 9, sp->req->l_crc);
(void)WRW_Write(sp->wrk, tailbuf, 13);
}
@@ -560,6 +560,6 @@ ESI_DeliverChild(const struct sess *sp)
p = st->ptr + st->len - 8;
icrc = vle32dec(p);
ilen = vle32dec(p + 4);
- sp->wrk->crc = crc32_combine(sp->wrk->crc, icrc, ilen);
- sp->wrk->l_crc += ilen;
+ sp->req->crc = crc32_combine(sp->req->crc, icrc, ilen);
+ sp->req->l_crc += ilen;
}
diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c
index 2236f0b..9b0760c 100644
--- a/bin/varnishd/cache/cache_pool.c
+++ b/bin/varnishd/cache/cache_pool.c
@@ -255,7 +255,6 @@ Pool_Work_Thread(void *priv, struct worker *wrk)
stats_clean = 0;
wrk->lastused = NAN;
- wrk->storage_hint = NULL;
AZ(wrk->sp->wrk);
THR_SetSession(wrk->sp);
@@ -267,7 +266,6 @@ Pool_Work_Thread(void *priv, struct worker *wrk)
WS_Assert(wrk->ws);
AZ(wrk->busyobj);
AZ(wrk->wrw.wfd);
- AZ(wrk->storage_hint);
assert(wrk->wlp == wrk->wlb);
if (cache_param->diag_bitmap & 0x00040000) {
if (wrk->vcl != NULL)
diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index 1abb12b..fc94c22 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -307,10 +307,10 @@ RES_WriteObj(struct sess *sp)
/* Nothing to do here */
} else if (sp->wrk->res_mode & RES_ESI) {
ESI_Deliver(sp);
- } else if (sp->wrk->res_mode & RES_ESI_CHILD && sp->wrk->gzip_resp) {
+ } else if (sp->wrk->res_mode & RES_ESI_CHILD && sp->req->gzip_resp) {
ESI_DeliverChild(sp);
} else if (sp->wrk->res_mode & RES_ESI_CHILD &&
- !sp->wrk->gzip_resp && sp->req->obj->gziped) {
+ !sp->req->gzip_resp && sp->req->obj->gziped) {
res_WriteGunzipObj(sp);
} else if (sp->wrk->res_mode & RES_GUNZIP) {
res_WriteGunzipObj(sp);
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index cb66ff7..e051dbb 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -283,8 +283,8 @@ const char * __match_proto__()
VRT_r_beresp_storage(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- if (sp->wrk->storage_hint != NULL)
- return (sp->wrk->storage_hint);
+ if (sp->req->storage_hint != NULL)
+ return (sp->req->storage_hint);
else
return (NULL);
}
@@ -298,7 +298,7 @@ VRT_l_beresp_storage(struct sess *sp, const char *str, ...)
va_start(ap, str);
b = VRT_String(sp->wrk->ws, NULL, str, ap);
va_end(ap);
- sp->wrk->storage_hint = b;
+ sp->req->storage_hint = b;
}
/*--------------------------------------------------------------------*/
More information about the varnish-commit
mailing list