[master] bd33cab Only try nuking after we failed to allocate space

Federico G. Schwindt fgsch at lodoss.net
Thu Oct 13 15:53:05 CEST 2016


commit bd33cab5a454c0cac450716c1082ba9bdd36a679
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Thu Oct 13 14:50:50 2016 +0100

    Only try nuking after we failed to allocate space

diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c
index 2b7bf72..af9e46b 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -531,12 +531,7 @@ smp_allocobj(struct worker *wrk, const struct stevedore *stv,
 	ltot = sizeof(struct object) + PRNDUP(wsl);
 	ltot = IRNUP(sc, ltot);
 
-	while (1) {
-		if (nuke_limit > 0) {
-			if (!LRU_NukeOne(wrk, stv->lru))
-				return (0);
-			nuke_limit--;
-		}
+	for (; nuke_limit >= 0; nuke_limit--) {
 		st = smp_allocx(stv, ltot, ltot, &so, &objidx, &sg);
 		if (st != NULL && st->space < ltot) {
 			stv->sml_free(st);		// NOP
@@ -544,7 +539,7 @@ smp_allocobj(struct worker *wrk, const struct stevedore *stv,
 		}
 		if (st != NULL)
 			break;
-		if (!nuke_limit)
+		if (!nuke_limit || !LRU_NukeOne(wrk, stv->lru))
 			return (0);
 	}
 
diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c
index 1385927..8649c6f 100644
--- a/bin/varnishd/storage/storage_simple.c
+++ b/bin/varnishd/storage/storage_simple.c
@@ -141,12 +141,7 @@ SML_allocobj(struct worker *wrk, const struct stevedore *stv,
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	assert(nuke_limit >= 0);
 	ltot = sizeof(struct object) + PRNDUP(wsl);
-	while (1) {
-		if (nuke_limit > 0) {
-			if (!LRU_NukeOne(wrk, stv->lru))
-				return (0);
-			nuke_limit--;
-		}
+	for (; nuke_limit >= 0; nuke_limit--) {
 		AN(stv->sml_alloc);
 		st = stv->sml_alloc(stv, ltot);
 		if (st != NULL && st->space < ltot) {
@@ -155,7 +150,7 @@ SML_allocobj(struct worker *wrk, const struct stevedore *stv,
 		}
 		if (st != NULL)
 			break;
-		if (!nuke_limit)
+		if (!nuke_limit || !LRU_NukeOne(wrk, stv->lru))
 			return (0);
 	}
 	AN(st);



More information about the varnish-commit mailing list