[master] c74c457 Free the LRU object and set free_offset when dropping empty segments in smp_close_seg()

Martin Blix Grydeland martin at varnish-cache.org
Wed Oct 10 09:49:18 CEST 2012


commit c74c457414847d5a1a56894fd9797ce2e4d2e208
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Sun Jun 3 23:57:48 2012 +0200

    Free the LRU object and set free_offset when dropping empty segments in smp_close_seg()
    
    Fixes: #1146

diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c
index 6ed80d2..e7dc597 100644
--- a/bin/varnishd/storage/storage_persistent_silo.c
+++ b/bin/varnishd/storage/storage_persistent_silo.c
@@ -253,9 +253,13 @@ smp_close_seg(struct smp_sc *sc, struct smp_seg *sg)
 	sc->cur_seg = NULL;
 
 	if (sg->nalloc == 0) {
-		/* XXX: if segment is empty, delete instead */
+		/* If segment is empty, delete instead */
 		VTAILQ_REMOVE(&sc->segments, sg, list);
-		free(sg);
+		assert(sg->p.offset >= sc->ident->stuff[SMP_SPC_STUFF]);
+		assert(sg->p.offset < sc->mediasize);
+		sc->free_offset = sg->p.offset;
+		LRU_Free(sg->lru);
+		FREE_OBJ(sg);
 		return;
 	}
 



More information about the varnish-commit mailing list