diff options
| -rw-r--r-- | src/platform/posix/posix_net.c | 2 | ||||
| -rw-r--r-- | src/transport/tcp/tcp.c | 2 | ||||
| -rw-r--r-- | tests/trantest.h | 14 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/platform/posix/posix_net.c b/src/platform/posix/posix_net.c index 2fdab245..c7c5ce82 100644 --- a/src/platform/posix/posix_net.c +++ b/src/platform/posix/posix_net.c @@ -137,7 +137,6 @@ nni_plat_tcp_send(nni_plat_tcpsock *s, nni_iov *iovs, int cnt) if (rv > resid) { nni_panic("writev says it wrote too much!"); } - resid -= rv; while (rv) { if (iov[i].iov_len <= rv) { @@ -366,6 +365,7 @@ nni_plat_tcp_accept(nni_plat_tcpsock *s, nni_plat_tcpsock *server) } nni_plat_tcp_setopts(fd); + s->fd = fd; return (0); } diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c index 8cd91044..00d9a2f3 100644 --- a/src/transport/tcp/tcp.c +++ b/src/transport/tcp/tcp.c @@ -401,7 +401,7 @@ nni_tcp_ep_accept(void *arg, void **pipep) int rv; - if ((pipe = NNI_ALLOC_STRUCT(pipe)) != NULL) { + if ((pipe = NNI_ALLOC_STRUCT(pipe)) == NULL) { return (NNG_ENOMEM); } pipe->proto = ep->proto; diff --git a/tests/trantest.h b/tests/trantest.h index fb5392a5..3bc47e8d 100644 --- a/tests/trantest.h +++ b/tests/trantest.h @@ -78,6 +78,19 @@ trantest_duplicate_listen(trantest *tt) } void +trantest_listen_accept(trantest *tt) +{ + Convey("Listen and accept" ,{ + nng_endpoint *ep; + So(nng_listen(tt->repsock, tt->addr, &ep, NNG_FLAG_SYNCH) == 0); + So(ep != NULL); + + So(nng_dial(tt->reqsock, tt->addr, &ep, NNG_FLAG_SYNCH) == 0); + So(ep != NULL); + }) +} + +void trantest_test_all(const char *addr) { trantest tt; @@ -92,5 +105,6 @@ trantest_test_all(const char *addr) trantest_scheme(&tt); trantest_conn_refused(&tt); trantest_duplicate_listen(&tt); + trantest_listen_accept(&tt); }) } |
