r4355 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Wed Nov 18 20:54:32 CET 2009
Author: phk
Date: 2009-11-18 20:54:32 +0100 (Wed, 18 Nov 2009)
New Revision: 4355
Modified:
trunk/varnish-cache/bin/varnishd/storage_persistent.c
Log:
Close a race that demonstrates that I have no idea what kind of load
my users have:
Do not load new segments opened after we started, even if multiple such
have been created, before we finish loading the old segments from the
silo.
Fixes #564
Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_persistent.c 2009-11-18 19:05:07 UTC (rev 4354)
+++ trunk/varnish-cache/bin/varnishd/storage_persistent.c 2009-11-18 19:54:32 UTC (rev 4355)
@@ -99,6 +99,8 @@
struct smp_segptr p;
+ unsigned must_load;
+
uint32_t nobj; /* Number of objects */
uint32_t nalloc; /* Allocations */
uint32_t nalloc1; /* Allocated objects */
@@ -884,7 +886,11 @@
struct smp_signctx ctx[1];
ASSERT_SILO_THREAD(sc);
- (void)sp;
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(sg, SMP_SEG_MAGIC);
+ CHECK_OBJ_NOTNULL(sg->lru, LRU_MAGIC);
+ assert(sg->must_load == 1);
+ sg->must_load = 0;
AN(sg->p.offset);
if (sg->p.objlist == 0)
return;
@@ -1005,7 +1011,11 @@
ALLOC_OBJ(sg, SMP_SEG_MAGIC);
AN(sg);
sg->lru = LRU_Alloc();
+ CHECK_OBJ_NOTNULL(sg->lru, LRU_MAGIC);
sg->p = *ss;
+
+ sg->must_load = 1;
+
/*
* HACK: prevent save_segs from nuking segment until we have
* HACK: loaded it.
@@ -1052,6 +1062,8 @@
ALLOC_OBJ(sg, SMP_SEG_MAGIC);
AN(sg);
sg->sc = sc;
+ sg->lru = LRU_Alloc();
+ CHECK_OBJ_NOTNULL(sg->lru, LRU_MAGIC);
AN(sc->objbuf);
sg->objs = sc->objbuf;
@@ -1189,7 +1201,8 @@
/* First, load all the objects from all segments */
VTAILQ_FOREACH(sg, &sc->segments, list)
- smp_load_seg(sp, sc, sg);
+ if (sg->must_load)
+ smp_load_seg(sp, sc, sg);
sc->flags |= SMP_F_LOADED;
BAN_Deref(&sc->tailban);
More information about the varnish-commit
mailing list