Commit ae57a6bd authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make the variables that control gzip'ed ESI deliver to sp->wrk so

included files can get at them.
parent f36b3ca6
...@@ -290,6 +290,9 @@ struct worker { ...@@ -290,6 +290,9 @@ struct worker {
/* ESI stuff */ /* ESI stuff */
struct vep_state *vep; struct vep_state *vep;
int gzip_resp;
ssize_t l_crc;
uint32_t crc;
/* Timeouts */ /* Timeouts */
double connect_timeout; double connect_timeout;
......
...@@ -174,10 +174,9 @@ ESI_Deliver(struct sess *sp) ...@@ -174,10 +174,9 @@ ESI_Deliver(struct sess *sp)
struct storage *st; struct storage *st;
uint8_t *p, *e, *q, *r; uint8_t *p, *e, *q, *r;
unsigned off; unsigned off;
ssize_t l, l_icrc, l_crc = 0; ssize_t l, l_icrc;
uint32_t crc = 0, icrc; uint32_t icrc;
uint8_t tailbuf[8 + 5]; uint8_t tailbuf[8 + 5];
int dogzip;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
st = sp->obj->esidata; st = sp->obj->esidata;
...@@ -185,13 +184,14 @@ ESI_Deliver(struct sess *sp) ...@@ -185,13 +184,14 @@ ESI_Deliver(struct sess *sp)
p = st->ptr; p = st->ptr;
e = st->ptr + st->len; e = st->ptr + st->len;
if (*p == VEC_GZ) { if (sp->esi_level == 0) {
p++; if (*p == VEC_GZ) {
dogzip = 1; p++;
crc = crc32(0L, Z_NULL, 0); sp->wrk->gzip_resp = 1;
l_crc = 0; sp->wrk->crc = crc32(0L, Z_NULL, 0);
} else } else
dogzip = 0; sp->wrk->gzip_resp = 0;
}
st = VTAILQ_FIRST(&sp->obj->store); st = VTAILQ_FIRST(&sp->obj->store);
off = 0; off = 0;
...@@ -202,14 +202,15 @@ ESI_Deliver(struct sess *sp) ...@@ -202,14 +202,15 @@ ESI_Deliver(struct sess *sp)
case VEC_V2: case VEC_V2:
case VEC_V8: case VEC_V8:
l = ved_decode_len(&p); l = ved_decode_len(&p);
if (dogzip) { if (sp->wrk->gzip_resp) {
assert(*p == VEC_C1 || *p == VEC_C2 || assert(*p == VEC_C1 || *p == VEC_C2 ||
*p == VEC_C8); *p == VEC_C8);
l_icrc = ved_decode_len(&p); l_icrc = ved_decode_len(&p);
icrc = vbe32dec(p); icrc = vbe32dec(p);
p += 4; p += 4;
crc = crc32_combine(crc, icrc, l_icrc); sp->wrk->crc =
l_crc += l_icrc; crc32_combine(sp->wrk->crc, icrc, l_icrc);
sp->wrk->l_crc += l_icrc;
} }
q = (void*)strchr((const char*)p, '\0'); q = (void*)strchr((const char*)p, '\0');
assert (q > p); assert (q > p);
...@@ -241,7 +242,7 @@ ESI_Deliver(struct sess *sp) ...@@ -241,7 +242,7 @@ ESI_Deliver(struct sess *sp)
INCOMPL(); INCOMPL();
} }
} }
if (dogzip) { if (sp->wrk->gzip_resp && sp->esi_level == 0) {
/* Emit a gzip literal block with finish bit set */ /* Emit a gzip literal block with finish bit set */
tailbuf[0] = 0x01; tailbuf[0] = 0x01;
tailbuf[1] = 0x00; tailbuf[1] = 0x00;
...@@ -250,10 +251,10 @@ ESI_Deliver(struct sess *sp) ...@@ -250,10 +251,10 @@ ESI_Deliver(struct sess *sp)
tailbuf[4] = 0xff; tailbuf[4] = 0xff;
/* Emit CRC32 */ /* Emit CRC32 */
vle32enc(tailbuf + 5, crc); vle32enc(tailbuf + 5, sp->wrk->crc);
/* MOD(2^32) length */ /* MOD(2^32) length */
vle32enc(tailbuf + 9, l_crc); vle32enc(tailbuf + 9, sp->wrk->l_crc);
ved_sendchunk(sp, "d\r\n", 3, tailbuf, 13); ved_sendchunk(sp, "d\r\n", 3, tailbuf, 13);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment