[PATCH 2/4] Improve client ws overflow handling.
Lasse Karstensen
lkarsten at varnish-software.com
Fri Jul 31 09:48:35 CEST 2015
---
bin/varnishd/cache/cache_deliver_proc.c | 5 ++++-
bin/varnishd/cache/cache_range.c | 8 ++++++--
bin/varnishd/cache/cache_vrt_re.c | 1 +
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c
index 4fd666b..6366028 100644
--- a/bin/varnishd/cache/cache_deliver_proc.c
+++ b/bin/varnishd/cache/cache_deliver_proc.c
@@ -74,7 +74,10 @@ VDP_push(struct req *req, vdp_bytes *func, void *priv, int bottom)
VSB_delete(vsb);
#endif
vdp = WS_Alloc(req->ws, sizeof *vdp);
- AN(vdp);
+ if (vdp == NULL) {
+ WS_MarkOverflow(req->ws);
+ return;
+ }
INIT_OBJ(vdp, VDP_ENTRY_MAGIC);
vdp->func = func;
vdp->priv = priv;
diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c
index 6122984..a109ba7 100644
--- a/bin/varnishd/cache/cache_range.c
+++ b/bin/varnishd/cache/cache_range.c
@@ -162,7 +162,9 @@ vrg_dorange(struct req *req, const char *r)
http_PutResponse(req->resp, "HTTP/1.1", 206, NULL);
vrg_priv = WS_Alloc(req->ws, sizeof *vrg_priv);
- XXXAN(vrg_priv);
+ if (vrg_priv == NULL) {
+ return(-1);
+ }
INIT_OBJ(vrg_priv, VRG_PRIV_MAGIC);
vrg_priv->range_off = 0;
vrg_priv->range_low = low;
@@ -183,7 +185,9 @@ VRG_dorange(struct req *req, const char *r)
/* We must snapshot the length if we're streaming from the backend */
i = vrg_dorange(req, r);
- if (i) {
+ if (i < 0)
+ WS_MarkOverflow(req->ws);
+ else if (i > 0) {
VSLb(req->vsl, SLT_Debug, "RANGE_FAIL line %d", i);
http_Unset(req->resp, H_Content_Length);
if (req->resp_len >= 0)
diff --git a/bin/varnishd/cache/cache_vrt_re.c b/bin/varnishd/cache/cache_vrt_re.c
index d96c4f4..c1ea167 100644
--- a/bin/varnishd/cache/cache_vrt_re.c
+++ b/bin/varnishd/cache/cache_vrt_re.c
@@ -171,6 +171,7 @@ VRT_regsub(VRT_CTX, int all, const char *str, void *re,
/* Copy suffix to match */
Tadd(&res_b, res_e, str + offset, 1 + len - offset);
if (res_b >= res_e) {
+ WS_MarkOverflow(ctx->ws);
WS_Release(ctx->ws, 0);
return (str);
}
--
2.1.4
--
Lasse Karstensen
Varnish Software AS
More information about the varnish-dev
mailing list