Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:Update
lmdb.2554
0001-Patch-for-LMDB-to-use-robust-mutexes.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Patch-for-LMDB-to-use-robust-mutexes.patch of Package lmdb.2554
diff -wruN -x '*~' -x '*.o' -x '*.a' -x '*.so' -x '*.so.[0-9]' -x autom4te.cache -x .deps -x .libs ../orig-liblmdb/configure.ac ./configure.ac --- ../orig-liblmdb/configure.ac 2014-07-28 17:44:41.873398363 +0200 +++ ./configure.ac 2014-07-28 17:47:06.143497590 +0200 @@ -9,5 +9,12 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) LT_INIT AC_CHECK_HEADERS([sys/file.h]) +AC_CHECK_LIB([pthread], [pthread_mutex_lock]) +AC_CHECK_LIB([pthreadGC2], [pthread_mutex_lock]) +AS_IF([test "$ac_cv_lib_pthread" = "no" && test "$ac_cv_lib_pthreadGC2" = "no"], +[ + AC_MSG_ERROR([Could not find pthreads library]) +]) +AC_CHECK_FUNCS([pthread_mutexattr_settype pthread_mutexattr_setrobust]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff -wruN -x '*~' -x '*.o' -x '*.a' -x '*.so' -x '*.so.[0-9]' -x autom4te.cache -x .deps -x .libs ../orig-liblmdb/mdb.c ./mdb.c --- ../orig-liblmdb/mdb.c 2014-01-31 09:23:13.341427766 +0100 +++ ./mdb.c 2014-07-28 17:44:55.145959267 +0200 @@ -169,6 +169,7 @@ #ifdef _WIN32 #define MDB_USE_HASH 1 #define MDB_PIDLOCK 0 +#define EOWNERDEAD 130 #define pthread_t DWORD #define pthread_mutex_t HANDLE #define pthread_key_t DWORD @@ -179,7 +180,7 @@ #define pthread_getspecific(x) TlsGetValue(x) #define pthread_setspecific(x,y) (TlsSetValue(x,y) ? 0 : ErrCode()) #define pthread_mutex_unlock(x) ReleaseMutex(x) -#define pthread_mutex_lock(x) WaitForSingleObject(x, INFINITE) +#define pthread_mutex_lock(x) (WaitForSingleObject(x, INFINITE) == WAIT_ABANDONED ? EOWNERDEAD : 0) // masks FAIL and TIMEOUT error, but acceptable #define LOCK_MUTEX_R(env) pthread_mutex_lock((env)->me_rmutex) #define UNLOCK_MUTEX_R(env) pthread_mutex_unlock((env)->me_rmutex) #define LOCK_MUTEX_W(env) pthread_mutex_lock((env)->me_wmutex) @@ -2275,7 +2276,20 @@ env->me_flags |= MDB_LIVE_READER; } - LOCK_MUTEX_R(env); + rc = LOCK_MUTEX_R(env); + switch (rc) + { + case 0: + break; +#ifdef HAVE_PTHREAD_MUTEXATTR_SETROBUST + case EOWNERDEAD: + // we cannot recover the state, so mark mutex as unusable + UNLOCK_MUTEX_R(env); + // FALLTHROUGH +#endif + default: + return MDB_PANIC; + } nr = ti->mti_numreaders; for (i=0; i<nr; i++) if (ti->mti_readers[i].mr_pid == 0) @@ -2305,7 +2319,20 @@ } } else { if (ti) { - LOCK_MUTEX_W(env); + rc = LOCK_MUTEX_W(env); + switch (rc) + { + case 0: + break; +#ifdef HAVE_PTHREAD_MUTEXATTR_SETROBUST + case EOWNERDEAD: + // we cannot recover the state, so mark mutex as unusable + UNLOCK_MUTEX_W(env); + // FALLTHROUGH +#endif + default: + return MDB_PANIC; + } txn->mt_txnid = ti->mti_txnid; meta = env->me_metas[txn->mt_txnid & 1]; @@ -4014,6 +4041,12 @@ pthread_mutexattr_t mattr; if ((rc = pthread_mutexattr_init(&mattr)) +#ifdef HAVE_PTHREAD_MUTEXATTR_SETTYPE + || (rc = pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_ERRORCHECK)) +#endif +#ifdef HAVE_PTHREAD_MUTEXATTR_SETROBUST + || (rc = pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST)) +#endif || (rc = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED)) || (rc = pthread_mutex_init(&env->me_txns->mti_mutex, &mattr)) || (rc = pthread_mutex_init(&env->me_txns->mti_wmutex, &mattr)))
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor