[master] 93686c6a2 Plug leaks caught by c80 with ASAN
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Sat Dec 28 09:20:09 UTC 2019
commit 93686c6a2993870984ee34d18705f38203560eeb
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Fri Dec 27 19:07:51 2019 +0100
Plug leaks caught by c80 with ASAN
This is only a matter of leaving the acceptor loop to always free the
poolsock before returning from the function. This was initially done in
only one place out of three, with no room to exit the accept inner loop
in the absence of an incoming connection.
With this we may have everything in place to drop the drop_pools debug
flag.
Refs 656982a5cf70
Closes #3177
diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index 0e7ee9877..169ec3d1e 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -456,13 +456,10 @@ vca_accept_task(struct worker *wrk, void *arg)
do {
i = accept(ls->sock, (void*)&wa.acceptaddr,
&wa.acceptaddrlen);
- } while (i < 0 && errno == EAGAIN);
+ } while (i < 0 && errno == EAGAIN && !ps->pool->die);
- if (i < 0 && ps->pool->die) {
- VSL(SLT_Debug, 0, "XXX Accept thread dies %p", ps);
- FREE_OBJ(ps);
- return;
- }
+ if (i < 0 && ps->pool->die)
+ break;
if (i < 0 && ls->sock == -2) {
/* Shut down in progress */
@@ -525,15 +522,19 @@ vca_accept_task(struct worker *wrk, void *arg)
* must reschedule the listening task so it will be
* taken up by another thread again.
*/
- if (!ps->pool->die)
+ if (!ps->pool->die) {
AZ(Pool_Task(wrk->pool, &ps->task,
TASK_QUEUE_VCA));
- return;
+ return;
+ }
}
if (!ps->pool->die && DO_DEBUG(DBG_SLOW_ACCEPTOR))
VTIM_sleep(2.0);
}
+
+ VSL(SLT_Debug, 0, "XXX Accept thread dies %p", ps);
+ FREE_OBJ(ps);
}
/*--------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c
index 75ed4bd94..22b2a7036 100644
--- a/bin/varnishd/cache/cache_pool.c
+++ b/bin/varnishd/cache/cache_pool.c
@@ -227,6 +227,7 @@ pool_poolherder(void *priv)
free(ppx->a_stat);
free(ppx->b_stat);
SES_DestroyPool(ppx);
+ Lck_Delete(&ppx->mtx);
FREE_OBJ(ppx);
VSC_C_main->pools--;
}
More information about the varnish-commit
mailing list