Tweak reader_pid check

Check again after acquiring rmutex. Avoids potential issue with
a duplicate pid coming in between initial check and rmutex.
vmware
Howard Chu 12 years ago
parent b1dc72b6b5
commit de72c08660
  1. 12
      libraries/liblmdb/mdb.c

@ -8092,11 +8092,13 @@ int mdb_reader_check(MDB_env *env, int *dead)
if (mdb_pid_insert(pids, pid) == 0) { if (mdb_pid_insert(pids, pid) == 0) {
if (mdb_reader_pid(env, Pidcheck, pid)) { if (mdb_reader_pid(env, Pidcheck, pid)) {
LOCK_MUTEX_R(env); LOCK_MUTEX_R(env);
for (j=i; j<rdrs; j++) if (mdb_reader_pid(env, Pidcheck, pid)) {
if (mr[j].mr_pid == pid) { for (j=i; j<rdrs; j++)
mr[j].mr_pid = 0; if (mr[j].mr_pid == pid) {
count++; mr[j].mr_pid = 0;
} count++;
}
}
UNLOCK_MUTEX_R(env); UNLOCK_MUTEX_R(env);
} }
} }

Loading…
Cancel
Save