aboutsummaryrefslogtreecommitdiff
path: root/tests/trantest.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-08-12 12:24:54 -0700
committerGarrett D'Amore <garrett@damore.org>2017-08-14 13:43:02 -0700
commit343417234aa3fd86e8ae0b56ae500a1ed3411cfc (patch)
tree728992cfe8c2987d5939026a1f734dcc58b3df18 /tests/trantest.h
parent4fb81f024e5f32a186cd5538574f8e5796980e36 (diff)
downloadnng-343417234aa3fd86e8ae0b56ae500a1ed3411cfc.tar.gz
nng-343417234aa3fd86e8ae0b56ae500a1ed3411cfc.tar.bz2
nng-343417234aa3fd86e8ae0b56ae500a1ed3411cfc.zip
fixes #62 Endpoint close should be synchronous #62
fixes #66 Make pipe and endpoint structures private This changes a number of things, refactoring endpoints and supporting code to keep their internals private, and making endpoint close synchronous. This will allow us to add a consumer facing API for nng_ep_close(), as well as property APIs, etc. While here a bunch of convoluted and dead code was cleaned up.
Diffstat (limited to 'tests/trantest.h')
-rw-r--r--tests/trantest.h54
1 files changed, 25 insertions, 29 deletions
diff --git a/tests/trantest.h b/tests/trantest.h
index 74e533bf..639d0632 100644
--- a/tests/trantest.h
+++ b/tests/trantest.h
@@ -82,14 +82,14 @@ void
trantest_conn_refused(trantest *tt)
{
Convey("Connection refused works", {
- nng_endpoint ep = 0;
+ nng_dialer d = 0;
- So(nng_dial(tt->reqsock, tt->addr, &ep, NNG_FLAG_SYNCH) ==
+ So(nng_dial(tt->reqsock, tt->addr, &d, NNG_FLAG_SYNCH) ==
NNG_ECONNREFUSED);
- So(ep == 0);
- So(nng_dial(tt->repsock, tt->addr, &ep, NNG_FLAG_SYNCH) ==
+ So(d == 0);
+ So(nng_dial(tt->repsock, tt->addr, &d, NNG_FLAG_SYNCH) ==
NNG_ECONNREFUSED);
- So(ep == 0);
+ So(d == 0);
})
}
@@ -97,14 +97,13 @@ void
trantest_duplicate_listen(trantest *tt)
{
Convey("Duplicate listen rejected", {
- nng_endpoint ep;
- So(nng_listen(tt->repsock, tt->addr, &ep, NNG_FLAG_SYNCH) ==
- 0);
- So(ep != 0);
- ep = 0;
- So(nng_listen(tt->reqsock, tt->addr, &ep, NNG_FLAG_SYNCH) ==
+ nng_listener l;
+ So(nng_listen(tt->repsock, tt->addr, &l, NNG_FLAG_SYNCH) == 0);
+ So(l != 0);
+ l = 0;
+ So(nng_listen(tt->reqsock, tt->addr, &l, NNG_FLAG_SYNCH) ==
NNG_EADDRINUSE);
- So(ep == 0);
+ So(l == 0);
})
}
@@ -112,15 +111,14 @@ void
trantest_listen_accept(trantest *tt)
{
Convey("Listen and accept", {
- nng_endpoint ep;
- ep = 0;
- So(nng_listen(tt->repsock, tt->addr, &ep, NNG_FLAG_SYNCH) ==
- 0);
- So(ep != 0);
-
- ep = 0;
- So(nng_dial(tt->reqsock, tt->addr, &ep, NNG_FLAG_SYNCH) == 0);
- So(ep != 0);
+ nng_listener l;
+ nng_dialer d;
+ So(nng_listen(tt->repsock, tt->addr, &l, NNG_FLAG_SYNCH) == 0);
+ So(l != 0);
+
+ d = 0;
+ So(nng_dial(tt->reqsock, tt->addr, &d, NNG_FLAG_SYNCH) == 0);
+ So(d != 0);
})
}
@@ -128,18 +126,16 @@ void
trantest_send_recv(trantest *tt)
{
Convey("Send and recv", {
- nng_endpoint ep = 0;
+ nng_listener l;
+ nng_dialer d;
nng_msg * send;
nng_msg * recv;
size_t len;
- ep = 0;
- So(nng_listen(tt->repsock, tt->addr, &ep, NNG_FLAG_SYNCH) ==
- 0);
- So(ep != 0);
- ep = 0;
- So(nng_dial(tt->reqsock, tt->addr, &ep, NNG_FLAG_SYNCH) == 0);
- So(ep != 0);
+ So(nng_listen(tt->repsock, tt->addr, &l, NNG_FLAG_SYNCH) == 0);
+ So(l != 0);
+ So(nng_dial(tt->reqsock, tt->addr, &d, NNG_FLAG_SYNCH) == 0);
+ So(d != 0);
send = NULL;
So(nng_msg_alloc(&send, 0) == 0);