r3919 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Thu Mar 12 11:28:58 CET 2009


Author: phk
Date: 2009-03-12 11:28:57 +0100 (Thu, 12 Mar 2009)
New Revision: 3919

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_main.c
   trunk/varnish-cache/bin/varnishd/mgt_param.c
   trunk/varnish-cache/bin/varnishd/storage_persistent.c
Log:
Add a diag_flag to make startup wait until we have loaded all objects.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2009-03-12 10:08:44 UTC (rev 3918)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2009-03-12 10:28:57 UTC (rev 3919)
@@ -670,6 +670,7 @@
 void SMP_BANchanged(const struct object *o, double t);
 void SMP_TTLchanged(const struct object *o);
 void SMP_FreeObj(struct object *o);
+void SMP_Ready(void);
 
 /*
  * A normal pointer difference is signed, but we never want a negative value

Modified: trunk/varnish-cache/bin/varnishd/cache_main.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_main.c	2009-03-12 10:08:44 UTC (rev 3918)
+++ trunk/varnish-cache/bin/varnishd/cache_main.c	2009-03-12 10:28:57 UTC (rev 3919)
@@ -129,6 +129,10 @@
 	SMS_Init();
 	STV_open();
 
+	/* Wait for persistent storage to load if asked to */
+	if (params->diag_bitmap & 0x00020000)
+		SMP_Ready();
+
 	VSL_stats->start_time = (time_t)TIM_real();
 
 	CLI_Run();

Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c	2009-03-12 10:08:44 UTC (rev 3918)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c	2009-03-12 10:28:57 UTC (rev 3919)
@@ -736,6 +736,7 @@
 		"  0x00008000 - panic to abort2().\n"
 #endif
 		"  0x00010000 - synchronize shmlog.\n"
+		"  0x00020000 - synchronous start of persistence.\n"
 		"  0x80000000 - do edge-detection on digest.\n"
 		"Use 0x notation and do the bitor in your head :-)\n",
 		0,

Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-03-12 10:08:44 UTC (rev 3918)
+++ trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-03-12 10:28:57 UTC (rev 3919)
@@ -89,6 +89,9 @@
 	unsigned		magic;
 #define SMP_SC_MAGIC		0x7b73af0a 
 
+	unsigned		flags;
+#define SMP_F_LOADED		(1 << 0)
+
 	int			fd;
 	const char		*filename;
 	off_t			mediasize;
@@ -102,8 +105,12 @@
 	struct smp_seghead	segments;
 	struct smp_seg		*cur_seg;
 	pthread_t		thread;
+
+	VTAILQ_ENTRY(smp_sc)	list;
 };
 
+static VTAILQ_HEAD(,smp_sc)	silos = VTAILQ_HEAD_INITIALIZER(silos);
+
 /*--------------------------------------------------------------------
  * Write a sha256hash after a sequence of bytes.
  */
@@ -690,6 +697,7 @@
 	VTAILQ_FOREACH(sg, &sc->segments, list)
 		smp_load_seg(sp, sc, sg);
 
+	sc->flags |= SMP_F_LOADED;
 	while (1)	
 		sleep (1);
 	return (NULL);
@@ -724,6 +732,8 @@
 	smp_new_seg(sc);
 
 	WRK_BgThread(&sc->thread, "persistence", smp_thread, sc);
+
+	VTAILQ_INSERT_TAIL(&silos, sc, list);
 }
 
 /*--------------------------------------------------------------------
@@ -831,6 +841,25 @@
 
 /*--------------------------------------------------------------------*/
 
+void
+SMP_Ready(void)
+{
+	struct smp_sc *sc;
+
+	while (1) {
+		VTAILQ_FOREACH(sc, &silos, list) {
+			if (!(sc->flags & SMP_F_LOADED)) {
+				sleep(1);
+				break;
+			}
+		}
+		if (sc == NULL)
+			break;
+	}
+}
+
+/*--------------------------------------------------------------------*/
+
 struct stevedore smp_stevedore = {
 	.magic	=	STEVEDORE_MAGIC,
 	.name	=	"persistent",



More information about the varnish-commit mailing list