diff options
| author | Garrett D'Amore <garrett@damore.org> | 2019-08-09 19:29:51 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2019-09-24 18:48:50 -0700 |
| commit | e618abf8f3db2a94269a79c8901a51148d48fcc2 (patch) | |
| tree | 1ca624cefb452bcfcf34daaf919ea77a5413bc15 /src/platform/posix | |
| parent | 906d5ea1b3d67bece941d8a4e0a049e5f6c65051 (diff) | |
| download | nng-e618abf8f3db2a94269a79c8901a51148d48fcc2.tar.gz nng-e618abf8f3db2a94269a79c8901a51148d48fcc2.tar.bz2 nng-e618abf8f3db2a94269a79c8901a51148d48fcc2.zip | |
fixes #970 TCP connections through docker-proxy do not reconnect
Diffstat (limited to 'src/platform/posix')
| -rw-r--r-- | src/platform/posix/posix_ipcconn.c | 20 | ||||
| -rw-r--r-- | src/platform/posix/posix_tcpconn.c | 20 |
2 files changed, 36 insertions, 4 deletions
diff --git a/src/platform/posix/posix_ipcconn.c b/src/platform/posix/posix_ipcconn.c index 07ec6213..c9faded5 100644 --- a/src/platform/posix/posix_ipcconn.c +++ b/src/platform/posix/posix_ipcconn.c @@ -186,7 +186,7 @@ ipc_doread(ipc_conn *c) // No bytes indicates a closed descriptor. // This implicitly completes this (all!) aio. nni_aio_list_remove(aio); - nni_aio_finish_error(aio, NNG_ECLOSED); + nni_aio_finish_error(aio, NNG_ECONNSHUT); continue; } @@ -202,6 +202,22 @@ ipc_doread(ipc_conn *c) } static void +ipc_error(void *arg, int err) +{ + ipc_conn *c = arg; + nni_aio *aio; + + nni_mtx_lock(&c->mtx); + while (((aio = nni_list_first(&c->readq)) != NULL) || + ((aio = nni_list_first(&c->writeq)) != NULL)) { + nni_aio_list_remove(aio); + nni_aio_finish_error(aio, err); + } + nni_posix_pfd_close(c->pfd); + nni_mtx_unlock(&c->mtx); +} + +static void ipc_close(void *arg) { ipc_conn *c = arg; @@ -225,7 +241,7 @@ ipc_cb(nni_posix_pfd *pfd, int events, void *arg) ipc_conn *c = arg; if (events & (POLLHUP | POLLERR | POLLNVAL)) { - ipc_close(c); + ipc_error(c, NNG_ECONNSHUT); return; } nni_mtx_lock(&c->mtx); diff --git a/src/platform/posix/posix_tcpconn.c b/src/platform/posix/posix_tcpconn.c index 0d3c274d..6ca7013b 100644 --- a/src/platform/posix/posix_tcpconn.c +++ b/src/platform/posix/posix_tcpconn.c @@ -180,7 +180,7 @@ tcp_doread(nni_tcp_conn *c) // No bytes indicates a closed descriptor. // This implicitly completes this (all!) aio. nni_aio_list_remove(aio); - nni_aio_finish_error(aio, NNG_ECLOSED); + nni_aio_finish_error(aio, NNG_ECONNSHUT); continue; } @@ -196,6 +196,22 @@ tcp_doread(nni_tcp_conn *c) } static void +tcp_error(void *arg, int err) +{ + nni_tcp_conn *c = arg; + nni_aio *aio; + + nni_mtx_lock(&c->mtx); + while (((aio = nni_list_first(&c->readq)) != NULL) || + ((aio = nni_list_first(&c->writeq)) != NULL)) { + nni_aio_list_remove(aio); + nni_aio_finish_error(aio, err); + } + nni_posix_pfd_close(c->pfd); + nni_mtx_unlock(&c->mtx); +} + +static void tcp_close(void *arg) { nni_tcp_conn *c = arg; @@ -242,7 +258,7 @@ tcp_cb(nni_posix_pfd *pfd, int events, void *arg) nni_tcp_conn *c = arg; if (events & (POLLHUP | POLLERR | POLLNVAL)) { - tcp_close(c); + tcp_error(c, NNG_ECONNSHUT); return; } nni_mtx_lock(&c->mtx); |
