Created
February 17, 2011 09:55
-
-
Save hintjens/831418 to your computer and use it in GitHub Desktop.
Crash 0MQ after 604 reconnection attempts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Crash mailbox... | |
| // | |
| #include <zmq.h> | |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <unistd.h> | |
| // Specify any two legally combineable socket types | |
| #define SERVER ZMQ_PAIR | |
| #define CLIENT ZMQ_PAIR | |
| int main (int argc, char *argv[]) | |
| { | |
| void *context = zmq_init (1); | |
| void *server = zmq_socket (context, SERVER); | |
| zmq_bind (server, "tcp://*:5055"); | |
| void *client1 = zmq_socket (context, CLIENT); | |
| zmq_setsockopt (client1, ZMQ_IDENTITY, "DIE", 3); | |
| zmq_connect (client1, "tcp://localhost:5055"); | |
| int ivl = 1; | |
| void *client2 = zmq_socket (context, CLIENT); | |
| zmq_setsockopt (client2, ZMQ_IDENTITY, "DIE", 3); | |
| zmq_setsockopt (client2, ZMQ_RECONNECT_IVL, &ivl, sizeof (ivl)); | |
| zmq_setsockopt (client2, ZMQ_RECONNECT_IVL_MAX, &ivl, sizeof (ivl)); | |
| zmq_connect (client2, "tcp://localhost:5055"); | |
| // 0MQ crashes here | |
| sleep (10); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment