[zeromq-dev] Race condition in cppzmq zmq::socket_t::close() / cppzmq tag?

Luca Boccassi luca.boccassi at gmail.com
Wed Dec 14 09:36:41 CET 2016


That could only happen if the same socket was used or managed from multiple
threads. As the documentation clearly states, sockets are intentionally not
thread safe and must not be used from multiple threads.

Regarding the version I'm not sure as it's never been tagged, and the
development usually lags a bit behind so it would risk being misleading.

It would make sense to be versioned only if it was in the same repo I think.

On Dec 14, 2016 07:25, "Eric Pederson" <ericacm at gmail.com> wrote:

I ran into a race condition in zmq::socket_t::close() in cppzmq:


*inline void *close() ZMQ_NOTHROW
{
    *if*(ptr == NULL)

*// already closed        **return *;

*// Someone can sneak in here and close the socket*
    *int *rc = zmq_close (ptr);
    ZMQ_ASSERT (rc == 0);
    ptr = 0 ;
}

I worked around it using compare-and-swap to atomically check if it's
already closed. Does that kind of fix sound reasonable for
zmq::socket_t::close()?


Also I wanted to follow up on my previous question about tagging cppzmq.  I
think that conversation got lost in the list shutdown that happened
recently.  Does it make sense to regularly tag the cppzmq repo with the
corresponding ZeroMQ version?

Thanks,

-- Eric

_______________________________________________
zeromq-dev mailing list
zeromq-dev at lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20161214/70979634/attachment.htm>


More information about the zeromq-dev mailing list