Protect rpmtsVerifyDB() with transaction lock
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 22 Apr 2010 10:48:58 +0000 (13:48 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 22 Apr 2010 10:48:58 +0000 (13:48 +0300)
- BDB docs state that db->verify() doesn't perform any locking even
  when used within an environment, and should only be used on files
  that are not being modified by another thread of control. Grabbing
  the transaction lock while verifying mostly ensures nobodys writing
  to the db behind our back.

lib/rpmts.c

index 3beb1a4..0dc39d9 100644 (file)
@@ -135,7 +135,13 @@ int rpmtsRebuildDB(rpmts ts)
 
 int rpmtsVerifyDB(rpmts ts)
 {
-    return rpmdbVerify(ts->rootDir);
+    int rc = -1;
+    rpmlock lock = rpmtsAcquireLock(ts);
+    if (lock) {
+       int rc = rpmdbVerify(ts->rootDir);
+       rpmlockFree(lock);
+    }
+    return rc;
 }
 
 /* keyp might no be defined. */