[master] 6227fdf WS_Reserve shouldn't round down if we're not asking for too much

Nils Goroll nils.goroll at uplex.de
Wed Aug 27 19:22:39 CEST 2014


commit 6227fdf3bba468f4645f3152033ce957debcbd2a
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