Fix pthread portability problem

This commit is contained in:
Tianlong Wu 2015-12-03 10:44:38 +08:00
parent d7a4fc2927
commit f44b61c403

View File

@ -619,7 +619,13 @@ FdEntity::FdEntity(const char* tpath, const char* cpath)
try{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
#ifdef PTHREAD_MUTEX_RECURSIVE_NP
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); // recursive mutex
#elif PTHREAD_MUTEX_RECURSIVE
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); // recursive mutex
#else
#error "Either PTHREAD_MUTEX_RECURSIVE_NP or PTHREAD_MUTEX_RECURSIVE must be defined."
#endif
pthread_mutex_init(&fdent_lock, &attr);
is_lock_init = true;
}catch(exception& e){