Commit 8c928934 authored by Pieter Hintjens's avatar Pieter Hintjens

Fixed use of deprecated zmq_init/term

parent 5f009e52
...@@ -29,7 +29,7 @@ int main (void) ...@@ -29,7 +29,7 @@ int main (void)
{ {
fprintf (stderr, "test_connect_resolve running...\n"); fprintf (stderr, "test_connect_resolve running...\n");
void *ctx = zmq_init (1); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
// Create pair of socket, each with high watermark of 2. Thus the total // Create pair of socket, each with high watermark of 2. Thus the total
...@@ -47,7 +47,7 @@ int main (void) ...@@ -47,7 +47,7 @@ int main (void)
rc = zmq_close (sock); rc = zmq_close (sock);
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;
......
...@@ -26,7 +26,7 @@ int main (void) ...@@ -26,7 +26,7 @@ int main (void)
{ {
fprintf (stderr, "test_hwm running...\n"); fprintf (stderr, "test_hwm running...\n");
void *ctx = zmq_init (1); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
// Create pair of socket, each with high watermark of 2. Thus the total // Create pair of socket, each with high watermark of 2. Thus the total
...@@ -76,7 +76,7 @@ int main (void) ...@@ -76,7 +76,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;
......
...@@ -30,12 +30,15 @@ int main (void) ...@@ -30,12 +30,15 @@ int main (void)
fprintf (stderr, "test_invalid_rep running...\n"); fprintf (stderr, "test_invalid_rep running...\n");
// Create REQ/ROUTER wiring. // Create REQ/ROUTER wiring.
void *ctx = zmq_init (1); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
void *router_socket = zmq_socket (ctx, ZMQ_ROUTER); void *router_socket = zmq_socket (ctx, ZMQ_ROUTER);
assert (router_socket); assert (router_socket);
void *req_socket = zmq_socket (ctx, ZMQ_REQ); void *req_socket = zmq_socket (ctx, ZMQ_REQ);
assert (req_socket); assert (req_socket);
int linger = 0; int linger = 0;
int rc = zmq_setsockopt (router_socket, ZMQ_LINGER, &linger, sizeof (int)); int rc = zmq_setsockopt (router_socket, ZMQ_LINGER, &linger, sizeof (int));
assert (rc == 0); assert (rc == 0);
...@@ -84,7 +87,7 @@ int main (void) ...@@ -84,7 +87,7 @@ int main (void)
assert (rc == 0); assert (rc == 0);
rc = zmq_close (req_socket); rc = zmq_close (req_socket);
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;
......
...@@ -38,16 +38,25 @@ static void do_bind_and_verify (void *s, const char *endpoint) ...@@ -38,16 +38,25 @@ static void do_bind_and_verify (void *s, const char *endpoint)
int main (void) int main (void)
{ {
// Create the infrastructure // Create the infrastructure
void *ctx = zmq_init (1); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_ROUTER); void *sb = zmq_socket (ctx, ZMQ_ROUTER);
assert (sb); 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:5560");
do_bind_and_verify (sb, "tcp://127.0.0.1:5561"); do_bind_and_verify (sb, "tcp://127.0.0.1:5561");
do_bind_and_verify (sb, "ipc:///tmp/testep"); 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 ; return 0 ;
} }
...@@ -192,7 +192,7 @@ int main (void) ...@@ -192,7 +192,7 @@ int main (void)
addr = "tcp://127.0.0.1:5560"; addr = "tcp://127.0.0.1:5560";
// Create the infrastructure // Create the infrastructure
void *ctx = zmq_init (1); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
// REP socket // REP socket
...@@ -266,7 +266,7 @@ int main (void) ...@@ -266,7 +266,7 @@ int main (void)
// Allow for closed or disconnected events to bubble up // Allow for closed or disconnected events to bubble up
zmq_sleep (1); zmq_sleep (1);
zmq_term (ctx); zmq_ctx_term (ctx);
// Expected REP socket events // Expected REP socket events
assert (rep_socket_events & ZMQ_EVENT_LISTENING); assert (rep_socket_events & ZMQ_EVENT_LISTENING);
......
...@@ -28,14 +28,18 @@ ...@@ -28,14 +28,18 @@
int main (void) int main (void)
{ {
// Create the infrastructure // Create the infrastructure
void *ctx = zmq_init (0); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_ROUTER); void *sb = zmq_socket (ctx, ZMQ_ROUTER);
assert (sb); assert (sb);
int rc = zmq_bind (sb, "inproc://a"); int rc = zmq_bind (sb, "inproc://a");
assert (rc == 0); assert (rc == 0);
void *sc = zmq_socket (ctx, ZMQ_DEALER); void *sc = zmq_socket (ctx, ZMQ_DEALER);
assert (sc); assert (sc);
rc = zmq_connect (sc, "inproc://a"); rc = zmq_connect (sc, "inproc://a");
assert (rc == 0); assert (rc == 0);
...@@ -69,9 +73,11 @@ int main (void) ...@@ -69,9 +73,11 @@ int main (void)
// Deallocate the infrastructure. // Deallocate the infrastructure.
rc = zmq_close (sc); rc = zmq_close (sc);
assert (rc == 0); assert (rc == 0);
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 ;
} }
......
...@@ -25,7 +25,7 @@ int main (void) ...@@ -25,7 +25,7 @@ int main (void)
{ {
fprintf (stderr, "test_pair_inproc running...\n"); fprintf (stderr, "test_pair_inproc running...\n");
void *ctx = zmq_init (0); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_PAIR); void *sb = zmq_socket (ctx, ZMQ_PAIR);
...@@ -46,7 +46,7 @@ int main (void) ...@@ -46,7 +46,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 ;
......
...@@ -25,7 +25,7 @@ int main (void) ...@@ -25,7 +25,7 @@ int main (void)
{ {
fprintf (stderr, "test_pair_ipc running...\n"); fprintf (stderr, "test_pair_ipc running...\n");
void *ctx = zmq_init (1); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_PAIR); void *sb = zmq_socket (ctx, ZMQ_PAIR);
...@@ -46,7 +46,7 @@ int main (void) ...@@ -46,7 +46,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 ;
......
...@@ -26,7 +26,7 @@ int main (void) ...@@ -26,7 +26,7 @@ int main (void)
{ {
fprintf (stderr, "test_pair_tcp running...\n"); fprintf (stderr, "test_pair_tcp running...\n");
void *ctx = zmq_init (1); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_PAIR); void *sb = zmq_socket (ctx, ZMQ_PAIR);
...@@ -47,7 +47,7 @@ int main (void) ...@@ -47,7 +47,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 ;
......
/* /*
Copyright (c) 2007-2012 iMatix Corporation 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 Copyright (c) 2007-2012 Other contributors as noted in the AUTHORS file
This file is part of 0MQ. This file is part of 0MQ.
......
...@@ -30,7 +30,7 @@ int main (void) ...@@ -30,7 +30,7 @@ int main (void)
{ {
fprintf (stderr, "test_reqrep_device running...\n"); fprintf (stderr, "test_reqrep_device running...\n");
void *ctx = zmq_init (1); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
// Create a req/rep device. // Create a req/rep device.
...@@ -136,7 +136,7 @@ int main (void) ...@@ -136,7 +136,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 ;
......
...@@ -25,7 +25,7 @@ int main (void) ...@@ -25,7 +25,7 @@ int main (void)
{ {
fprintf (stderr, "test_reqrep_inproc running...\n"); fprintf (stderr, "test_reqrep_inproc running...\n");
void *ctx = zmq_init (0); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_REP); void *sb = zmq_socket (ctx, ZMQ_REP);
...@@ -46,7 +46,7 @@ int main (void) ...@@ -46,7 +46,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 ;
......
...@@ -25,7 +25,7 @@ int main (void) ...@@ -25,7 +25,7 @@ int main (void)
{ {
fprintf (stderr, "test_reqrep_ipc running...\n"); fprintf (stderr, "test_reqrep_ipc running...\n");
void *ctx = zmq_init (1); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_REP); void *sb = zmq_socket (ctx, ZMQ_REP);
...@@ -46,7 +46,7 @@ int main (void) ...@@ -46,7 +46,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 ;
......
...@@ -26,7 +26,7 @@ int main (void) ...@@ -26,7 +26,7 @@ int main (void)
{ {
fprintf (stderr, "test_reqrep_tcp running...\n"); fprintf (stderr, "test_reqrep_tcp running...\n");
void *ctx = zmq_init (1); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_REP); void *sb = zmq_socket (ctx, ZMQ_REP);
...@@ -47,7 +47,7 @@ int main (void) ...@@ -47,7 +47,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 ;
......
...@@ -27,7 +27,7 @@ int main (void) ...@@ -27,7 +27,7 @@ int main (void)
{ {
fprintf (stderr, "test_router_mandatory running...\n"); fprintf (stderr, "test_router_mandatory running...\n");
void *ctx = zmq_init (1); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
// Creating the first socket. // Creating the first socket.
...@@ -98,7 +98,7 @@ int main (void) ...@@ -98,7 +98,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 ;
......
...@@ -48,7 +48,6 @@ extern "C" ...@@ -48,7 +48,6 @@ extern "C"
int main (void) int main (void)
{ {
void *ctx;
void *s1; void *s1;
void *s2; void *s2;
int i; int i;
...@@ -61,8 +60,9 @@ int main (void) ...@@ -61,8 +60,9 @@ int main (void)
for (j = 0; j != 10; j++) { for (j = 0; j != 10; j++) {
// Check the shutdown with many parallel I/O threads. // Check the shutdown with many parallel I/O threads.
ctx = zmq_init (7); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
zmq_ctx_set (ctx, ZMQ_IO_THREADS, 7);
s1 = zmq_socket (ctx, ZMQ_PUB); s1 = zmq_socket (ctx, ZMQ_PUB);
assert (s1); assert (s1);
...@@ -85,7 +85,7 @@ int main (void) ...@@ -85,7 +85,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);
} }
......
...@@ -30,7 +30,7 @@ int main (void) ...@@ -30,7 +30,7 @@ int main (void)
{ {
fprintf (stderr, "test_sub_forward running...\n"); fprintf (stderr, "test_sub_forward running...\n");
void *ctx = zmq_init (1); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
// First, create an intermediate device. // First, create an intermediate device.
...@@ -92,7 +92,7 @@ int main (void) ...@@ -92,7 +92,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 ;
......
...@@ -36,7 +36,7 @@ int main (void) ...@@ -36,7 +36,7 @@ int main (void)
fprintf (stderr, "unbind endpoint test running...\n"); fprintf (stderr, "unbind endpoint test running...\n");
// Create infrastructure. // Create infrastructure.
void *ctx = zmq_init (1); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
void *push = zmq_socket (ctx, ZMQ_PUSH); void *push = zmq_socket (ctx, ZMQ_PUSH);
assert (push); assert (push);
...@@ -69,16 +69,14 @@ int main (void) ...@@ -69,16 +69,14 @@ 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);
// Now the other way round. // Now the other way round.
fprintf (stderr, "disconnect endpoint test running...\n"); fprintf (stderr, "disconnect endpoint test running...\n");
// Create infrastructure. // Create infrastructure.
ctx = zmq_init (1); ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
push = zmq_socket (ctx, ZMQ_PUSH); push = zmq_socket (ctx, ZMQ_PUSH);
assert (push); assert (push);
...@@ -111,7 +109,7 @@ int main (void) ...@@ -111,7 +109,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;
......
...@@ -49,7 +49,7 @@ int main (void) ...@@ -49,7 +49,7 @@ int main (void)
{ {
fprintf (stderr, "test_timeo running...\n"); fprintf (stderr, "test_timeo running...\n");
void *ctx = zmq_init (1); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
// Create a disconnected socket. // Create a disconnected socket.
...@@ -111,7 +111,7 @@ int main (void) ...@@ -111,7 +111,7 @@ int main (void)
assert (rc == 0); assert (rc == 0);
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 ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment