mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-23 16:48:08 +02:00
add an option to check if the socket is thread safe
This commit is contained in:
@@ -423,6 +423,19 @@ int zmq::socket_base_t::getsockopt (int option_, void *optval_,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (option_ == ZMQ_THREAD_SAFE) {
|
||||
if (*optvallen_ < sizeof (int)) {
|
||||
errno = EINVAL;
|
||||
EXIT_MUTEX();
|
||||
return -1;
|
||||
}
|
||||
memset(optval_, 0, *optvallen_);
|
||||
*((int*) optval_) = thread_safe ? 1 : 0;
|
||||
*optvallen_ = sizeof (int);
|
||||
EXIT_MUTEX();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rc = options.getsockopt (option_, optval_, optvallen_);
|
||||
EXIT_MUTEX();
|
||||
return rc;
|
||||
|
Reference in New Issue
Block a user