]> git.sur5r.net Git - openldap/commitdiff
Tweak reader_pid check
authorHoward Chu <hyc@symas.com>
Fri, 19 Jul 2013 16:57:33 +0000 (09:57 -0700)
committerHoward Chu <hyc@symas.com>
Fri, 19 Jul 2013 16:57:33 +0000 (09:57 -0700)
Check again after acquiring rmutex. Avoids potential issue with
a duplicate pid coming in between initial check and rmutex.

libraries/liblmdb/mdb.c

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