From f4ce5a285167e7656037096f77f04ab80a010453 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 14 Jan 2017 13:00:55 -0800 Subject: 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. --- src/transport/ipc/ipc.c | 17 ++++++++++++++--- src/transport/tcp/tcp.c | 18 +++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) (limited to 'src/transport') 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); } -- cgit v1.2.3-70-g09d2