diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-07-31 12:33:58 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-08-05 18:45:04 +0300 |
| commit | d7f7c896c0ede24249ef63b1e45b1878bf4bd473 (patch) | |
| tree | 32eece7d91a648f24cb174096fb9667cab978f37 /src/platform | |
| parent | ccc24a8e508131a2226474642a038baaa2cbcc8c (diff) | |
| download | nng-d7f7c896c0ede24249ef63b1e45b1878bf4bd473.tar.gz nng-d7f7c896c0ede24249ef63b1e45b1878bf4bd473.tar.bz2 nng-d7f7c896c0ede24249ef63b1e45b1878bf4bd473.zip | |
fixes #599 nng_dial sync should not return until added to socket
fixes #208 pipe start should occur before connect / accept
fixes #616 Race condition closing between header & body
This refactors the transports to handle their own connection
handshaking before passing the pipe to the socket. This
changes and simplifies the setup. This also fixes a rather
challenging race condition described by #616.
Diffstat (limited to 'src/platform')
| -rw-r--r-- | src/platform/posix/posix_ipcconn.c | 8 | ||||
| -rw-r--r-- | src/platform/posix/posix_tcpconn.c | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/platform/posix/posix_ipcconn.c b/src/platform/posix/posix_ipcconn.c index 2b46fb12..539a00ba 100644 --- a/src/platform/posix/posix_ipcconn.c +++ b/src/platform/posix/posix_ipcconn.c @@ -47,6 +47,10 @@ ipc_conn_dowrite(nni_ipc_conn *c) int fd; if (c->closed || ((fd = nni_posix_pfd_fd(c->pfd)) < 0)) { + while ((aio = nni_list_first(&c->writeq)) != NULL) { + nni_aio_list_remove(aio); + nni_aio_finish_error(aio, NNG_ECLOSED); + } return; } @@ -129,6 +133,10 @@ ipc_conn_doread(nni_ipc_conn *c) int fd; if (c->closed || ((fd = nni_posix_pfd_fd(c->pfd)) < 0)) { + while ((aio = nni_list_first(&c->readq)) != NULL) { + nni_aio_list_remove(aio); + nni_aio_finish_error(aio, NNG_ECLOSED); + } return; } diff --git a/src/platform/posix/posix_tcpconn.c b/src/platform/posix/posix_tcpconn.c index c0352c55..cf85e8e8 100644 --- a/src/platform/posix/posix_tcpconn.c +++ b/src/platform/posix/posix_tcpconn.c @@ -43,6 +43,10 @@ tcp_conn_dowrite(nni_tcp_conn *c) int fd; if (c->closed || ((fd = nni_posix_pfd_fd(c->pfd)) < 0)) { + while ((aio = nni_list_first(&c->writeq)) != NULL) { + nni_aio_list_remove(aio); + nni_aio_finish_error(aio, NNG_ECLOSED); + } return; } @@ -125,6 +129,10 @@ tcp_conn_doread(nni_tcp_conn *c) int fd; if (c->closed || ((fd = nni_posix_pfd_fd(c->pfd)) < 0)) { + while ((aio = nni_list_first(&c->readq)) != NULL) { + nni_aio_list_remove(aio); + nni_aio_finish_error(aio, NNG_ECLOSED); + } return; } |
