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/inproc | |
| 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/inproc')
| -rw-r--r-- | src/transport/inproc/inproc.c | 62 |
1 files changed, 2 insertions, 60 deletions
diff --git a/src/transport/inproc/inproc.c b/src/transport/inproc/inproc.c index 5b443d63..4c79ddfd 100644 --- a/src/transport/inproc/inproc.c +++ b/src/transport/inproc/inproc.c @@ -49,8 +49,6 @@ struct nni_inproc_pair { struct nni_inproc_ep { char addr[NNG_MAXADDRLEN + 1]; int mode; - int closed; - int started; nni_list_node node; uint16_t proto; nni_cv cv; @@ -211,10 +209,8 @@ nni_inproc_ep_init(void **epp, const char *url, nni_sock *sock, int mode) return (NNG_ENOMEM); } - ep->mode = mode; - ep->closed = 0; - ep->started = 0; - ep->proto = nni_sock_proto(sock); + ep->mode = mode; + ep->proto = nni_sock_proto(sock); NNI_LIST_INIT(&ep->clients, nni_inproc_ep, node); nni_aio_list_init(&ep->aios); @@ -264,7 +260,6 @@ nni_inproc_ep_close(void *arg) nni_aio * aio; nni_mtx_lock(&nni_inproc.mx); - ep->closed = 1; if (nni_list_active(&nni_inproc.servers, ep)) { nni_list_remove(&nni_inproc.servers, ep); } @@ -374,24 +369,6 @@ nni_inproc_ep_connect(void *arg, nni_aio *aio) return; } - if (nni_list_active(&ep->clients, ep)) { - // We already have a pending connection... - nni_aio_finish_error(aio, NNG_EINVAL); - nni_mtx_unlock(&nni_inproc.mx); - return; - } - if (ep->started) { - nni_aio_finish_error(aio, NNG_EBUSY); - nni_mtx_unlock(&nni_inproc.mx); - return; - } - - if (ep->closed) { - nni_aio_finish_error(aio, NNG_ECLOSED); - nni_mtx_unlock(&nni_inproc.mx); - return; - } - if ((rv = nni_inproc_pipe_init((void *) &aio->a_pipe, ep)) != 0) { nni_aio_finish_error(aio, rv); nni_mtx_unlock(&nni_inproc.mx); @@ -400,10 +377,6 @@ nni_inproc_ep_connect(void *arg, nni_aio *aio) // Find a server. NNI_LIST_FOREACH (&nni_inproc.servers, server) { - if ((server->mode != NNI_EP_MODE_LISTEN) || - (server->started == 0)) { - continue; - } if (strcmp(server->addr, ep->addr) == 0) { break; } @@ -428,28 +401,13 @@ nni_inproc_ep_bind(void *arg) nni_inproc_ep *srch; nni_list * list = &nni_inproc.servers; - if (ep->mode != NNI_EP_MODE_LISTEN) { - return (NNG_EINVAL); - } nni_mtx_lock(&nni_inproc.mx); - if (ep->started) { - nni_mtx_unlock(&nni_inproc.mx); - return (NNG_EBUSY); - } - if (ep->closed) { - nni_mtx_unlock(&nni_inproc.mx); - return (NNG_ECLOSED); - } NNI_LIST_FOREACH (list, srch) { - if ((srch->mode != NNI_EP_MODE_LISTEN) || (!srch->started)) { - continue; - } if (strcmp(srch->addr, ep->addr) == 0) { nni_mtx_unlock(&nni_inproc.mx); return (NNG_EADDRINUSE); } } - ep->started = 1; nni_list_append(list, ep); nni_mtx_unlock(&nni_inproc.mx); return (0); @@ -468,23 +426,7 @@ nni_inproc_ep_accept(void *arg, nni_aio *aio) return; } - if (ep->mode != NNI_EP_MODE_LISTEN) { - nni_aio_finish_error(aio, NNG_EINVAL); - nni_mtx_unlock(&nni_inproc.mx); - return; - } - // We are already on the master list of servers, thanks to bind. - if (ep->closed) { - nni_aio_finish_error(aio, NNG_ECLOSED); - nni_mtx_unlock(&nni_inproc.mx); - return; - } - if (!ep->started) { - nni_aio_finish_error(aio, NNG_ESTATE); - nni_mtx_unlock(&nni_inproc.mx); - return; - } if ((rv = nni_inproc_pipe_init((void *) &aio->a_pipe, ep)) != 0) { nni_aio_finish_error(aio, rv); |
