aboutsummaryrefslogtreecommitdiff
path: root/src/nng_compat.c
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 /src/nng_compat.c
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 'src/nng_compat.c')
-rw-r--r--src/nng_compat.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/nng_compat.c b/src/nng_compat.c
index 2593a0dd..48b406eb 100644
--- a/src/nng_compat.c
+++ b/src/nng_compat.c
@@ -160,27 +160,26 @@ int
nn_bind(int s, const char *addr)
{
int rv;
- nng_endpoint ep;
+ nng_listener l;
- if ((rv = nng_listen((nng_socket) s, addr, &ep, NNG_FLAG_SYNCH)) !=
- 0) {
+ if ((rv = nng_listen((nng_socket) s, addr, &l, NNG_FLAG_SYNCH)) != 0) {
nn_seterror(rv);
return (-1);
}
- return ((int) ep);
+ return ((int) l);
}
int
nn_connect(int s, const char *addr)
{
- int rv;
- nng_endpoint ep;
+ int rv;
+ nng_dialer d;
- if ((rv = nng_dial((nng_socket) s, addr, &ep, 0)) != 0) {
+ if ((rv = nng_dial((nng_socket) s, addr, &d, 0)) != 0) {
nn_seterror(rv);
return (-1);
}
- return ((int) ep);
+ return ((int) d);
}
int
@@ -192,8 +191,11 @@ nn_shutdown(int s, int ep)
// ID can result in affecting the wrong socket. But this requires
// a buggy application, and because we don't recycle endpoints
// until wrap, its unlikely to actually come up in practice.
+ // Note that listeners and dialers share the same namespace
+ // in the core, so we can close either one this way.
- if ((rv = nng_endpoint_close((nng_endpoint) ep)) != 0) {
+ if (((rv = nng_dialer_close((nng_dialer) ep)) != 0) &&
+ ((rv = nng_listener_close((nng_listener) ep)) != 0)) {
nn_seterror(rv);
return (-1);
}