0
0
mirror of https://github.com/zeromq/libzmq.git synced 2025-01-14 01:37:56 +08:00

Fixed use of deprecated zmq_init/term

This commit is contained in:
Pieter Hintjens 2013-01-31 09:10:49 +01:00
parent 5f009e5234
commit 8c9289342a
19 changed files with 56 additions and 41 deletions

View File

@ -29,7 +29,7 @@ int main (void)
{
fprintf (stderr, "test_connect_resolve running...\n");
void *ctx = zmq_init (1);
void *ctx = zmq_ctx_new ();
assert (ctx);
// Create pair of socket, each with high watermark of 2. Thus the total
@ -47,7 +47,7 @@ int main (void)
rc = zmq_close (sock);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0;

View File

@ -26,7 +26,7 @@ int main (void)
{
fprintf (stderr, "test_hwm running...\n");
void *ctx = zmq_init (1);
void *ctx = zmq_ctx_new ();
assert (ctx);
// Create pair of socket, each with high watermark of 2. Thus the total
@ -76,7 +76,7 @@ int main (void)
rc = zmq_close (sb);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0;

View File

@ -30,12 +30,15 @@ int main (void)
fprintf (stderr, "test_invalid_rep running...\n");
// Create REQ/ROUTER wiring.
void *ctx = zmq_init (1);
void *ctx = zmq_ctx_new ();
assert (ctx);
void *router_socket = zmq_socket (ctx, ZMQ_ROUTER);
assert (router_socket);
void *req_socket = zmq_socket (ctx, ZMQ_REQ);
assert (req_socket);
int linger = 0;
int rc = zmq_setsockopt (router_socket, ZMQ_LINGER, &linger, sizeof (int));
assert (rc == 0);
@ -84,7 +87,7 @@ int main (void)
assert (rc == 0);
rc = zmq_close (req_socket);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0;

View File

@ -38,16 +38,25 @@ static void do_bind_and_verify (void *s, const char *endpoint)
int main (void)
{
// Create the infrastructure
void *ctx = zmq_init (1);
void *ctx = zmq_ctx_new ();
assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_ROUTER);
assert (sb);
int val = 0;
int rc = zmq_setsockopt (sb, ZMQ_LINGER, &val, sizeof (val));
assert (rc == 0);
do_bind_and_verify (sb, "tcp://127.0.0.1:5560");
do_bind_and_verify (sb, "tcp://127.0.0.1:5561");
do_bind_and_verify (sb, "ipc:///tmp/testep");
rc = zmq_close (sb);
assert (rc == 0);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0 ;
}

View File

@ -192,7 +192,7 @@ int main (void)
addr = "tcp://127.0.0.1:5560";
// Create the infrastructure
void *ctx = zmq_init (1);
void *ctx = zmq_ctx_new ();
assert (ctx);
// REP socket
@ -266,7 +266,7 @@ int main (void)
// Allow for closed or disconnected events to bubble up
zmq_sleep (1);
zmq_term (ctx);
zmq_ctx_term (ctx);
// Expected REP socket events
assert (rep_socket_events & ZMQ_EVENT_LISTENING);

View File

@ -28,14 +28,18 @@
int main (void)
{
// Create the infrastructure
void *ctx = zmq_init (0);
void *ctx = zmq_ctx_new ();
assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_ROUTER);
assert (sb);
int rc = zmq_bind (sb, "inproc://a");
assert (rc == 0);
void *sc = zmq_socket (ctx, ZMQ_DEALER);
assert (sc);
rc = zmq_connect (sc, "inproc://a");
assert (rc == 0);
@ -69,9 +73,11 @@ int main (void)
// Deallocate the infrastructure.
rc = zmq_close (sc);
assert (rc == 0);
rc = zmq_close (sb);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0 ;
}

View File

@ -25,7 +25,7 @@ int main (void)
{
fprintf (stderr, "test_pair_inproc running...\n");
void *ctx = zmq_init (0);
void *ctx = zmq_ctx_new ();
assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_PAIR);
@ -46,7 +46,7 @@ int main (void)
rc = zmq_close (sb);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0 ;

View File

@ -25,7 +25,7 @@ int main (void)
{
fprintf (stderr, "test_pair_ipc running...\n");
void *ctx = zmq_init (1);
void *ctx = zmq_ctx_new ();
assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_PAIR);
@ -46,7 +46,7 @@ int main (void)
rc = zmq_close (sb);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0 ;

View File

