Commit f00f23d8 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

varnishtest: Don't cancel tunnel threads

Unlike other threads we cancel in varnishtest there's 2 per tunnel and
they need coordination between each other. The spec thread remains as-is
and the poll thread now checks vtc_stop after each condwait.

With this I'm no longer able to reproduce a21's timeout.

Reverts d4cf677a
parent a52a1dd4
......@@ -44,5 +44,3 @@ client c2 -connect "${t2_sock}" {
txreq
rxresp
} -run
tunnel t2 -wait
......@@ -386,11 +386,14 @@ tunnel_poll_thread(void *priv)
while (tunnel_is_open(t) && !vtc_stop) {
AZ(pthread_mutex_lock(&t->mtx));
/* NB: can be woken up by `tunnel tX -wait` */
while (t->state == TUNNEL_ACCEPT)
while (t->state == TUNNEL_ACCEPT && !vtc_stop)
AZ(pthread_cond_wait(&t->cond, &t->mtx));
state = t->state;
AZ(pthread_mutex_unlock(&t->mtx));
if (vtc_stop)
break;
assert(state < TUNNEL_POLL_DONE);
memset(pfd, 0, sizeof pfd);
......@@ -415,6 +418,9 @@ tunnel_poll_thread(void *priv)
}
AZ(pthread_mutex_unlock(&t->mtx));
if (vtc_stop)
break;
tunnel_write(t, vl, t->send_lane, "Sending");
tunnel_write(t, vl, t->recv_lane, "Receiving");
}
......@@ -651,14 +657,10 @@ tunnel_wait(struct tunnel *t)
AZ(pthread_cond_signal(&t->cond));
AZ(pthread_join(t->tspec, &res));
if (res == PTHREAD_CANCELED && !vtc_stop)
vtc_fatal(t->vl, "Tunnel spec canceled");
if (res != NULL && !vtc_stop)
vtc_fatal(t->vl, "Tunnel spec returned \"%p\"", res);
AZ(pthread_join(t->tpoll, &res));
if (res == PTHREAD_CANCELED && !vtc_stop)
vtc_fatal(t->vl, "Tunnel poll canceled");
if (res != NULL && !vtc_stop)
vtc_fatal(t->vl, "Tunnel poll returned \"%p\"", res);
......@@ -679,7 +681,6 @@ static void
tunnel_reset(void)
{
struct tunnel *t;
enum tunnel_state_e state;
while (1) {
AZ(pthread_mutex_lock(&tunnel_mtx));
......@@ -691,15 +692,7 @@ tunnel_reset(void)
if (t == NULL)
break;
AZ(pthread_mutex_lock(&t->mtx));
state = t->state;
if (state < TUNNEL_POLL_DONE)
(void)pthread_cancel(t->tpoll);
if (state < TUNNEL_SPEC_DONE)
(void)pthread_cancel(t->tspec);
AZ(pthread_mutex_unlock(&t->mtx));
if (state != TUNNEL_STOPPED)
if (t->state != TUNNEL_STOPPED)
tunnel_wait(t);
tunnel_delete(t);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment