add an option to check if the socket is thread safe

This commit is contained in:
somdoron
2015-08-16 10:42:11 +03:00
parent de018e8766
commit 34968771ca
3 changed files with 21 additions and 0 deletions

View File

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