[master] d0a2ec9 Only handle signals if we still have a VUT
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed May 2 08:49:11 UTC 2018
commit d0a2ec9e75f4e09d9d40c057d34f66c548766c81
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 b33f5ce..5d32d6a 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 b714f54..d80986b 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 cd3f5a0..488027d 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 0000000..e8737b4
--- /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 61f0e4d..5f030c9 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