diff --git a/builds/redhat/zeromq.spec.in b/builds/redhat/zeromq.spec.in index 8261b203..31156870 100644 --- a/builds/redhat/zeromq.spec.in +++ b/builds/redhat/zeromq.spec.in @@ -113,6 +113,7 @@ This package contains ZeroMQ related development libraries and header files. %{_mandir}/man3/zmq_ctx_get.3.gz %{_mandir}/man3/zmq_ctx_new.3.gz %{_mandir}/man3/zmq_ctx_set.3.gz +%{_mandir}/man3/zmq_ctx_term.3.gz %{_mandir}/man3/zmq_msg_recv.3.gz %{_mandir}/man3/zmq_errno.3.gz %{_mandir}/man3/zmq_getsockopt.3.gz diff --git a/doc/Makefile.am b/doc/Makefile.am index 2a19124a..6f41ce2b 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,5 +1,5 @@ MAN3 = zmq_bind.3 zmq_unbind.3 zmq_connect.3 zmq_disconnect.3 zmq_close.3 \ - zmq_ctx_new.3 zmq_ctx_destroy.3 zmq_ctx_get.3 zmq_ctx_set.3 \ + zmq_ctx_new.3 zmq_ctx_term.3 zmq_ctx_destroy.3 zmq_ctx_get.3 zmq_ctx_set.3 \ zmq_msg_init.3 zmq_msg_init_data.3 zmq_msg_init_size.3 \ zmq_msg_move.3 zmq_msg_copy.3 zmq_msg_size.3 zmq_msg_data.3 zmq_msg_close.3 \ zmq_msg_send.3 zmq_msg_recv.3 \ diff --git a/doc/zmq.txt b/doc/zmq.txt index 4c79e4d6..373b1fdd 100644 --- a/doc/zmq.txt +++ b/doc/zmq.txt @@ -42,7 +42,7 @@ Work with context properties:: linkzmq:zmq_ctx_get[3] Destroy a 0MQ context:: - linkzmq:zmq_ctx_destroy[3] + linkzmq:zmq_ctx_term[3] Monitor a 0MQ context:: linkzmq:zmq_ctx_set_monitor[3] diff --git a/doc/zmq_ctx_destroy.txt b/doc/zmq_ctx_destroy.txt index 640b6b8a..f023227c 100644 --- a/doc/zmq_ctx_destroy.txt +++ b/doc/zmq_ctx_destroy.txt @@ -4,7 +4,7 @@ zmq_ctx_destroy(3) NAME ---- -zmq_ctx_destroy - destroy a 0MQ context +zmq_ctx_destroy - terminate a 0MQ context SYNOPSIS @@ -36,7 +36,7 @@ Context termination is performed in the following steps: For further details regarding socket linger behavior refer to the _ZMQ_LINGER_ option in linkzmq:zmq_setsockopt[3]. -This function replaces the deprecated function linkzmq:zmq_term[3]. +This function is deprecated by linkzmq:zmq_ctx_term[3]. RETURN VALUE diff --git a/doc/zmq_ctx_new.txt b/doc/zmq_ctx_new.txt index cd1bbca8..c08a1ce7 100644 --- a/doc/zmq_ctx_new.txt +++ b/doc/zmq_ctx_new.txt @@ -41,7 +41,7 @@ SEE ALSO linkzmq:zmq[7] linkzmq:zmq_ctx_set[3] linkzmq:zmq_ctx_get[3] -linkzmq:zmq_ctx_destroy[3] +linkzmq:zmq_ctx_term[3] AUTHORS diff --git a/doc/zmq_ctx_term.txt b/doc/zmq_ctx_term.txt new file mode 100644 index 00000000..036b30ef --- /dev/null +++ b/doc/zmq_ctx_term.txt @@ -0,0 +1,66 @@ +zmq_ctx_term(3) +================== + + +NAME +---- +zmq_ctx_term - destroy a 0MQ context + + +SYNOPSIS +-------- +*int zmq_ctx_term (void '*context');* + + +DESCRIPTION +----------- +The _zmq_ctx_term()_ function shall destroy the 0MQ context 'context'. + +Context termination is performed in the following steps: + +1. Any blocking operations currently in progress on sockets open within + 'context' shall return immediately with an error code of ETERM. With the + exception of _zmq_close()_, any further operations on sockets open within + 'context' shall fail with an error code of ETERM. + +2. After interrupting all blocking calls, _zmq_ctx_term()_ shall _block_ until the + following conditions are satisfied: + + * All sockets open within 'context' have been closed with _zmq_close()_. + + * For each socket within 'context', all messages sent by the application + with _zmq_send()_ have either been physically transferred to a network + peer, or the socket's linger period set with the _ZMQ_LINGER_ socket + option has expired. + +For further details regarding socket linger behavior refer to the _ZMQ_LINGER_ +option in linkzmq:zmq_setsockopt[3]. + +This function replaces the deprecated function linkzmq:zmq_term[3]. + + +RETURN VALUE +------------ +The _zmq_ctx_term()_ function shall return zero if successful. Otherwise +it shall return `-1` and set 'errno' to one of the values defined below. + + +ERRORS +------ +*EFAULT*:: +The provided 'context' was invalid. +*EINTR*:: +Termination was interrupted by a signal. It can be restarted if needed. + + +SEE ALSO +-------- +linkzmq:zmq[7] +linkzmq:zmq_init[3] +linkzmq:zmq_close[3] +linkzmq:zmq_setsockopt[3] + + +AUTHORS +------- +This 0MQ manual page was written by Pieter Hintjens diff --git a/doc/zmq_term.txt b/doc/zmq_term.txt index f3604ce5..ecf98969 100644 --- a/doc/zmq_term.txt +++ b/doc/zmq_term.txt @@ -36,7 +36,7 @@ Context termination is performed in the following steps: For further details regarding socket linger behaviour refer to the _ZMQ_LINGER_ option in linkzmq:zmq_setsockopt[3]. -This function is deprecated by linkzmq:zmq_ctx_destroy[3]. +This function is deprecated by linkzmq:zmq_ctx_term[3]. RETURN VALUE ------------ diff --git a/include/zmq.h b/include/zmq.h index a4b99750..ce00567d 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -163,13 +163,14 @@ ZMQ_EXPORT const char *zmq_strerror (int errnum); #define ZMQ_MAX_SOCKETS_DFLT 1024 ZMQ_EXPORT void *zmq_ctx_new (void); -ZMQ_EXPORT int zmq_ctx_destroy (void *context); +ZMQ_EXPORT int zmq_ctx_term (void *context); ZMQ_EXPORT int zmq_ctx_set (void *context, int option, int optval); ZMQ_EXPORT int zmq_ctx_get (void *context, int option); /* Old (legacy) API */ ZMQ_EXPORT void *zmq_init (int io_threads); ZMQ_EXPORT int zmq_term (void *context); +ZMQ_EXPORT int zmq_ctx_destroy (void *context); /******************************************************************************/ diff --git a/src/zmq.cpp b/src/zmq.cpp index 6a74989b..52698b1c 100644 --- a/src/zmq.cpp +++ b/src/zmq.cpp @@ -163,7 +163,7 @@ void *zmq_ctx_new (void) return ctx; } -int zmq_ctx_destroy (void *ctx_) +int zmq_ctx_term (void *ctx_) { if (!ctx_ || !((zmq::ctx_t*) ctx_)->check_tag ()) { errno = EFAULT; @@ -225,7 +225,12 @@ void *zmq_init (int io_threads_) int zmq_term (void *ctx_) { - return zmq_ctx_destroy (ctx_); + return zmq_ctx_term (ctx_); +} + +int zmq_ctx_destroy (void *ctx_) +{ + return zmq_ctx_term (ctx_); } diff --git a/tests/test_connect_delay.cpp b/tests/test_connect_delay.cpp index ad419929..e10b12ff 100644 --- a/tests/test_connect_delay.cpp +++ b/tests/test_connect_delay.cpp @@ -101,7 +101,7 @@ int main (void) rc = zmq_close (to); assert (rc == 0); - rc = zmq_ctx_destroy(context); + rc = zmq_ctx_term(context); assert (rc == 0); // TEST 2 @@ -172,7 +172,7 @@ int main (void) rc = zmq_close (to); assert (rc == 0); - rc = zmq_ctx_destroy(context); + rc = zmq_ctx_term(context); assert (rc == 0); // TEST 3 @@ -219,7 +219,7 @@ int main (void) rc = zmq_close (to); assert (rc == 0); - rc = zmq_ctx_destroy(context2); + rc = zmq_ctx_term(context2); assert (rc == 0); // Give time to process disconnect @@ -252,9 +252,9 @@ int main (void) rc = zmq_close (from); assert (rc == 0); - rc = zmq_ctx_destroy(context); + rc = zmq_ctx_term(context); assert (rc == 0); - rc = zmq_ctx_destroy(context2); + rc = zmq_ctx_term(context2); assert (rc == 0); } diff --git a/tests/test_disconnect_inproc.cpp b/tests/test_disconnect_inproc.cpp index 78750830..94f8113c 100644 --- a/tests/test_disconnect_inproc.cpp +++ b/tests/test_disconnect_inproc.cpp @@ -114,7 +114,7 @@ int main(int argc, char** argv) { zmq_close(pubSocket) && printf("zmq_close: %s", zmq_strerror(errno)); zmq_close(subSocket) && printf("zmq_close: %s", zmq_strerror(errno)); - zmq_ctx_destroy(context); + zmq_ctx_term(context); return 0; }