SHA256
1
0
forked from pool/lmdb
lmdb/0001-Patch-for-LMDB-to-use-robust-mutexes.patch
Klaus Kämpf 5d7692be2a Accepting request 293807 from home:sumski:hazard:to:your:stereo
- Update to 0.9.14:
* Fix to support 64K page size (ITS#7713)
* Fix to persist decreased as well as increased mapsizes (ITS#7789)
* Fix cursor bug when deleting last node of a DUPSORT key
* Fix mdb_env_info to return FIXEDMAP address
* Fix ambiguous error code from writing to closed DBI (ITS#7825)
* Fix mdb_copy copying past end of file (ITS#7886)
* Fix cursor bugs from page_merge/rebalance
* Fix to dirty fewer pages in deletes (mdb_page_loose())
* Fix mdb_dbi_open creating subDBs (ITS#7917)
* Fix mdb_cursor_get(_DUP) with single value (ITS#7913)
* Fix Windows compat issues in mtests (ITS#7879)
* Add compacting variant of mdb_copy
* Add BigEndian integer key compare code
* Add mdb_dump/mdb_load utilities
 - Changes since 0.9.13:
* Fix mdb_page_alloc unlimited overflow page search
* Documentation:
  Re-fix MDB_CURRENT doc (ITS#7793)
  Fix MDB_GET_MULTIPLE/MDB_NEXT_MULTIPLE doc
 - Changes since 0.9.12:
* Fix MDB_GET_BOTH regression (ITS#7875,#7681)
* Fix MDB_MULTIPLE writing multiple keys (ITS#7834)
* Fix mdb_rebalance (ITS#7829)
* Fix mdb_page_split (ITS#7815)
* Fix md_entries count (ITS#7861,#7828,#7793)
* Fix MDB_CURRENT (ITS#7793)
* Fix possible crash on Windows DLL detach
* Misc code cleanup
* Documentation:

OBS-URL: https://build.opensuse.org/request/show/293807
OBS-URL: https://build.opensuse.org/package/show/systemsmanagement/lmdb?expand=0&rev=12
2015-03-31 19:08:42 +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
@@ -207,6 +207,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
@@ -218,7 +219,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)
@@ -2498,7 +2499,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)
@@ -2528,7 +2542,20 @@ mdb_txn_renew0(MDB_txn *txn)
}
} 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];
@@ -4330,6 +4357,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)))