Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix: set PTHREAD_MUTEX_ERRORCHECK in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Jun 3, 2012
1 parent 28ed730 commit c03964f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/unix/thread.c
Expand Up @@ -49,10 +49,28 @@ int uv_thread_join(uv_thread_t *tid) {


int uv_mutex_init(uv_mutex_t* mutex) {
#ifdef NDEBUG
if (pthread_mutex_init(mutex, NULL))
return -1;
else
return 0;
#else
pthread_mutexattr_t attr;
int r;

if (pthread_mutexattr_init(&attr))
abort();

if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK))
abort();

r = pthread_mutex_init(mutex, &attr);

if (pthread_mutexattr_destroy(&attr))
abort();

return r ? -1 : 0;
#endif
}


Expand Down

0 comments on commit c03964f

Please sign in to comment.