[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#7971) LMDB: Uncarefully appointment when beginning a readonly txn.

The attached files is derived from OpenLDAP Software. All of the modifications
to OpenLDAP Software represented in the following patch(es) were developed by
Peter-Service LLC, Moscow, Russia. Peter-Service LLC has not assigned rights
and/or interest in this work to any party. I, Leonid Yuriev am authorized by
Peter-Service LLC, my employer, to release this work under the following terms.

Peter-Service LLC hereby places the following modifications to OpenLDAP Software
(and only these modifications) into the public domain. Hence, these
modifications may be freely used and/or redistributed for any purpose with or
without attribution and/or other notice.

commit ff0bde6a95bb8ab2355324b65f451216d5ef2a0e
Author: Leo Yuriev <leo@yuriev.ru>
Date:   2014-10-18 02:00:37 +0400

    ITS#7971 for LMDB: clarification in  mdb_txn_renew0().

diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c
index 83a15c1..1e766af 100644
--- a/libraries/liblmdb/mdb.c
+++ b/libraries/liblmdb/mdb.c
@@ -2507,15 +2507,16 @@ mdb_txn_renew0(MDB_txn *txn)
- ti->mti_readers[i].mr_pid = pid;
- ti->mti_readers[i].mr_tid = tid;
+ r = &ti->mti_readers[i];
+ r->mr_txnid = (txnid_t)-1;
+ r->mr_tid = tid;
+ r->mr_pid = pid; /* should be written last, see ITS#. */
  if (i == nr)
  ti->mti_numreaders = ++nr;
  /* Save numreaders for un-mutexed mdb_env_close() */
  env->me_numreaders = nr;

- r = &ti->mti_readers[i];
  new_notls = (env->me_flags & MDB_NOTLS);
  if (!new_notls && (rc=pthread_setspecific(env->me_txkey, r))) {
  r->mr_pid = 0;