From 1eaf9e86a8f54d77d6f392829d1b859c94965329 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 5 Jan 2020 11:16:03 -0800 Subject: fixes #1112 POSIX pollq finalizers could be simpler We reap the connections when closing, to ensure that the clean up is done outside the pollq thread. This also reduces pressure on the pollq, we think. But more importantly it eliminates some complex code that was meant to avoid deadlocks, but ultimately created other use-after-free challenges. This work is an enabler for further simplifications in the aio/task logic. While here we converted some potentially racy locking of the dialers and reference counts to simpler lock-free reference counting. --- src/supplemental/tcp/tcp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/supplemental/tcp/tcp.c') diff --git a/src/supplemental/tcp/tcp.c b/src/supplemental/tcp/tcp.c index 02a3351f..02d5d6ce 100644 --- a/src/supplemental/tcp/tcp.c +++ b/src/supplemental/tcp/tcp.c @@ -155,12 +155,15 @@ tcp_dialer_free(void *arg) return; } + nni_aio_stop(d->resaio); + nni_aio_stop(d->conaio); + nni_aio_fini(d->resaio); + nni_aio_fini(d->conaio); + if (d->d != NULL) { nni_tcp_dialer_close(d->d); nni_tcp_dialer_fini(d->d); } - nni_aio_fini(d->resaio); - nni_aio_fini(d->conaio); nni_mtx_fini(&d->mtx); nni_strfree(d->host); nni_strfree(d->port); -- cgit v1.2.3-70-g09d2