diff options
| author | Garrett D'Amore <garrett@damore.org> | 2020-01-05 11:16:03 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2020-01-05 13:22:32 -0800 |
| commit | 1eaf9e86a8f54d77d6f392829d1b859c94965329 (patch) | |
| tree | 2efa5ea0befd760b9011989639f9572a58a55f03 /src/platform/posix/posix_tcp.h | |
| parent | 36ff88911f8c4a0859457b0fc511333965163c82 (diff) | |
| download | nng-1eaf9e86a8f54d77d6f392829d1b859c94965329.tar.gz nng-1eaf9e86a8f54d77d6f392829d1b859c94965329.tar.bz2 nng-1eaf9e86a8f54d77d6f392829d1b859c94965329.zip | |
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.
Diffstat (limited to 'src/platform/posix/posix_tcp.h')
| -rw-r--r-- | src/platform/posix/posix_tcp.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/platform/posix/posix_tcp.h b/src/platform/posix/posix_tcp.h index e1a70bc3..87312dff 100644 --- a/src/platform/posix/posix_tcp.h +++ b/src/platform/posix/posix_tcp.h @@ -1,5 +1,5 @@ // -// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // Copyright 2018 Devolutions <info@devolutions.net> // @@ -27,7 +27,21 @@ struct nni_tcp_conn { nni_tcp_dialer *dialer; nni_reap_item reap; }; -extern int nni_posix_tcp_init(nni_tcp_conn **, nni_posix_pfd *); + +struct nni_tcp_dialer { + nni_list connq; // pending connections + bool closed; + bool nodelay; + bool keepalive; + struct sockaddr_storage src; + size_t srclen; + nni_mtx mtx; + nni_atomic_u64 ref; + nni_atomic_bool fini; +}; + +extern int nni_posix_tcp_alloc(nni_tcp_conn **, nni_tcp_dialer *); +extern void nni_posix_tcp_init(nni_tcp_conn *, nni_posix_pfd *); extern void nni_posix_tcp_start(nni_tcp_conn *, int, int); extern void nni_posix_tcp_dialer_rele(nni_tcp_dialer *); |
