diff options
Diffstat (limited to 'src/transport')
| -rw-r--r-- | src/transport/ipc/ipc.c | 17 | ||||
| -rw-r--r-- | src/transport/tcp/tcp.c | 18 |
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); } |
