diff --git a/src/socket_base.cpp b/src/socket_base.cpp index 70fef8b1..334e05ec 100644 --- a/src/socket_base.cpp +++ b/src/socket_base.cpp @@ -102,6 +102,11 @@ bool zmq::socket_base_t::check_tag () return tag == 0xbaddecaf; } +bool zmq::socket_base_t::is_thread_safe () const +{ + return thread_safe; +} + zmq::socket_base_t *zmq::socket_base_t::create (int type_, class ctx_t *parent_, uint32_t tid_, diff --git a/src/socket_base.hpp b/src/socket_base.hpp index 06cf1b06..5655819c 100644 --- a/src/socket_base.hpp +++ b/src/socket_base.hpp @@ -67,6 +67,9 @@ class socket_base_t : public own_t, // Returns false if object is not a socket. bool check_tag (); + // Returns whether the socket is thread-safe. + bool is_thread_safe () const; + // Create a socket of a specified type. static socket_base_t * create (int type_, zmq::ctx_t *parent_, uint32_t tid_, int sid_); diff --git a/src/socket_poller.cpp b/src/socket_poller.cpp index e45bec9e..570e4b8d 100644 --- a/src/socket_poller.cpp +++ b/src/socket_poller.cpp @@ -33,13 +33,8 @@ static bool is_thread_safe (zmq::socket_base_t &socket) { - int thread_safe; - size_t thread_safe_size = sizeof (int); - - int rc = - socket.getsockopt (ZMQ_THREAD_SAFE, &thread_safe, &thread_safe_size); - zmq_assert (rc == 0); - return thread_safe; + // do not use getsockopt here, since that would fail during context termination + return socket.is_thread_safe (); } zmq::socket_poller_t::socket_poller_t () :