Merge pull request #1758 from zeromq/revert-1757-revert-1756-replace-zmq-term

Revert "Revert "Problem: deprecated use and reference of `zmq_term`""
This commit is contained in:
Constantin Rack 2016-02-01 23:02:32 +01:00
commit c6b11ae4a7
26 changed files with 53 additions and 53 deletions

View File

@ -52,7 +52,7 @@ int main (void)
// Child process // Child process
// Immediately close parent sockets and context // Immediately close parent sockets and context
zmq_close (pull); zmq_close (pull);
zmq_term (ctx); zmq_ctx_term (ctx);
// Create new context, socket, connect and send some messages // Create new context, socket, connect and send some messages
void *child_ctx = zmq_ctx_new (); void *child_ctx = zmq_ctx_new ();

View File

@ -22,8 +22,8 @@ not yet physically transferred to the network depends on the value of the
_ZMQ_LINGER_ socket option for the specified 'socket'. _ZMQ_LINGER_ socket option for the specified 'socket'.
NOTE: The default setting of _ZMQ_LINGER_ does not discard unsent messages; NOTE: The default setting of _ZMQ_LINGER_ does not discard unsent messages;
this behaviour may cause the application to block when calling _zmq_term()_. this behaviour may cause the application to block when calling _zmq_ctx_term()_.
For details refer to linkzmq:zmq_setsockopt[3] and linkzmq:zmq_term[3]. For details refer to linkzmq:zmq_setsockopt[3] and linkzmq:zmq_ctx_term[3].
RETURN VALUE RETURN VALUE
@ -41,7 +41,7 @@ The provided 'socket' was invalid.
SEE ALSO SEE ALSO
-------- --------
linkzmq:zmq_socket[3] linkzmq:zmq_socket[3]
linkzmq:zmq_term[3] linkzmq:zmq_ctx_term[3]
linkzmq:zmq_setsockopt[3] linkzmq:zmq_setsockopt[3]
linkzmq:zmq[7] linkzmq:zmq[7]

View File

@ -30,7 +30,7 @@ applications receive termination messages, and then terminate the context
with 'ZMQ_LINGER' set to zero on all sockets. This setting is an easier way with 'ZMQ_LINGER' set to zero on all sockets. This setting is an easier way
to get the same result. When 'ZMQ_BLOCKY' is set to false, all new sockets to get the same result. When 'ZMQ_BLOCKY' is set to false, all new sockets
are given a linger timeout of zero. You must still close all sockets before are given a linger timeout of zero. You must still close all sockets before
calling zmq_term. calling zmq_ctx_term.
[horizontal] [horizontal]
Default value:: true (old behavior) Default value:: true (old behavior)

View File

@ -25,8 +25,8 @@ _ZMQ_LINGER_ socket option for the specified 'socket'.
The 'endpoint' argument is as described in linkzmq:zmq_connect[3] The 'endpoint' argument is as described in linkzmq:zmq_connect[3]
NOTE: The default setting of _ZMQ_LINGER_ does not discard unsent messages; NOTE: The default setting of _ZMQ_LINGER_ does not discard unsent messages;
this behaviour may cause the application to block when calling _zmq_term()_. this behaviour may cause the application to block when calling _zmq_ctx_term()_.
For details refer to linkzmq:zmq_setsockopt[3] and linkzmq:zmq_term[3]. For details refer to linkzmq:zmq_setsockopt[3] and linkzmq:zmq_ctx_term[3].
RETURN VALUE RETURN VALUE

View File

@ -349,12 +349,12 @@ The 'ZMQ_LINGER' option shall retrieve the linger period for the specified
'socket'. The linger period determines how long pending messages which have 'socket'. The linger period determines how long pending messages which have
yet to be sent to a peer shall linger in memory after a socket is closed with yet to be sent to a peer shall linger in memory after a socket is closed with
linkzmq:zmq_close[3], and further affects the termination of the socket's linkzmq:zmq_close[3], and further affects the termination of the socket's
context with linkzmq:zmq_term[3]. The following outlines the different context with linkzmq:zmq_ctx_term[3]. The following outlines the different
behaviours: behaviours:
* The default value of '-1' specifies an infinite linger period. Pending * The default value of '-1' specifies an infinite linger period. Pending
messages shall not be discarded after a call to _zmq_close()_; attempting to messages shall not be discarded after a call to _zmq_close()_; attempting to
terminate the socket's context with _zmq_term()_ shall block until all terminate the socket's context with _zmq_ctx_term()_ shall block until all
pending messages have been sent to a peer. pending messages have been sent to a peer.
* The value of '0' specifies no linger period. Pending messages shall be * The value of '0' specifies no linger period. Pending messages shall be
@ -362,7 +362,7 @@ behaviours:
* Positive values specify an upper bound for the linger period in milliseconds. * Positive values specify an upper bound for the linger period in milliseconds.
Pending messages shall not be discarded after a call to _zmq_close()_; Pending messages shall not be discarded after a call to _zmq_close()_;
attempting to terminate the socket's context with _zmq_term()_ shall block attempting to terminate the socket's context with _zmq_ctx_term()_ shall block
until either all pending messages have been sent to a peer, or the linger until either all pending messages have been sent to a peer, or the linger
period expires, after which any pending messages shall be discarded. period expires, after which any pending messages shall be discarded.

