Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zmq_ctx_term hangs if data is sent but connect never succeeds regardless of ZMQ_LINGER #2067

Closed
cxreg opened this issue Jul 27, 2016 · 1 comment

Comments

@cxreg
Copy link
Contributor

cxreg commented Jul 27, 2016

According to the documentation, if ZMQ_LINGER is set to 0 then zmq_ctx_term will not block if there is pending sends. However, this doesn't seem to work if the connection never succeeded. This snippet reproduces the behavior. It is worth noting that if the connect ever succeeded (even if it is disconnected at the time of close and term) it will not hang. This only happens if the connect never succeeded.

I'm not sure if this is related to #1279 so I opened this as a new ticket. If they are related, please merge as needed

#include <zmq.h>

char buf[1024] = {0};

int main(void) {
    void *ctx = zmq_ctx_new();
    void *sock = zmq_socket (ctx, ZMQ_PUSH);
    zmq_setsockopt(sock, ZMQ_LINGER, 0, 0);
    zmq_connect(sock, "tcp://localhost:9999");
    zmq_send(sock, buf, 1024, 0);
    zmq_close(sock);
    printf("destroying zmq ctx\n");
    zmq_ctx_term(ctx);
    printf("finished\n");
}
@cxreg
Copy link
Contributor Author

cxreg commented Jul 27, 2016

Nevermind this is user error, I misunderstood the api for zmq_setsockopt. If I pass a pointer to an integer with the value of 0 then it works as documented. Sorry for the noise.

@cxreg cxreg closed this as completed Jul 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant