Problem: socket poller shutdown asserts when context is terminating

Solution: do not call getsockopt to query thread-safety of a socket
This commit is contained in:
Simon Giesecke 2018-03-28 10:46:19 +02:00
parent 32c8abb1d8
commit 87fbb5c447
3 changed files with 10 additions and 7 deletions

View File

@ -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_,

View File

@ -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_);

View File

@ -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 () :