Commit 2700f6cd authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

A bit of cleanup

parent 92d43d17
......@@ -632,7 +632,7 @@ enum vgz_flag { VGZ_NORMAL, VGZ_ALIGN, VGZ_RESET, VGZ_FINISH };
struct vgz *VGZ_NewUngzip(const struct sess *sp, struct ws *tmp);
struct vgz *VGZ_NewGzip(const struct sess *sp, struct ws *tmp);
void VGZ_Ibuf(struct vgz *, const void *, ssize_t len);
int VGZ_IbufEmpty(struct vgz *vg);
int VGZ_IbufEmpty(const struct vgz *vg);
void VGZ_Obuf(struct vgz *, const void *, ssize_t len);
int VGZ_ObufStorage(const struct sess *sp, struct vgz *vg);
int VGZ_Gzip(struct vgz *, const void **, size_t *len, enum vgz_flag);
......
......@@ -174,8 +174,8 @@ ESI_Deliver(struct sess *sp)
struct storage *st;
uint8_t *p, *e, *q, *r;
unsigned off;
ssize_t l, l_icrc, l_crc;
uint32_t crc, icrc;
ssize_t l, l_icrc, l_crc = 0;
uint32_t crc = 0, icrc;
uint8_t tailbuf[8 + 5];
int dogzip;
......@@ -208,13 +208,11 @@ ESI_Deliver(struct sess *sp)
l_icrc = ved_decode_len(&p);
icrc = vbe32dec(p);
p += 4;
}
q = (void*)strchr((const char*)p, '\0');
assert (q > p);
if (dogzip) {
crc = crc32_combine(crc, icrc, l_icrc);
l_crc += l_icrc;
}
q = (void*)strchr((const char*)p, '\0');
assert (q > p);
ved_sendchunk(sp, p, q - p, st->ptr + off, l);
off += l;
p = q + 1;
......
......@@ -113,6 +113,7 @@ vfp_esi_bytes_gu(struct sess *sp, struct http_conn *htc, size_t bytes)
if (VGZ_ObufStorage(sp, vg))
return (-1);
i = VGZ_Gunzip(vg, &dp, &dl);
xxxassert(i == Z_OK || i == Z_STREAM_END);
VEP_parse(sp, dp, dl);
sp->obj->len += dl;
}
......@@ -136,8 +137,6 @@ struct vef_priv {
* We receive a ungzip'ed object, and want to store it gzip'ed.
*/
#include "vend.h"
static ssize_t
vfp_vep_callback(const struct sess *sp, ssize_t l, enum vgz_flag flg)
{
......@@ -146,8 +145,6 @@ vfp_vep_callback(const struct sess *sp, ssize_t l, enum vgz_flag flg)
const void *dp;
int i;
printf("ZCB(%jd, %d)\n", l, flg);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
vef = sp->wrk->vef_priv;
CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
......@@ -166,18 +163,14 @@ printf("ZCB(%jd, %d)\n", l, flg);
return (vef->tot);
}
i = VGZ_Gzip(vef->vgz, &dp, &dl, flg);
printf("GZI = %d %jd\n", i, dl);
vef->tot += dl;
sp->obj->len += dl;
} while (!VGZ_IbufEmpty(vef->vgz));
vef->bufp += l;
if (flg == VGZ_FINISH)
assert(i == 1); /* XXX */
else
assert(i == 0); /* XXX */
printf("ZCB = %jd\n", vef->tot);
fflush(stdout);
usleep(100);
if (flg == VGZ_FINISH)
assert(i == 1); /* XXX */
else
assert(i == 0); /* XXX */
return (vef->tot);
}
......@@ -256,7 +249,6 @@ vfp_esi_bytes(struct sess *sp, struct http_conn *htc, size_t bytes)
int i;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
printf("BYTES = %jd\n", bytes);
if (sp->wrk->is_gzip && sp->wrk->do_gunzip)
i = vfp_esi_bytes_gu(sp, htc, bytes);
else if (sp->wrk->is_gunzip && sp->wrk->do_gzip)
......@@ -265,7 +257,6 @@ printf("BYTES = %jd\n", bytes);
i = vfp_esi_bytes_gg(sp, htc, bytes);
else
i = vfp_esi_bytes_uu(sp, htc, bytes);
printf("BYTES = %d\n", i);
return (i);
}
......@@ -276,7 +267,6 @@ vfp_esi_end(struct sess *sp)
struct vef_priv *vef;
ssize_t l;
printf("END\n");
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
if (sp->wrk->is_gzip && sp->wrk->do_gunzip)
VGZ_Destroy(&sp->wrk->vgz_rx);
......@@ -299,8 +289,7 @@ printf("END\n");
sp->wrk->vef_priv = NULL;
CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
XXXAZ(vef->error);
printf("TOT %jd\n", vef->tot);
sp->obj->len = vef->tot;
// sp->obj->len = vef->tot;
}
return (0);
}
......
......@@ -202,7 +202,7 @@ VGZ_Ibuf(struct vgz *vg, const void *ptr, ssize_t len)
}
int
VGZ_IbufEmpty(struct vgz *vg)
VGZ_IbufEmpty(const struct vgz *vg)
{
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
......
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