diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-07-13 03:01:05 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-07-13 03:01:05 -0700 |
| commit | 4735d7b69aaf0109b49a6a152b50099ad8400f96 (patch) | |
| tree | 226a34bca67f908e0e70a1ecc858015b4538df06 /src/transport | |
| parent | 85593e678c35c13ed2d37f7f22aa41b0b8d70825 (diff) | |
| download | nng-4735d7b69aaf0109b49a6a152b50099ad8400f96.tar.gz nng-4735d7b69aaf0109b49a6a152b50099ad8400f96.tar.bz2 nng-4735d7b69aaf0109b49a6a152b50099ad8400f96.zip | |
Windows implmentation of TCP is "working now".
This is only lightly tested, and I expect that there remain
some race conditions. Endpoint logic in particular needs
work.
Diffstat (limited to 'src/transport')
| -rw-r--r-- | src/transport/tcp/tcp.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c index e60a1b1d..875eb71a 100644 --- a/src/transport/tcp/tcp.c +++ b/src/transport/tcp/tcp.c @@ -567,15 +567,28 @@ nni_tcp_ep_close(void *arg) { nni_tcp_ep *ep = arg; + nni_mtx_lock(&ep->mtx); + ep->closed = 1; nni_plat_tcp_ep_close(ep->tep); + nni_mtx_unlock(&ep->mtx); } static int nni_tcp_ep_bind(void *arg) { nni_tcp_ep *ep = arg; + int rv; + + nni_mtx_lock(&ep->mtx); + if (ep->closed) { + nni_mtx_unlock(&ep->mtx); + return (NNG_ECLOSED); + } - return (nni_plat_tcp_ep_listen(ep->tep)); + rv = nni_plat_tcp_ep_listen(ep->tep); + nni_mtx_unlock(&ep->mtx); + + return (rv); } static void @@ -638,6 +651,10 @@ nni_tcp_ep_accept(void *arg, nni_aio *aio) int rv; nni_mtx_lock(&ep->mtx); + if (ep->closed) { + nni_aio_finish(aio, NNG_ECLOSED, 0); + nni_mtx_unlock(&ep->mtx); + } NNI_ASSERT(ep->user_aio == NULL); ep->user_aio = aio; @@ -659,6 +676,10 @@ nni_tcp_ep_connect(void *arg, nni_aio *aio) int rv; nni_mtx_lock(&ep->mtx); + if (ep->closed) { + nni_aio_finish(aio, NNG_ECLOSED, 0); + nni_mtx_unlock(&ep->mtx); + } NNI_ASSERT(ep->user_aio == NULL); ep->user_aio = aio; |
