Reviewed by Darin Adler.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Feb 2008 21:00:00 +0000 (21:00 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Feb 2008 21:00:00 +0000 (21:00 +0000)
        <rdar://problem/5743768> A deadlock during storage layout tests

        Make sure not to hold the m_openDatabaseMapGuard mutex when calling
        Database::markAsDeletedAndClose(), since that can cause a deadlock
        during the synchronous DatabaseThread call it triggers.

        * storage/DatabaseTracker.cpp:
        (WebCore::DatabaseTracker::deleteDatabaseFile):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@30233 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/storage/DatabaseTracker.cpp

index 8b37cb6..0c53aef 100644 (file)
@@ -1,3 +1,16 @@
+2008-02-14  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by Darin Adler.
+
+        <rdar://problem/5743768> A deadlock during storage layout tests
+
+        Make sure not to hold the m_openDatabaseMapGuard mutex when calling
+        Database::markAsDeletedAndClose(), since that can cause a deadlock
+        during the synchronous DatabaseThread call it triggers.
+
+        * storage/DatabaseTracker.cpp:
+        (WebCore::DatabaseTracker::deleteDatabaseFile):
+
 2008-02-14  Adam Roben  <aroben@apple.com>
 
         Improve the efficiency of SecurityOriginHash
index bc2e708..c4595e9 100644 (file)
@@ -731,6 +731,12 @@ bool DatabaseTracker::deleteDatabaseFile(SecurityOrigin* origin, const String& n
     if (fullPath.isEmpty())
         return true;
 
+    Vector<RefPtr<Database> > deletedDatabases;
+
+    // Make sure not to hold the m_openDatabaseMapGuard mutex when calling
+    // Database::markAsDeletedAndClose(), since that can cause a deadlock
+    // during the synchronous DatabaseThread call it triggers.
+
     {
         MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
         if (m_openDatabaseMap) {
@@ -744,12 +750,15 @@ bool DatabaseTracker::deleteDatabaseFile(SecurityOrigin* origin, const String& n
                     // We have some database open with this name. Mark them as deleted.
                     DatabaseSet::const_iterator end = databaseSet->end();
                     for (DatabaseSet::const_iterator it = databaseSet->begin(); it != end; ++it)
-                        (*it)->markAsDeletedAndClose();
+                        deletedDatabases.append(*it);
                 }
             }
         }
     }
 
+    for (unsigned i = 0; i < deletedDatabases.size(); ++i)
+        deletedDatabases[i]->markAsDeletedAndClose();
+
     return deleteFile(fullPath);
 }