View File

@ -43,7 +43,7 @@ An invalid number of 'io_threads' was requested.
SEE ALSO SEE ALSO
-------- --------
linkzmq:zmq[7] linkzmq:zmq[7]
linkzmq:zmq_term[3] linkzmq:zmq_ctx_term[3]
AUTHORS AUTHORS

View File

@ -385,12 +385,12 @@ The 'ZMQ_LINGER' option shall set the linger period for the specified 'socket'.
The linger period determines how long pending messages which have yet to be The linger period determines how long pending messages which have yet to be
sent to a peer shall linger in memory after a socket is disconnected with sent to a peer shall linger in memory after a socket is disconnected with
linkzmq:zmq_disconnect[3] or closed with linkzmq:zmq_close[3], and further linkzmq:zmq_disconnect[3] or closed with linkzmq:zmq_close[3], and further
affects the termination of the socket's context with linkzmq:zmq_term[3]. The affects the termination of the socket's context with linkzmq:zmq_ctx_term[3].
following outlines the different behaviours: The following outlines the different behaviours:
* A value of '-1' specifies an infinite linger period. Pending * A value of '-1' specifies an infinite linger period. Pending
messages shall not be discarded after a call to _zmq_disconnect()_ or messages shall not be discarded after a call to _zmq_disconnect()_ or
_zmq_close()_; attempting to terminate the socket's context with _zmq_term()_ _zmq_close()_; attempting to terminate the socket's context with _zmq_ctx_term()_
shall block until all pending messages have been sent to a peer. shall block until all pending messages have been sent to a peer.
* The value of '0' specifies no linger period. Pending messages shall be * The value of '0' specifies no linger period. Pending messages shall be
@ -398,7 +398,7 @@ following outlines the different behaviours:
* Positive values specify an upper bound for the linger period in milliseconds. * Positive values specify an upper bound for the linger period in milliseconds.
Pending messages shall not be discarded after a call to _zmq_disconnect()_ or Pending messages shall not be discarded after a call to _zmq_disconnect()_ or
_zmq_close()_; attempting to terminate the socket's context with _zmq_term()_ _zmq_close()_; attempting to terminate the socket's context with _zmq_ctx_term()_
shall block until either all pending messages have been sent to a peer, or the shall block until either all pending messages have been sent to a peer, or the
linger period expires, after which any pending messages shall be discarded. linger period expires, after which any pending messages shall be discarded.

View File

@ -229,9 +229,9 @@ int main (int argc, char *argv [])
return -1; return -1;
} }
rc = zmq_term (ctx); rc = zmq_ctx_term (ctx);
if (rc != 0) { if (rc != 0) {
printf ("error in zmq_term: %s\n", zmq_strerror (errno)); printf ("error in zmq_ctx_term: %s\n", zmq_strerror (errno));
return -1; return -1;
} }

View File

@ -232,9 +232,9 @@ int main (int argc, char *argv [])
return -1; return -1;
} }
rc = zmq_term (ctx); rc = zmq_ctx_term (ctx);
if (rc != 0) { if (rc != 0) {
printf ("error in zmq_term: %s\n", zmq_strerror (errno)); printf ("error in zmq_ctx_term: %s\n", zmq_strerror (errno));
return -1; return -1;
} }

View File

@ -106,9 +106,9 @@ int main (int argc, char *argv [])
return -1; return -1;
} }
rc = zmq_term (ctx); rc = zmq_ctx_term (ctx);
if (rc != 0) { if (rc != 0) {
printf ("error in zmq_term: %s\n", zmq_strerror (errno)); printf ("error in zmq_ctx_term: %s\n", zmq_strerror (errno));
return -1; return -1;
} }

View File

@ -130,9 +130,9 @@ int main (int argc, char *argv [])
return -1; return -1;
} }
rc = zmq_term (ctx); rc = zmq_ctx_term (ctx);
if (rc != 0) { if (rc != 0) {
printf ("error in zmq_term: %s\n", zmq_strerror (errno)); printf ("error in zmq_ctx_term: %s\n", zmq_strerror (errno));
return -1; return -1;
} }

View File

