[4.0] d8f1646 WS_Reserve shouldn't round down if we're not asking for too much

Lasse Karstensen lkarsten at varnish-software.com
Mon Sep 22 16:38:24 CEST 2014


commit d8f16461ed6745dbefdc9d60bb5150d57445b3b8
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Aug 27 18:07:43 2014 +0200

    WS_Reserve shouldn't round down if we're not asking for too much

diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c
index ccc887c..956fef4 100644
--- a/bin/varnishd/cache/cache_ws.c
+++ b/bin/varnishd/cache/cache_ws.c
@@ -202,13 +202,12 @@ WS_Reserve(struct ws *ws, unsigned bytes)
 
 	WS_Assert(ws);
 	assert(ws->r == NULL);
-	if (bytes == 0)
-		b2 = ws->e - ws->f;
-	else if (bytes > ws->e - ws->f)
-		b2 = ws->e - ws->f;
-	else
-		b2 = bytes;
-	b2 = PRNDDN(b2);
+
+	b2 = PRNDDN(ws->e - ws->f);
+	if ((bytes != 0) &&
+	    (bytes < b2))
+		b2 = PRNDUP(bytes);
+
 	xxxassert(ws->f + b2 <= ws->e);
 	ws->r = ws->f + b2;
 	DSL(DBG_WORKSPACE, 0, "WS_Reserve(%p, %u/%u) = %u",



More information about the varnish-commit mailing list