mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-21 23:56:56 +02:00
thread safety bug - lock when sending
This commit is contained in:
@@ -88,7 +88,13 @@ namespace zmq
|
||||
public:
|
||||
inline mutex_t ()
|
||||
{
|
||||
int rc = pthread_mutex_init (&mutex, NULL);
|
||||
int rc = pthread_mutexattr_init(&attr);
|
||||
posix_assert (rc);
|
||||
|
||||
rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
posix_assert (rc);
|
||||
|
||||
rc = pthread_mutex_init (&mutex, &attr);
|
||||
posix_assert (rc);
|
||||
}
|
||||
|
||||
@@ -96,6 +102,9 @@ namespace zmq
|
||||
{
|
||||
int rc = pthread_mutex_destroy (&mutex);
|
||||
posix_assert (rc);
|
||||
|
||||
rc = pthread_mutexattr_destroy (&attr);
|
||||
posix_assert (rc);
|
||||
}
|
||||
|
||||
inline void lock ()
|
||||
@@ -128,6 +137,7 @@ namespace zmq
|
||||
private:
|
||||
|
||||
pthread_mutex_t mutex;
|
||||
pthread_mutexattr_t attr;
|
||||
|
||||
// Disable copy construction and assignment.
|
||||
mutex_t (const mutex_t&);
|
||||
|
Reference in New Issue
Block a user