zeromq / libzmq

ZeroMQ core engine in C++, implements ZMTP/3.1
https://www.zeromq.org
Mozilla Public License 2.0
9.71k stars 2.36k forks source link

zmq_connect () set the send timeout invalid in push mode #4099

Open hus1ngx opened 3 years ago

hus1ngx commented 3 years ago

Please use this template for reporting suspected bugs or requests for help.

Issue description

In push/pull mode, set the timeout on the push side, and then conect.zmq_send always blocks when the pull side is not online.Even if non-blocking sending is set

Environment

Minimal test code / Steps to reproduce the issue

#include "zhelpers.h"
#include <unistd.h>
int main(void)
{
    int timeout = 30;
    void *context = zmq_ctx_new();
    void *publisher = zmq_socket(context, ZMQ_PUSH);
    zmq_setsockopt(publisher, ZMQ_SNDTIMEO, &timeout, sizeof(timeout));
    zmq_setsockopt(publisher, ZMQ_RCVTIMEO, &timeout, sizeof(timeout));
    zmq_connect(publisher, "ipc:///tmp/pipeline.ipc"); // invalid
    // zmq_bind(publisher, "ipc:///tmp/pipeline.ipc"); // Valid
    char* msg = "We want to see this";
    int rc = zmq_send(publisher, msg,strlen(msg), ZMQ_DONTWAIT);
    if(rc<0)
    {
        printf("%s\n",zmq_strerror(zmq_errno()));
    }
    sleep(1);
    zmq_close(publisher);
    zmq_ctx_destroy(context);
    return 0;
}

What's the actual result? (include assertion message & call stack if applicable)

zmq_send will always block

What's the expected result?

zmq_send exits in time out

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had activity for 365 days. It will be closed if no further activity occurs within 56 days. Thank you for your contributions.