aboutsummaryrefslogtreecommitdiff
path: root/src/nng.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-01-05 18:02:22 -0800
committerGarrett D'Amore <garrett@damore.org>2017-01-05 18:02:22 -0800
commit1b6e9985960a1079be81a576d52aa7f3fe47c92b (patch)
tree2f6c9b33571cf30e28ca721064a9c0d038be4c42 /src/nng.h
parentb17703d1e708a99e9a46ceb012676dc89df40df5 (diff)
downloadnng-1b6e9985960a1079be81a576d52aa7f3fe47c92b.tar.gz
nng-1b6e9985960a1079be81a576d52aa7f3fe47c92b.tar.bz2
nng-1b6e9985960a1079be81a576d52aa7f3fe47c92b.zip
Add nng_shutdown() for sockets to help avoid close race.
Also we added a two phase shutdown for threads.
Diffstat (limited to 'src/nng.h')
-rw-r--r--src/nng.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/nng.h b/src/nng.h
index 61894ce8..6cf7a568 100644
--- a/src/nng.h
+++ b/src/nng.h
@@ -54,7 +54,14 @@ NNG_DECL int nng_open(nng_socket **, uint16_t proto);
// error to reference the socket in any way after this is called. Likewise,
// it is an error to reference any resources such as endpoints or
// pipes associated with the socket.
-NNG_DECL int nng_close(nng_socket *);
+NNG_DECL void nng_close(nng_socket *);
+
+// nng_shutdown shuts down the socket. This causes any threads doing
+// work for the socket or blocked in socket functions to be woken (and
+// return NNG_ECLOSED). The socket resources are still present, so it
+// is safe to call other functions; they will just return NNG_ECLOSED.
+// A call to nng_close is still required to release the resources.
+NNG_DECL int nng_shutdown(nng_socket *);
// nng_protocol returns the protocol number of the socket.
uint16_t nng_protocol(nng_socket *);