@ -26,7 +26,7 @@ int main (void)
{
fprintf (stderr, "test_pair_tcp running...\n");
void *ctx = zmq_init (1);
void *ctx = zmq_ctx_new ();
assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_PAIR);
@ -47,7 +47,7 @@ int main (void)
rc = zmq_close (sb);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0 ;

View File

@ -1,6 +1,5 @@
/*
Copyright (c) 2007-2012 iMatix Corporation
Copyright (c) 2011 250bpm s.r.o.
Copyright (c) 2007-2012 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.

View File

@ -30,7 +30,7 @@ int main (void)
{
fprintf (stderr, "test_reqrep_device running...\n");
void *ctx = zmq_init (1);
void *ctx = zmq_ctx_new ();
assert (ctx);
// Create a req/rep device.
@ -136,7 +136,7 @@ int main (void)
assert (rc == 0);
rc = zmq_close (dealer);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0 ;

View File

@ -25,7 +25,7 @@ int main (void)
{
fprintf (stderr, "test_reqrep_inproc running...\n");
void *ctx = zmq_init (0);
void *ctx = zmq_ctx_new ();
assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_REP);
@ -46,7 +46,7 @@ int main (void)
rc = zmq_close (sb);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0 ;

View File

@ -25,7 +25,7 @@ int main (void)
{
fprintf (stderr, "test_reqrep_ipc running...\n");
void *ctx = zmq_init (1);
void *ctx = zmq_ctx_new ();
assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_REP);
@ -46,7 +46,7 @@ int main (void)
rc = zmq_close (sb);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0 ;

View File

@ -26,7 +26,7 @@ int main (void)
{
fprintf (stderr, "test_reqrep_tcp running...\n");
void *ctx = zmq_init (1);
void *ctx = zmq_ctx_new ();
assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_REP);
@ -47,7 +47,7 @@ int main (void)
rc = zmq_close (sb);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0 ;

View File

@ -27,7 +27,7 @@ int main (void)
{
fprintf (stderr, "test_router_mandatory running...\n");
void *ctx = zmq_init (1);
void *ctx = zmq_ctx_new ();
assert (ctx);
// Creating the first socket.
@ -98,7 +98,7 @@ int main (void)
rc = zmq_close (sb);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0 ;

View File

@ -48,7 +48,6 @@ extern "C"
int main (void)
{
void *ctx;
void *s1;
void *s2;
int i;
@ -61,8 +60,9 @@ int main (void)
for (j = 0; j != 10; j++) {
// Check the shutdown with many parallel I/O threads.
ctx = zmq_init (7);
void *ctx = zmq_ctx_new ();
assert (ctx);
zmq_ctx_set (ctx, ZMQ_IO_THREADS, 7);
s1 = zmq_socket (ctx, ZMQ_PUB);
assert (s1);
@ -85,7 +85,7 @@ int main (void)
rc = zmq_close (s1);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
}

View File

@ -30,7 +30,7 @@ int main (void)
{
fprintf (stderr, "test_sub_forward running...\n");
void *ctx = zmq_init (1);
void *ctx = zmq_ctx_new ();
assert (ctx);
// First, create an intermediate device.
@ -92,7 +92,7 @@ int main (void)
assert (rc == 0);
rc = zmq_close (sub);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0 ;

View File

@ -36,7 +36,7 @@ int main (void)
fprintf (stderr, "unbind endpoint test running...\n");
// Create infrastructure.
void *ctx = zmq_init (1);
void *ctx = zmq_ctx_new ();
assert (ctx);
void *push = zmq_socket (ctx, ZMQ_PUSH);
assert (push);
@ -69,16 +69,14 @@ int main (void)
assert (rc == 0);
rc = zmq_close (push);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
// Now the other way round.
fprintf (stderr, "disconnect endpoint test running...\n");
// Create infrastructure.
ctx = zmq_init (1);
ctx = zmq_ctx_new ();
assert (ctx);
push = zmq_socket (ctx, ZMQ_PUSH);
assert (push);
@ -111,7 +109,7 @@ int main (void)
assert (rc == 0);
rc = zmq_close (push);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0;

View File

@ -49,7 +49,7 @@ int main (void)
{
fprintf (stderr, "test_timeo running...\n");
void *ctx = zmq_init (1);
void *ctx = zmq_ctx_new ();
assert (ctx);
// Create a disconnected socket.
@ -111,7 +111,7 @@ int main (void)
assert (rc == 0);
rc = zmq_close (sb);
assert (rc == 0);
rc = zmq_term (ctx);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0 ;