lmdb/0001-Patch-for-LMDB-to-use-robust-mutexes.patch
Klaus Kämpf 78ba7b81e3 Accepting request 340787 from home:sumski:hazard:to:your:stereo
- Update to 0.9.16:
* Fix cursor EOF bug (ITS#8190)
* Fix handling of subDB records (ITS#8181)
* Fix mdb_midl_shrink() usage (ITS#8200)
 - Changes since 0.9.15:
* Fix txn init (ITS#7961,#7987)
* Fix MDB_PREV_DUP (ITS#7955,#7671)
* Fix compact of empty env (ITS#7956)
* Fix mdb_copy file mode
* Fix mdb_env_close() after failed mdb_env_open()
* Fix mdb_rebalance collapsing root (ITS#8062)
* Fix mdb_load with large values (ITS#8066)
* Fix to retry writes on EINTR (ITS#8106)
* Fix mdb_cursor_del on empty DB (ITS#8109)
* Fix MDB_INTEGERDUP key compare (ITS#8117)
* Fix error handling (ITS#7959,#8157,etc.)
* Fix race conditions (ITS#7969,7970)
* Added workaround for fdatasync bug in ext3fs
 * Build:
  * Don't use -fPIC for static lib
  * Update .gitignore (ITS#7952,#7953)
  * Cleanup for "make test" (ITS#7841), "make clean", mtest*.c
  * Misc. Android/Windows cleanup
 * Documentation
  * Fix MDB_APPEND doc
  * Fix MDB_MAXKEYSIZE doc (ITS#8156)
  * Fix mdb_cursor_put,mdb_cursor_del EACCES description
  * Fix mdb_env_sync(MDB_RDONLY env) doc (ITS#8021)
  * Clarify MDB_WRITEMAP doc (ITS#8021)
  * Clarify mdb_env_open doc

OBS-URL: https://build.opensuse.org/request/show/340787
OBS-URL: https://build.opensuse.org/package/show/systemsmanagement/lmdb?expand=0&rev=16
2015-10-26 13:52:21 +00:00

94 lines
3.9 KiB
Diff

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
@@ -11,5 +11,12 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
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
@@ -215,6 +215,7 @@ extern int cacheflush(char *addr, int nbytes, int cache);
#define MDB_USE_HASH 1
#define MDB_PIDLOCK 0
#define THREAD_RET DWORD
+#define EOWNERDEAD 130
#define pthread_t HANDLE
#define pthread_mutex_t HANDLE
#define pthread_cond_t HANDLE
@@ -226,7 +227,7 @@ extern int cacheflush(char *addr, int nbytes, int cache);
#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 pthread_cond_signal(x) SetEvent(*x)
#define pthread_cond_wait(cond,mutex) do{SignalObjectAndWait(*mutex, *cond, INFINITE, FALSE); WaitForSingleObject(*mutex, INFINITE);}while(0)
#define THREAD_CREATE(thr,start,arg) thr=CreateThread(NULL,0,start,arg,0,NULL)
@@ -2529,7 +2530,20 @@ mdb_txn_renew0(MDB_txn *txn)
env->me_live_reader = 1;
}
- 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)
@@ -2563,7 +2577,20 @@ mdb_txn_renew0(MDB_txn *txn)
txn->mt_dbxs = env->me_dbxs; /* mostly static anyway */
} 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];
@@ -4458,6 +4485,12 @@ mdb_env_setup_locks(MDB_env *env, char *lpath, int mode, int *excl)
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)))