[master] b37b3c3d3 gzip: Retire enum vgz_ua_e
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed Jun 26 09:25:07 UTC 2024
commit b37b3c3d33d063560105be47bed71cf84beccc55
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Tue Nov 29 11:34:49 2022 +0100
gzip: Retire enum vgz_ua_e
We already have everything we need with enum vgzret_e and vgz::dir.
diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c
index c52b7ff84..e80fee3d0 100644
--- a/bin/varnishd/cache/cache_esi_fetch.c
+++ b/bin/varnishd/cache/cache_esi_fetch.c
@@ -97,7 +97,7 @@ vfp_vep_callback(struct vfp_ctx *vc, void *priv, ssize_t l, enum vgz_flag flg)
}
VGZ_Obuf(vef->vgz, ptr, dl);
i = VGZ_Gzip(vef->vgz, &dp, &dl, flg);
- VGZ_UpdateObj(vc, vef->vgz, VUA_UPDATE);
+ VGZ_UpdateObj(vc, vef->vgz, i);
if (dl > 0) {
vef->tot += dl;
VFP_Extend(vc, dl, VFP_OK);
@@ -145,7 +145,7 @@ vfp_esi_end(struct vfp_ctx *vc, struct vef_priv *vef,
if (vef->vgz != NULL) {
if (retval == VFP_END)
- VGZ_UpdateObj(vc, vef->vgz, VUA_END_GZIP);
+ VGZ_UpdateObj(vc, vef->vgz, VGZ_END);
if (VGZ_Destroy(&vef->vgz) != VGZ_END)
retval = VFP_Error(vc,
"ESI+Gzip Failed at the very end");
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index b5e608db4..650aed8c3 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -406,14 +406,16 @@ const struct vdp VDP_gunzip = {
/*--------------------------------------------------------------------*/
void
-VGZ_UpdateObj(const struct vfp_ctx *vc, struct vgz *vg, enum vgz_ua_e e)
+VGZ_UpdateObj(const struct vfp_ctx *vc, struct vgz *vg, enum vgzret_e e)
{
char *p;
intmax_t ii;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
+ if (e < VGZ_OK)
+ return;
ii = vg->vz.start_bit + vg->vz.last_bit + vg->vz.stop_bit;
- if (e == VUA_UPDATE && ii == vg->bits)
+ if (e != VGZ_END && ii == vg->bits)
return;
vg->bits = ii;
p = ObjSetAttr(vc->wrk, vc->oc, OA_GZIPBITS, 32, NULL);
@@ -421,9 +423,11 @@ VGZ_UpdateObj(const struct vfp_ctx *vc, struct vgz *vg, enum vgz_ua_e e)
vbe64enc(p, vg->vz.start_bit);
vbe64enc(p + 8, vg->vz.last_bit);
vbe64enc(p + 16, vg->vz.stop_bit);
- if (e == VUA_END_GZIP)
+ if (e != VGZ_END)
+ return;
+ if (vg->dir == VGZ_GZ)
vbe64enc(p + 24, vg->vz.total_in);
- if (e == VUA_END_GUNZIP)
+ if (vg->dir == VGZ_UN)
vbe64enc(p + 24, vg->vz.total_out);
}
@@ -620,7 +624,7 @@ vfp_gzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p,
if (vr < VGZ_OK)
return (VFP_Error(vc, "Gzip failed"));
if (dl > 0) {
- VGZ_UpdateObj(vc, vg, VUA_UPDATE);
+ VGZ_UpdateObj(vc, vg, vr);
*lp = dl;
assert(dp == p);
if (vr != VGZ_END || !VGZ_IbufEmpty(vg))
@@ -632,7 +636,7 @@ vfp_gzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p,
if (vr != VGZ_END)
return (VFP_Error(vc, "Gzip failed"));
- VGZ_UpdateObj(vc, vg, VUA_END_GZIP);
+ VGZ_UpdateObj(vc, vg, VGZ_END);
return (VFP_END);
}
@@ -673,11 +677,10 @@ vfp_testgunzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p,
"Invalid Gzip data: %s", vgz_msg(vg)));
} while (!VGZ_IbufEmpty(vg));
}
- VGZ_UpdateObj(vc, vg, VUA_UPDATE);
+ VGZ_UpdateObj(vc, vg, vr);
if (vp == VFP_END) {
if (vr != VGZ_END)
return (VFP_Error(vc, "tGunzip failed"));
- VGZ_UpdateObj(vc, vg, VUA_END_GUNZIP);
}
return (vp);
}
diff --git a/bin/varnishd/cache/cache_vgz.h b/bin/varnishd/cache/cache_vgz.h
index af5e08933..0464bc7f1 100644
--- a/bin/varnishd/cache/cache_vgz.h
+++ b/bin/varnishd/cache/cache_vgz.h
@@ -55,10 +55,4 @@ enum vgzret_e VGZ_Gzip(struct vgz *, const void **, ssize_t *len,
// enum vgzret_e VGZ_Gunzip(struct vgz *, const void **, ssize_t *len);
enum vgzret_e VGZ_Destroy(struct vgz **);
-enum vgz_ua_e {
- VUA_UPDATE, // Update start/stop/last bits if changed
- VUA_END_GZIP, // Record uncompressed size
- VUA_END_GUNZIP, // Record uncompressed size
-};
-
-void VGZ_UpdateObj(const struct vfp_ctx *, struct vgz*, enum vgz_ua_e);
+void VGZ_UpdateObj(const struct vfp_ctx *, struct vgz*, enum vgzret_e);
More information about the varnish-commit
mailing list