[master] f268e93 Add a SIGUSR1 handler to flush outstanding transactions

Martin Blix Grydeland martin at varnish-cache.org
Wed Oct 9 16:03:04 CEST 2013


commit f268e93bb8636201f046ae2cbdaca560e74e47b5
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Wed Oct 9 15:08:55 2013 +0200

    Add a SIGUSR1 handler to flush outstanding transactions
    
    Also don't flush on SIGINT exit

diff --git a/include/vut.h b/include/vut.h
index 2ba148c..51f2552 100644
--- a/include/vut.h
+++ b/include/vut.h
@@ -51,6 +51,7 @@ struct VUT {
 	struct vpf_fh	*pfh;
 	int		sighup;
 	int		sigint;
+	int		sigusr1;
 };
 
 extern struct VUT VUT;
diff --git a/lib/libvarnishtools/vut.c b/lib/libvarnishtools/vut.c
index caf80e6..d318c45 100644
--- a/lib/libvarnishtools/vut.c
+++ b/lib/libvarnishtools/vut.c
@@ -76,6 +76,13 @@ vut_sigint(int sig)
 	VUT.sigint = 1;
 }
 
+static void
+vut_sigusr1(int sig)
+{
+	(void)sig;
+	VUT.sigusr1 = 1;
+}
+
 void
 VUT_Error(int status, const char *fmt, ...)
 {
@@ -216,6 +223,7 @@ VUT_Setup(void)
 	(void)signal(SIGHUP, vut_sighup);
 	(void)signal(SIGINT, vut_sigint);
 	(void)signal(SIGTERM, vut_sigint);
+	(void)signal(SIGUSR1, vut_sigusr1);
 
 	/* Open PID file */
 	if (VUT.P_arg) {
@@ -288,6 +296,13 @@ VUT_Main(VSLQ_dispatch_f *func, void *priv)
 				    VSL_Error(VUT.vsl));
 		}
 
+		if (VUT.sigusr1) {
+			/* Flush and report any incomplete records */
+			VUT.sigusr1 = 0;
+			if (VUT.vslq != NULL)
+				VSLQ_Flush(VUT.vslq, func, priv);
+		}
+
 		if (VUT.vslq == NULL) {
 			/* Reconnect VSM */
 			AZ(VUT.r_arg);
@@ -344,8 +359,6 @@ VUT_Main(VSLQ_dispatch_f *func, void *priv)
 		}
 	}
 
-	if (VUT.vslq != NULL)
-		VSLQ_Flush(VUT.vslq, func, priv);
 	if (VUT.fo)
 		fflush(VUT.fo);
 



More information about the varnish-commit mailing list