r4278 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Wed Oct 7 09:57:54 CEST 2009


Author: phk
Date: 2009-10-07 09:57:54 +0200 (Wed, 07 Oct 2009)
New Revision: 4278

Modified:
   trunk/varnish-cache/bin/varnishd/storage_persistent.c
Log:
Minor polishing:

Only delete empty segments from front of list.

Preallocate the temporary object-index buffer at open time.



Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-10-06 08:31:57 UTC (rev 4277)
+++ trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-10-07 07:57:54 UTC (rev 4278)
@@ -616,16 +616,18 @@
 
 	Lck_AssertHeld(&sc->mtx);
 
-	/* Elide any empty segments from the list before we write it */
+	/*
+	 * Remove empty segments from the front of the list
+	 * before we write the segments to disk.
+	 */
 	VTAILQ_FOREACH_SAFE(sg, &sc->segments, list, sg2) {
 		if (sg->nobj > 0)
-			continue;
+			break;
 		if (sg == sc->cur_seg)
 			continue;
 		VTAILQ_REMOVE(&sc->segments, sg, list);
-		// XXX: free segment
+		free(sg);
 	}
-
 	smp_save_seg(sc, &sc->seg1);
 	smp_save_seg(sc, &sc->seg2);
 }
@@ -1042,13 +1044,9 @@
 	AN(sg);
 	sg->sc = sc;
 
-	if (sc->objbuf == NULL) {
-		sg->objs = malloc(sizeof *sg->objs * sc->aim_nobj);
-	} else {
-		sg->objs = sc->objbuf;
-		sc->objbuf = NULL;
-	}
-	
+	AN(sc->objbuf);
+	sg->objs = sc->objbuf;
+	sc->objbuf = NULL;
 	AN(sg->objs);
 
 	/* XXX: debugging */
@@ -1207,6 +1205,9 @@
 	Lck_New(&sc->mtx);
 	Lck_Lock(&sc->mtx);
 
+	sc->objbuf = malloc(sizeof *sc->objbuf * sc->aim_nobj);
+	AN(sc->objbuf);
+
 	/* We trust the parent to give us a valid silo, for good measure: */
 	AZ(smp_valid_silo(sc));
 



More information about the varnish-commit mailing list