[master] 7a4da8d Rotate log on SIGHUP

Martin Blix Grydeland martin at varnish-cache.org
Thu Jun 13 12:41:24 CEST 2013


commit 7a4da8d1d21c0aff9ced3ff77bee608d2e7b8932
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Mon May 27 16:54:26 2013 +0200

    Rotate log on SIGHUP

diff --git a/include/vapi/vapi_options.h b/include/vapi/vapi_options.h
index 6051308..71ef712 100644
--- a/include/vapi/vapi_options.h
+++ b/include/vapi/vapi_options.h
@@ -92,9 +92,7 @@
 	    " them. The file will be overwritten unless the -a option"	\
 	    " was specified. If the application receives a SIGHUP"	\
 	    " while writing to a file, it will reopen the file"		\
-	    " allowing the old one to be rotated away.\n"		\
-	    "\n"							\
-	    "XXX: Log rotation not yet implemented"			\
+	    " allowing the old one to be rotated away."			\
 	)
 
 #define VSL_OPT_x							\
diff --git a/lib/libvarnishtools/vut.c b/lib/libvarnishtools/vut.c
index 05e7ff5..9682c7d 100644
--- a/lib/libvarnishtools/vut.c
+++ b/lib/libvarnishtools/vut.c
@@ -259,6 +259,18 @@ VUT_Main(VSLQ_dispatch_f *func, void *priv)
 	}
 
 	while (!VUT.sigint) {
+		if (VUT.w_arg && VUT.sighup) {
+			/* Rotate log */
+			VUT.sighup = 0;
+			AN(VUT.fo);
+			fclose(VUT.fo);
+			VUT.fo = VSL_WriteOpen(VUT.vsl, VUT.w_arg, 0,
+			    VUT.u_opt);
+			if (VUT.fo == NULL)
+				VUT_Error(1, "Can't open output file (%s)",
+				    VSL_Error(VUT.vsl));
+		}
+
 		if (VUT.vslq == NULL) {
 			AZ(VUT.r_arg);
 			AN(VUT.vsm);



More information about the varnish-commit mailing list