@ -119,9 +119,9 @@ int main (int argc, char *argv [])
return -1; return -1;
} }
rc = zmq_term (ctx); rc = zmq_ctx_term (ctx);
if (rc != 0) { if (rc != 0) {
printf ("error in zmq_term: %s\n", zmq_strerror (errno)); printf ("error in zmq_ctx_term: %s\n", zmq_strerror (errno));
return -1; return -1;
} }

View File

@ -97,9 +97,9 @@ int main (int argc, char *argv [])
return -1; return -1;
} }
rc = zmq_term (ctx); rc = zmq_ctx_term (ctx);
if (rc != 0) { if (rc != 0) {
printf ("error in zmq_term: %s\n", zmq_strerror (errno)); printf ("error in zmq_ctx_term: %s\n", zmq_strerror (errno));
return -1; return -1;
} }

View File

@ -135,19 +135,19 @@ zmq::ctx_t::~ctx_t ()
int zmq::ctx_t::terminate () int zmq::ctx_t::terminate ()
{ {
slot_sync.lock(); slot_sync.lock();
bool saveTerminating = terminating; bool saveTerminating = terminating;
terminating = false; terminating = false;
// Connect up any pending inproc connections, otherwise we will hang // Connect up any pending inproc connections, otherwise we will hang
pending_connections_t copy = pending_connections; pending_connections_t copy = pending_connections;
for (pending_connections_t::iterator p = copy.begin (); p != copy.end (); ++p) { for (pending_connections_t::iterator p = copy.begin (); p != copy.end (); ++p) {
zmq::socket_base_t *s = create_socket (ZMQ_PAIR); zmq::socket_base_t *s = create_socket (ZMQ_PAIR);
s->bind (p->first.c_str ()); s->bind (p->first.c_str ());
s->close (); s->close ();
} }
terminating = saveTerminating; terminating = saveTerminating;
if (!starting) { if (!starting) {

View File

@ -75,7 +75,7 @@ namespace zmq
// Returns false if object is not a context. // Returns false if object is not a context.
bool check_tag (); bool check_tag ();
// This function is called when user invokes zmq_term. If there are // This function is called when user invokes zmq_ctx_term. If there are
// no more sockets open it'll cause all the infrastructure to be shut // no more sockets open it'll cause all the infrastructure to be shut
// down. If there are open sockets still, the deallocation happens // down. If there are open sockets still, the deallocation happens
// after the last one is closed. // after the last one is closed.
@ -146,8 +146,8 @@ namespace zmq
uint32_t tag; uint32_t tag;
// Sockets belonging to this context. We need the list so that // Sockets belonging to this context. We need the list so that
// we can notify the sockets when zmq_term() is called. The sockets // we can notify the sockets when zmq_ctx_term() is called.
// will return ETERM then. // The sockets will return ETERM then.
typedef array_t <socket_base_t> sockets_t; typedef array_t <socket_base_t> sockets_t;
sockets_t sockets; sockets_t sockets;
@ -159,7 +159,7 @@ namespace zmq
// yet. Launching of I/O threads is delayed. // yet. Launching of I/O threads is delayed.
bool starting; bool starting;
// If true, zmq_term was already called. // If true, zmq_ctx_term was already called.
bool terminating; bool terminating;
// Synchronisation of accesses to global slot-related data: // Synchronisation of accesses to global slot-related data:
@ -179,7 +179,7 @@ namespace zmq
uint32_t slot_count; uint32_t slot_count;
i_mailbox **slots; i_mailbox **slots;
// Mailbox for zmq_term thread. // Mailbox for zmq_ctx_term thread.
mailbox_t term_mailbox; mailbox_t term_mailbox;
// List of inproc endpoints within this context. // List of inproc endpoints within this context.

View File

@ -223,8 +223,8 @@ zmq::i_mailbox *zmq::socket_base_t::get_mailbox ()
void zmq::socket_base_t::stop () void zmq::socket_base_t::stop ()
{ {
// Called by ctx when it is terminated (zmq_term). // Called by ctx when it is terminated (zmq_ctx_term).
// 'stop' command is sent from the threads that called zmq_term to // 'stop' command is sent from the threads that called zmq_ctx_term to
// the thread owning the socket. This way, blocking call in the // the thread owning the socket. This way, blocking call in the
// owner thread can be interrupted. // owner thread can be interrupted.
send_stop (); send_stop ();
@ -1376,7 +1376,7 @@ int zmq::socket_base_t::process_commands (int timeout_, bool throttle_)
void zmq::socket_base_t::process_stop () void zmq::socket_base_t::process_stop ()
{ {
// Here, someone have called zmq_term while the socket was still alive. // Here, someone have called zmq_ctx_term while the socket was still alive.
// We'll remember the fact so that any blocking call is interrupted and any // We'll remember the fact so that any blocking call is interrupted and any
// further attempt to use the socket will return ETERM. The user is still // further attempt to use the socket will return ETERM. The user is still
// responsible for calling zmq_close on the socket though! // responsible for calling zmq_close on the socket though!

View File

@ -75,7 +75,7 @@ int main (int, char *[])
rc = zmq_close (s_out); rc = zmq_close (s_out);
assert (rc == 0); assert (rc == 0);
rc = zmq_term (ctx); rc = zmq_ctx_term (ctx);
assert (rc == 0); assert (rc == 0);
return 0; return 0;

View File

@ -104,7 +104,7 @@ int main (void)
rc = zmq_close (to); rc = zmq_close (to);
assert (rc == 0); assert (rc == 0);
rc = zmq_term (context); rc = zmq_ctx_term (context);
assert (rc == 0); assert (rc == 0);
// TEST 2 // TEST 2
@ -169,7 +169,7 @@ int main (void)
rc = zmq_close (to); rc = zmq_close (to);
assert (rc == 0); assert (rc == 0);
rc = zmq_term (context); rc = zmq_ctx_term (context);
assert (rc == 0); assert (rc == 0);
// TEST 3 // TEST 3
@ -242,7 +242,7 @@ int main (void)
rc = zmq_close (frontend); rc = zmq_close (frontend);
assert (rc == 0); assert (rc == 0);
rc = zmq_term (context); rc = zmq_ctx_term (context);
assert (rc == 0); assert (rc == 0);
} }

View File

@ -50,7 +50,7 @@ int main (void)
// Child process // Child process
// Immediately close parent sockets and context // Immediately close parent sockets and context
zmq_close (pull); zmq_close (pull);
zmq_term (ctx); zmq_ctx_term (ctx);
// Create new context, socket, connect and send some messages // Create new context, socket, connect and send some messages
void *child_ctx = zmq_ctx_new (); void *child_ctx = zmq_ctx_new ();

View File

@ -57,7 +57,7 @@ int main (void)
rc = zmq_close (sb); rc = zmq_close (sb);
assert (rc == 0); assert (rc == 0);
rc = zmq_term (ctx); rc = zmq_ctx_term (ctx);
assert (rc == 0); assert (rc == 0);
return 0 ; return 0 ;

View File

@ -146,7 +146,7 @@ int main (void)
assert (rc == 0); assert (rc == 0);
rc = zmq_close (dealer); rc = zmq_close (dealer);
assert (rc == 0); assert (rc == 0);
rc = zmq_term (ctx); rc = zmq_ctx_term (ctx);
assert (rc == 0); assert (rc == 0);
return 0 ; return 0 ;

View File

@ -57,7 +57,7 @@ int main (void)
rc = zmq_close (sb); rc = zmq_close (sb);
assert (rc == 0); assert (rc == 0);
rc = zmq_term (ctx); rc = zmq_ctx_term (ctx);
assert (rc == 0); assert (rc == 0);
return 0 ; return 0 ;

View File

@ -65,7 +65,7 @@ int main (void)
rc = zmq_close (sa); rc = zmq_close (sa);
assert (rc == 0); assert (rc == 0);
rc = zmq_term (ctx); rc = zmq_ctx_term (ctx);
assert (rc == 0); assert (rc == 0);
return 0 ; return 0 ;

View File

@ -95,7 +95,7 @@ int main (void)
rc = zmq_close (s1); rc = zmq_close (s1);
assert (rc == 0); assert (rc == 0);
rc = zmq_term (ctx); rc = zmq_ctx_term (ctx);
assert (rc == 0); assert (rc == 0);
} }

View File

@ -103,7 +103,7 @@ int main (void)
assert (rc == 0); assert (rc == 0);
rc = zmq_close (sub); rc = zmq_close (sub);
assert (rc == 0); assert (rc == 0);
rc = zmq_term (ctx); rc = zmq_ctx_term (ctx);
assert (rc == 0); assert (rc == 0);
return 0 ; return 0 ;

View File

@ -81,7 +81,7 @@ int main (void)
assert (rc == 0); assert (rc == 0);
rc = zmq_close (push); rc = zmq_close (push);
assert (rc == 0); assert (rc == 0);
rc = zmq_term (ctx); rc = zmq_ctx_term (ctx);
assert (rc == 0); assert (rc == 0);
@ -122,7 +122,7 @@ int main (void)
assert (rc == 0); assert (rc == 0);
rc = zmq_close (push); rc = zmq_close (push);
assert (rc == 0); assert (rc == 0);
rc = zmq_term (ctx); rc = zmq_ctx_term (ctx);
assert (rc == 0); assert (rc == 0);
return 0; return 0;