r846 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Sun Aug 20 15:38:34 CEST 2006


Author: phk
Date: 2006-08-20 15:38:34 +0200 (Sun, 20 Aug 2006)
New Revision: 846

Modified:
   trunk/varnish-cache/bin/varnishd/heritage.h
   trunk/varnish-cache/bin/varnishd/mgt_child.c
   trunk/varnish-cache/bin/varnishd/mgt_param.c
   trunk/varnish-cache/bin/varnishd/varnishd.c
Log:
Make autostart a tweakable parameter, this is useful for debugging


Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h	2006-08-20 12:15:15 UTC (rev 845)
+++ trunk/varnish-cache/bin/varnishd/heritage.h	2006-08-20 13:38:34 UTC (rev 846)
@@ -43,6 +43,9 @@
 	/* Acceptor hints */
 	unsigned		sess_timeout;
 	unsigned		send_timeout;
+
+	/* Management hints */
+	unsigned		auto_restart;
 };
 
 extern struct params *params;

Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_child.c	2006-08-20 12:15:15 UTC (rev 845)
+++ trunk/varnish-cache/bin/varnishd/mgt_child.c	2006-08-20 13:38:34 UTC (rev 846)
@@ -247,8 +247,10 @@
 	child_fds[0] = -1;
 	fprintf(stderr, "Child cleaned\n");
 
-	if (child_state == CH_DIED)
+	if (child_state == CH_DIED && params->auto_restart)
 		start_child();
+	else if (child_state == CH_DIED)
+		child_state = CH_STOPPED;
 	else if (child_state == CH_STOPPING)
 		child_state = CH_STOPPED;
 	return (0);

Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c	2006-08-20 12:15:15 UTC (rev 845)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c	2006-08-20 13:38:34 UTC (rev 846)
@@ -160,6 +160,26 @@
 
 /*--------------------------------------------------------------------*/
 
+static void
+tweak_auto_restart(struct cli *cli, struct parspec *par, const char *arg)
+{
+	unsigned u;
+
+	(void)par;
+	if (arg != NULL) {
+		u = strtoul(arg, NULL, 0);
+		if (u != 0 && u != 1) {
+			cli_out(cli, "Only zero and one allowed.\n");
+			cli_result(cli, CLIS_PARAM);
+			return;
+		}
+		params->auto_restart = u;
+	}
+	cli_out(cli, "%u {1 = yes, 0 = no}\n", params->auto_restart);
+}
+
+/*--------------------------------------------------------------------*/
+
 /*
  * Make sure to end all lines with either a space or newline of the
  * formatting will go haywire.
@@ -221,7 +241,10 @@
 		DELAYED_EFFECT
 		"See getopt(3) under SO_SNDTIMEO for more information.\n"
 		"Default is 600 seconds. " },
-		
+	{ "auto_restart", tweak_auto_restart,
+		"Restart child process automatically if it dies. "
+		"1 = yes, 0 = no.\n"
+		"Default is 1. " },
 	{ NULL, NULL, NULL }
 };
 

Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c	2006-08-20 12:15:15 UTC (rev 845)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c	2006-08-20 13:38:34 UTC (rev 846)
@@ -341,6 +341,7 @@
 	params->mem_workspace = 4096;
 	params->sess_timeout = 15;
 	params->send_timeout = 600;
+	params->auto_restart = 1;
 
 	while ((o = getopt(argc, argv, "b:df:h:p:s:t:T:Vw:")) != -1)
 		switch (o) {




More information about the varnish-commit mailing list