[master] 815e32a Escalate the signals if HAproxy refuses to die
Poul-Henning Kamp
phk at FreeBSD.org
Sat Apr 7 10:28:10 UTC 2018
commit 815e32a024c0c4c8969d649fc8518528fc3157d2
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sat Apr 7 10:27:04 2018 +0000
Escalate the signals if HAproxy refuses to die
diff --git a/bin/varnishtest/vtc_haproxy.c b/bin/varnishtest/vtc_haproxy.c
index ea66f81..73f42b8 100644
--- a/bin/varnishtest/vtc_haproxy.c
+++ b/bin/varnishtest/vtc_haproxy.c
@@ -312,7 +312,7 @@ static void
haproxy_wait(struct haproxy *h)
{
void *p;
- int i;
+ int i, n, sig;
vtc_log(h->vl, 2, "Wait");
@@ -321,16 +321,28 @@ haproxy_wait(struct haproxy *h)
closefd(&h->fds[1]);
+ sig = SIGINT;
+ n = 0;
+ vtc_log(h->vl, 2, "Stop HAproxy pid=%ld", (long)h->pid);
while (!h->opt_check_mode && !h->its_dead_jim) {
assert(h->pid > 0);
- vtc_log(h->vl, 2, "Stop HAproxy pid=%ld", (long)h->pid);
- i= kill(h->pid, HAPROXY_SIGNAL);
- h->expect_signal = -HAPROXY_SIGNAL;
- if (i && errno == ESRCH)
- break;
- if (i)
- vtc_log(h->vl, 4, "Kill=%d: %s", i, strerror(errno));
+ if (n == 0) {
+ i= kill(h->pid, sig);
+ vtc_log(h->vl, 4,
+ "Kill(%d)=%d: %s", sig, i, strerror(errno));
+ h->expect_signal = -sig;
+ if (i && errno == ESRCH)
+ break;
+ }
usleep(100000);
+ if (++n == 20) {
+ switch (sig) {
+ case SIGINT: sig = SIGTERM ; break;
+ case SIGTERM: sig = SIGKILL ; break;
+ default: break;
+ }
+ n = 0;
+ }
}
AZ(pthread_join(h->tp, &p));
More information about the varnish-commit
mailing list