diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-08-23 13:20:24 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-08-23 21:14:19 -0700 |
| commit | 2ec64a78da8df01ec534161475a87989ae527776 (patch) | |
| tree | 430d4289ca56e123cf2b2be76cf90a6c346bf27c /src/transport/tcp | |
| parent | 8ad296769192cf4628710ac0b228be2aca6d8dad (diff) | |
| download | nng-2ec64a78da8df01ec534161475a87989ae527776.tar.gz nng-2ec64a78da8df01ec534161475a87989ae527776.tar.bz2 nng-2ec64a78da8df01ec534161475a87989ae527776.zip | |
The common endpoint code already ensures state is proper.
This eliminates tests for code that we cannot reach, because the
upper layer endpoint code already ensures that we don't get called
if we are closing, that the mode is correct, and that only one
outstanding endpoint operation is in progress on any given endpoint.
Diffstat (limited to 'src/transport/tcp')
| -rw-r--r-- | src/transport/tcp/tcp.c | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c index 24362fcd..f5e5ad87 100644 --- a/src/transport/tcp/tcp.c +++ b/src/transport/tcp/tcp.c @@ -48,7 +48,6 @@ struct nni_tcp_pipe { struct nni_tcp_ep { char addr[NNG_MAXADDRLEN + 1]; nni_plat_tcp_ep *tep; - int closed; uint16_t proto; size_t rcvmax; nni_duration linger; @@ -630,8 +629,7 @@ nni_tcp_ep_init(void **epp, const char *url, nni_sock *sock, int mode) nni_mtx_init(&ep->mtx); nni_aio_init(&ep->aio, nni_tcp_ep_cb, ep); - ep->closed = 0; - ep->proto = nni_sock_proto(sock); + ep->proto = nni_sock_proto(sock); (void) snprintf(ep->addr, sizeof(ep->addr), "%s", url); *epp = ep; @@ -644,7 +642,6 @@ 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); @@ -658,11 +655,6 @@ nni_tcp_ep_bind(void *arg) int rv; nni_mtx_lock(&ep->mtx); - if (ep->closed) { - nni_mtx_unlock(&ep->mtx); - return (NNG_ECLOSED); - } - rv = nni_plat_tcp_ep_listen(ep->tep); nni_mtx_unlock(&ep->mtx); @@ -739,19 +731,13 @@ nni_tcp_ep_accept(void *arg, nni_aio *aio) nni_mtx_lock(&ep->mtx); NNI_ASSERT(ep->user_aio == NULL); - if (ep->closed) { - nni_aio_finish(aio, NNG_ECLOSED, 0); - nni_mtx_unlock(&ep->mtx); - return; - } - ep->user_aio = aio; - if ((rv = nni_aio_start(aio, nni_tcp_cancel_ep, ep)) != 0) { - ep->user_aio = NULL; nni_mtx_unlock(&ep->mtx); return; } + ep->user_aio = aio; + nni_plat_tcp_ep_accept(ep->tep, &ep->aio); nni_mtx_unlock(&ep->mtx); } @@ -771,12 +757,6 @@ nni_tcp_ep_connect(void *arg, nni_aio *aio) return; } - if (ep->closed) { - nni_aio_finish(aio, NNG_ECLOSED, 0); - nni_mtx_unlock(&ep->mtx); - return; - } - ep->user_aio = aio; nni_plat_tcp_ep_connect(ep->tep, &ep->aio); |
