Commit 01b66692 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Record the positions of gzip start, last and stop bits in

objects when we know them.

For now: use malloc for gzip instead of running out of workspace.
parent fd081460
......@@ -433,6 +433,10 @@ struct object {
/* XXX: make bitmap */
unsigned cacheable;
unsigned gziped;
/* Bit positions in the gzip stream */
ssize_t gzip_start;
ssize_t gzip_last;
ssize_t gzip_stop;
ssize_t len;
......@@ -643,6 +647,7 @@ int VGZ_ObufStorage(const struct sess *sp, struct vgz *vg);
int VGZ_Gzip(struct vgz *, const void **, size_t *len, enum vgz_flag);
int VGZ_Gunzip(struct vgz *, const void **, size_t *len);
void VGZ_Destroy(struct vgz **);
void VGZ_UpdateObj(const struct vgz*, struct object *);
/* cache_http.c */
unsigned HTTP_estimate(unsigned nhttp);
......
......@@ -270,6 +270,7 @@ vfp_esi_bytes_gg(struct sess *sp, struct http_conn *htc, size_t bytes)
VGZ_Obuf(sp->wrk->vgz_rx, ibuf2, sizeof ibuf2);
i = VGZ_Gunzip(sp->wrk->vgz_rx, &dp, &dl);
/* XXX: check i */
assert(i >= 0);
vef->bufp = ibuf2;
if (dl > 0)
VEP_parse(sp, ibuf2, dl);
......@@ -371,6 +372,7 @@ vfp_esi_end(struct sess *sp)
if (sp->wrk->vef_priv != NULL) {
vef = sp->wrk->vef_priv;
VGZ_UpdateObj(vef->vgz, sp->obj);
sp->wrk->vef_priv = NULL;
CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
XXXAZ(vef->error);
......
......@@ -148,6 +148,11 @@ VGZ_NewUngzip(const struct sess *sp, struct ws *tmp)
* Since we don't control windowBits, we have to assume
* it is 15, so 34-35KB or so.
*/
#if 1
vg->vz.zalloc = NULL;
vg->vz.zfree = NULL;
vg->vz.opaque = NULL;
#endif
assert(Z_OK == inflateInit2(&vg->vz, 31));
return (vg);
}
......@@ -176,6 +181,11 @@ VGZ_NewGzip(const struct sess *sp, struct ws *tmp)
* XXX: It may be more efficent to malloc them, rather than have
* XXX: too many worker threads grow the stacks.
*/
#if 1
vg->vz.zalloc = NULL;
vg->vz.zfree = NULL;
vg->vz.opaque = NULL;
#endif
i = deflateInit2(&vg->vz,
0, /* Level */
Z_DEFLATED, /* Method */
......@@ -271,6 +281,7 @@ VGZ_Gunzip(struct vgz *vg, const void **pptr, size_t *plen)
return (1);
if (i == Z_BUF_ERROR)
return (2);
printf("INFLATE=%d\n", i);
return (-1);
}
......@@ -317,6 +328,18 @@ VGZ_Gzip(struct vgz *vg, const void **pptr, size_t *plen, enum vgz_flag flags)
/*--------------------------------------------------------------------*/
void
VGZ_UpdateObj(const struct vgz *vg, struct object *obj)
{
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
obj->gzip_start = vg->vz.start_bit;
obj->gzip_last = vg->vz.last_bit;
obj->gzip_stop = vg->vz.stop_bit;
}
/*--------------------------------------------------------------------*/
void
VGZ_Destroy(struct vgz **vg)
{
......@@ -458,6 +481,7 @@ vfp_gzip_end(struct sess *sp)
i = VGZ_Gzip(vg, &dp, &dl, VGZ_FINISH);
sp->obj->len += dl;
} while (i != Z_STREAM_END);
VGZ_UpdateObj(vg, sp->obj);
VGZ_Destroy(&vg);
sp->obj->gziped = 1;
return (0);
......
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