mdbx: PTHREAD_MUTEX_ERRORCHECK при MDBX_DEBUG > 0.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2023-10-29 16:39:35 +03:00
parent 1943db7d41
commit ad4d00677b

View File

@ -503,8 +503,18 @@ MDBX_INTERNAL_FUNC int osal_fastmutex_init(osal_fastmutex_t *fastmutex) {
#if defined(_WIN32) || defined(_WIN64)
InitializeCriticalSection(fastmutex);
return MDBX_SUCCESS;
#elif MDBX_DEBUG
pthread_mutexattr_t ma;
int rc = pthread_mutexattr_init(&ma);
if (likely(!rc)) {
rc = pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_ERRORCHECK);
if (likely(!rc) || rc == ENOTSUP)
rc = pthread_mutex_init(fastmutex, &ma);
pthread_mutexattr_destroy(&ma);
}
return rc;
#else
return pthread_mutex_init(fastmutex, NULL);
return pthread_mutex_init(fastmutex, nullptr);
#endif
}