summaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-01-14 13:00:55 -0800
committerGarrett D'Amore <garrett@damore.org>2017-01-14 13:00:55 -0800
commitf4ce5a285167e7656037096f77f04ab80a010453 (patch)
tree48a9746e154872e4a01c9dee465aed716af278be /src/transport
parentb639e4d3643b8245b77bc8707a3a864221fad195 (diff)
downloadnng-f4ce5a285167e7656037096f77f04ab80a010453.tar.gz
nng-f4ce5a285167e7656037096f77f04ab80a010453.tar.bz2
nng-f4ce5a285167e7656037096f77f04ab80a010453.zip
Windows TCP now working.
There are lots of changes here, mostly stuff we did in support of Windows TCP. However, there are some bugs that were fixed, and we added some new error codes, and generalized the handling of some failures during accept. Windows IPC (NamedPipes) is still missing.
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/ipc/ipc.c17
-rw-r--r--src/transport/tcp/tcp.c18
2 files changed, 29 insertions, 6 deletions
diff --git a/src/transport/ipc/ipc.c b/src/transport/ipc/ipc.c
index 8a28dfe5..2ddc74b7 100644
--- a/src/transport/ipc/ipc.c
+++ b/src/transport/ipc/ipc.c
@@ -190,7 +190,10 @@ nni_ipc_ep_init(void **epp, const char *url, uint16_t proto)
ep->closed = 0;
ep->proto = proto;
ep->rcvmax = 1024 * 1024; // XXX: fix this
- nni_plat_ipc_init(&ep->fd);
+ if ((rv = nni_plat_ipc_init(&ep->fd)) != 0) {
+ NNI_FREE_STRUCT(ep);
+ return (rv);
+ }
(void) snprintf(ep->addr, sizeof (ep->addr), "%s", url);
@@ -273,12 +276,16 @@ nni_ipc_ep_connect(void *arg, void **pipep)
if ((pipe = NNI_ALLOC_STRUCT(pipe)) == NULL) {
return (NNG_ENOMEM);
}
- nni_plat_ipc_init(&pipe->fd);
+ if ((rv = nni_plat_ipc_init(&pipe->fd)) != 0) {
+ NNI_FREE_STRUCT(pipe);
+ return (rv);
+ }
pipe->proto = ep->proto;
pipe->rcvmax = ep->rcvmax;
rv = nni_plat_ipc_connect(&pipe->fd, path);
if (rv != 0) {
+ nni_plat_ipc_fini(&pipe->fd);
NNI_FREE_STRUCT(pipe);
return (rv);
}
@@ -327,9 +334,13 @@ nni_ipc_ep_accept(void *arg, void **pipep)
}
pipe->proto = ep->proto;
pipe->rcvmax = ep->rcvmax;
- nni_plat_ipc_init(&pipe->fd);
+ if ((rv = nni_plat_ipc_init(&pipe->fd)) != 0) {
+ NNI_FREE_STRUCT(pipe);
+ return (rv);
+ }
if ((rv = nni_plat_ipc_accept(&pipe->fd, &ep->fd)) != 0) {
+ nni_plat_ipc_fini(&pipe->fd);
NNI_FREE_STRUCT(pipe);
return (rv);
}
diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c
index 9b8cdb1d..8fcf07e5 100644
--- a/src/transport/tcp/tcp.c
+++ b/src/transport/tcp/tcp.c
@@ -180,7 +180,11 @@ nni_tcp_ep_init(void **epp, const char *url, uint16_t proto)
ep->proto = proto;
ep->ipv4only = 0;
ep->rcvmax = 1024 * 1024; // XXX: fix this
- nni_plat_tcp_init(&ep->fd);
+
+ if ((rv = nni_plat_tcp_init(&ep->fd)) != 0) {
+ NNI_FREE_STRUCT(ep);
+ return (rv);
+ }
(void) snprintf(ep->addr, sizeof (ep->addr), "%s", url);
@@ -347,7 +351,10 @@ nni_tcp_ep_connect(void *arg, void **pipep)
if ((pipe = NNI_ALLOC_STRUCT(pipe)) == NULL) {
return (NNG_ENOMEM);
}
- nni_plat_tcp_init(&pipe->fd);
+ if ((rv = nni_plat_tcp_init(&pipe->fd)) != 0) {
+ NNI_FREE_STRUCT(pipe);
+ return (rv);
+ }
pipe->proto = ep->proto;
pipe->rcvmax = ep->rcvmax;
@@ -357,6 +364,7 @@ nni_tcp_ep_connect(void *arg, void **pipep)
bindaddr = lclpart == NULL ? NULL : &lcladdr;
rv = nni_plat_tcp_connect(&pipe->fd, &remaddr, bindaddr);
if (rv != 0) {
+ nni_plat_tcp_fini(&pipe->fd);
NNI_FREE_STRUCT(pipe);
return (rv);
}
@@ -416,9 +424,13 @@ nni_tcp_ep_accept(void *arg, void **pipep)
}
pipe->proto = ep->proto;
pipe->rcvmax = ep->rcvmax;
- nni_plat_tcp_init(&pipe->fd);
+
+ if ((rv = nni_plat_tcp_init(&pipe->fd)) != 0) {
+ NNI_FREE_STRUCT(pipe);
+ }
if ((rv = nni_plat_tcp_accept(&pipe->fd, &ep->fd)) != 0) {
+ nni_plat_tcp_fini(&pipe->fd);
NNI_FREE_STRUCT(pipe);
return (rv);
}