{"action":"created","issue":{"url":"https://api.github.com/repos/zeromq/libzmq/issues/2218","repository_url":"https://api.github.com/repos/zeromq/libzmq","labels_url":"https://api.github.com/repos/zeromq/libzmq/issues/2218/labels{/name}","comments_url":"https://api.github.com/repos/zeromq/libzmq/issues/2218/comments","events_url":"https://api.github.com/repos/zeromq/libzmq/issues/2218/events","html_url":"https://github.com/zeromq/libzmq/issues/2218","id":190316931,"number":2218,"title":"zmq_msg_send and zmq_poll return whey they shouldn't (MacOS)","user":{"login":"rbx","id":1915061,"avatar_url":"https://avatars.githubusercontent.com/u/1915061?v=3","gravatar_id":"","url":"https://api.github.com/users/rbx","html_url":"https://github.com/rbx","followers_url":"https://api.github.com/users/rbx/followers","following_url":"https://api.github.com/users/rbx/following{/other_user}","gists_url":"https://api.github.com/users/rbx/gists{/gist_id}","starred_url":"https://api.github.com/users/rbx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbx/subscriptions","organizations_url":"https://api.github.com/users/rbx/orgs","repos_url":"https://api.github.com/users/rbx/repos","events_url":"https://api.github.com/users/rbx/events{/privacy}","received_events_url":"https://api.github.com/users/rbx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2016-11-18T13:16:31Z","updated_at":"2016-11-24T18:11:12Z","closed_at":null,"body":"I am having an issue using `zmq_msg_send` and `zmq_poll` on MacOS.\r\n\r\nWhen using `zmq_poll` with `ZMQ_POLLOUT`, it triggers and `zmq_msg_send` allows me to send messages even when nobody is connected (socket is binding). The sending does not actually send/queue anything.\r\nI have tested it on a PUSH socket with ZeroMQ versions 4.1.3 and 4.2.0.\r\n\r\nThe following is a minimal code to reproduce the problem:\r\n```C++\r\n#include <iostream>\r\n#include <cassert>\r\n#include \"zmq.h\"\r\n\r\nint main()\r\n{\r\n    void* ctx = zmq_ctx_new();\r\n    void* socket = zmq_socket(ctx, ZMQ_PUSH);\r\n    int rc = zmq_bind(socket, \"tcp://127.0.0.1:5555\"); assert(rc == 0);\r\n\r\n    zmq_pollitem_t items[1];\r\n    items[0].socket = socket;\r\n    items[0].fd = 0;\r\n    items[0].events = ZMQ_POLLOUT;\r\n\r\n    int counter = 0;\r\n\r\n    while (true)\r\n    {\r\n        rc = zmq_poll(items, 1, 1000);\r\n        std::cout << \"zmq_poll => \" << rc << std::endl;\r\n\r\n        if (items[0].revents & ZMQ_POLLOUT)\r\n        {\r\n            zmq_msg_t msg;\r\n            rc = zmq_msg_init_size(&msg, 1000); assert(rc >= 0);\r\n            int nbytes = zmq_msg_send(&msg, socket, 0);\r\n            std::cout << \"sent msg nr. \" << ++counter << \" (\" << nbytes << \" bytes).\" << std::endl;\r\n        }\r\n    }\r\n\r\n    zmq_close(socket);\r\n    zmq_ctx_term(ctx);\r\n\r\n    return 0;\r\n}\r\n\r\n```\r\n```\r\nclang++ zmq-poll-send.cxx -o zmq-poll-send -lzmq\r\n```\r\n\r\nWhen running the executable by itself (without a receiver) on a Linux system (Ubuntu 16.10 + GCC 6.2.0), it does the right thing. No queue is created (binding socket without connected peers) and sending cannot be done:\r\n```\r\nzmq_poll => 0\r\nzmq_poll => 0\r\nzmq_poll => 0\r\nzmq_poll => 0\r\n...\r\n```\r\n\r\nBut when running it on MacOS (10.12.1 + Apple LLVM version 8.0.0 (clang-800.0.42.1)), poll (mostly) reports that the sending can be done and `zmq_msg_send` \"sends\" it:\r\n```\r\nzmq_poll => 0\r\nzmq_poll => 1\r\nsent msg nr. 1 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 2 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 3 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 4 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 5 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 6 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 7 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 8 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 9 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 10 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 11 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 12 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 13 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 14 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 15 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 16 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 17 (1000 bytes).\r\nzmq_poll => 0\r\nzmq_poll => 1\r\nsent msg nr. 18 (1000 bytes).\r\nzmq_poll => 1\r\nsent msg nr. 19 (1000 bytes).\r\n...\r\n```\r\nMy hope was that at least the messages would go into queue (although it should not exist yet since no peers are connected), but this goes on over the default queue size of 1000. And if i connect a receiver the already sent messages do not arrive (new ones do). So the messages are lost!\r\n"},"comment":{"url":"https://api.github.com/repos/zeromq/libzmq/issues/comments/262827411","html_url":"https://github.com/zeromq/libzmq/issues/2218#issuecomment-262827411","issue_url":"https://api.github.com/repos/zeromq/libzmq/issues/2218","id":262827411,"user":{"login":"bluca","id":782193,"avatar_url":"https://avatars.githubusercontent.com/u/782193?v=3","gravatar_id":"","url":"https://api.github.com/users/bluca","html_url":"https://github.com/bluca","followers_url":"https://api.github.com/users/bluca/followers","following_url":"https://api.github.com/users/bluca/following{/other_user}","gists_url":"https://api.github.com/users/bluca/gists{/gist_id}","starred_url":"https://api.github.com/users/bluca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluca/subscriptions","organizations_url":"https://api.github.com/users/bluca/orgs","repos_url":"https://api.github.com/users/bluca/repos","events_url":"https://api.github.com/users/bluca/events{/privacy}","received_events_url":"https://api.github.com/users/bluca/received_events","type":"User","site_admin":false},"created_at":"2016-11-24T18:11:12Z","updated_at":"2016-11-24T18:11:12Z","body":"I'm afraid I'm out of high-level ideas, and the only thing left is firing up GDB and having a look at what's actually happening. Would you be able to do that?"}}
{"actor":{"display_login":"bluca"}}