[zeromq-dev] EAGAIN with zmq_disconnect on inproc socket

Stefan Radomski radomski at tk.informatik.tu-darmstadt.de
Mon Dec 3 18:18:30 CET 2012

On Dec 3, 2012, at 4:35 PM, Pieter Hintjens <ph at imatix.com>

> On Mon, Dec 3, 2012 at 4:25 PM, Stefan Radomski
> <radomski at tk.informatik.tu-darmstadt.de> wrote:
>> I keep getting an EAGAIN error with ZeroMQ 3.2.2 on MacOSX 10.8.2 when
>> calling zmq_disconnect on an inproc socket
> This looks like a bug on zmq_disconnect. The semantics for connect on
> inproc are somewhat different since this does execute immediately,
> unlike the other protocols, which execute asynchronously. However
> disconnect obvious should not return EAGAIN when there's actually not
> an error.
> If you manage to make a patch for this, that'd be great.

I tried to, but could not get it to work. Right before the following snippet in socket_base.cpp:

    //  Find the endpoints range (if any) corresponding to the addr_ string.
    std::pair <endpoints_t::iterator, endpoints_t::iterator> range = endpoints.equal_range (std::string (addr_));
    if (range.first == range.second)
        return -1;

I inserted some code to check whether this is an inproc address and get the corresponding remote endpoint.

    //  Parse addr_ string.
    std::string protocol;
    std::string address;
    rc = parse_uri (addr_, protocol, address);
    if (rc != 0)
        return -1;

    rc = check_protocol (protocol);
    if (rc != 0)
        return -1;

    endpoint_t peer = find_endpoint (addr_);
    if (!peer.socket)
        return -1;

    // Disconnect an inproc socket
    if (protocol == "inproc") {
        for (pipes_t::size_type i = 0; i != pipes.size (); ++i) {
            if (pipes [i]->peer == peer.socket) { /// <- not working
              pipes [i]->terminate (false);
              return 0;
        return -1;

But I cannot figure out, which pipe to terminate as I am having difficulties finding out, which one is connected to the peer endpoint. Also, I am not sure how to terminate a pipe - is it actually sufficient to call terminate on the pipe? If you help me to complete this one, I'll submit it as a patch.

Best regards

More information about the zeromq-dev mailing list