aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/options.c1
-rw-r--r--src/transport/inproc/inproc.c62
-rw-r--r--src/transport/ipc/ipc.c23
-rw-r--r--src/transport/tcp/tcp.c26
4 files changed, 7 insertions, 105 deletions
diff --git a/src/core/options.c b/src/core/options.c
index 55797218..bdbcaaba 100644
--- a/src/core/options.c
+++ b/src/core/options.c
@@ -328,7 +328,6 @@ nni_option_name(int id)
int
nni_option_register(const char *name, int *idp)
{
- int id;
int rv;
// Note that if the id was already in use, we will
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);
diff --git a/src/transport/ipc/ipc.c b/src/transport/ipc/ipc.c
index 3430ceb3..4324eedd 100644
--- a/src/transport/ipc/ipc.c
+++ b/src/transport/ipc/ipc.c
@@ -49,7 +49,6 @@ struct nni_ipc_pipe {
struct nni_ipc_ep {
char addr[NNG_MAXADDRLEN + 1];
nni_plat_ipc_ep *iep;
- int closed;
uint16_t proto;
size_t rcvmax;
nni_aio aio;
@@ -510,8 +509,7 @@ nni_ipc_ep_init(void **epp, const char *url, nni_sock *sock, int mode)
nni_mtx_init(&ep->mtx);
nni_aio_init(&ep->aio, nni_ipc_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;
@@ -524,7 +522,6 @@ nni_ipc_ep_close(void *arg)
nni_ipc_ep *ep = arg;
nni_mtx_lock(&ep->mtx);
- ep->closed = 1;
nni_plat_ipc_ep_close(ep->iep);
nni_mtx_unlock(&ep->mtx);
@@ -538,11 +535,7 @@ nni_ipc_ep_bind(void *arg)
int rv;
nni_mtx_lock(&ep->mtx);
- if (ep->closed) {
- rv = NNG_ECLOSED;
- } else {
- rv = nni_plat_ipc_ep_listen(ep->iep);
- }
+ rv = nni_plat_ipc_ep_listen(ep->iep);
nni_mtx_unlock(&ep->mtx);
return (rv);
}
@@ -621,16 +614,10 @@ nni_ipc_ep_accept(void *arg, nni_aio *aio)
NNI_ASSERT(ep->user_aio == NULL);
if ((rv = nni_aio_start(aio, nni_ipc_cancel_ep, ep)) != 0) {
- ep->user_aio = NULL;
nni_mtx_unlock(&ep->mtx);
return;
}
- if (ep->closed) {
- nni_aio_finish(aio, NNG_ECLOSED, 0);
- nni_mtx_unlock(&ep->mtx);
- return;
- }
ep->user_aio = aio;
nni_plat_ipc_ep_accept(ep->iep, &ep->aio);
@@ -652,12 +639,6 @@ nni_ipc_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_ipc_ep_connect(ep->iep, &ep->aio);
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);