diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-14 13:00:55 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-14 13:00:55 -0800 |
| commit | f4ce5a285167e7656037096f77f04ab80a010453 (patch) | |
| tree | 48a9746e154872e4a01c9dee465aed716af278be /src/transport/tcp | |
| parent | b639e4d3643b8245b77bc8707a3a864221fad195 (diff) | |
| download | nng-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/tcp')
| -rw-r--r-- | src/transport/tcp/tcp.c | 18 |
1 files changed, 15 insertions, 3 deletions
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); } |
