[6.0] a247f4487 Only handle signals if we still have a VUT

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Thu Aug 16 08:52:53 UTC 2018


commit a247f4487aad8d7fb9404710c1235530d379794a
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Wed May 2 10:37:24 2018 +0200

    Only handle signals if we still have a VUT
    
    This can happen if a signal is caught after `VUT_Fini` was called, but
    at this point we should no longer manipulate the VUT being dismantled.
    
    Original test case by Geoff, slightly modified.
    
    Closes #2650

diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c
index b33f5ce73..5d32d6a80 100644
--- a/bin/varnishhist/varnishhist.c
+++ b/bin/varnishhist/varnishhist.c
@@ -494,7 +494,9 @@ profile_error(const char *s)
 static void
 vut_sighandler(int sig)
 {
-	VUT_Signaled(vut, sig);
+
+	if (vut != NULL)
+		VUT_Signaled(vut, sig);
 }
 
 int
diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c
index b714f54cb..d80986b78 100644
--- a/bin/varnishlog/varnishlog.c
+++ b/bin/varnishlog/varnishlog.c
@@ -124,8 +124,9 @@ sighup(struct VUT *v)
 static void
 vut_sighandler(int sig)
 {
-	CHECK_OBJ_NOTNULL(vut, VUT_MAGIC);
-	VUT_Signaled(vut, sig);
+
+	if (vut != NULL)
+		VUT_Signaled(vut, sig);
 }
 
 int
diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c
index cd3f5a027..488027d0e 100644
--- a/bin/varnishncsa/varnishncsa.c
+++ b/bin/varnishncsa/varnishncsa.c
@@ -1124,8 +1124,9 @@ sighup(struct VUT *v)
 static void
 vut_sighandler(int sig)
 {
-	CHECK_OBJ_NOTNULL(vut, VUT_MAGIC);
-	VUT_Signaled(vut, sig);
+
+	if (vut != NULL)
+		VUT_Signaled(vut, sig);
 }
 
 static char *
diff --git a/bin/varnishtest/tests/r02649.vtc b/bin/varnishtest/tests/r02649.vtc
new file mode 100644
index 000000000..e8737b4f4
--- /dev/null
+++ b/bin/varnishtest/tests/r02649.vtc
@@ -0,0 +1,18 @@
+varnishtest "Cleanly stop a VUT app via vtc process -stop"
+
+varnish v1 -vcl {
+	backend be {
+		.host = "${bad_backend}";
+	}
+} -start
+
+process p1 {
+	exec varnishncsa -n ${v1_name} -P ${tmpdir}/ncsa.pid -w ${tmpdir}/ncsa.log
+} -start
+
+delay 1
+
+process p1 -expect-exit 0 -stop -wait
+
+# Expect empty stderr output
+shell -match {^0\b} "wc -c ${tmpdir}/p1/stderr"
diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c
index 61f0e4d44..5f030c9a1 100644
--- a/bin/varnishtop/varnishtop.c
+++ b/bin/varnishtop/varnishtop.c
@@ -195,8 +195,9 @@ sighup(struct VUT *v)
 static void
 vut_sighandler(int sig)
 {
-	CHECK_OBJ_NOTNULL(vut, VUT_MAGIC);
-	VUT_Signaled(vut, sig);
+
+	if (vut != NULL)
+		VUT_Signaled(vut, sig);
 }
 
 static void


More information about the varnish-commit mailing list