Title: [219772] branches/safari-604-branch/Source/WebCore

Diff

Modified: branches/safari-604-branch/Source/WebCore/ChangeLog (219771 => 219772)


--- branches/safari-604-branch/Source/WebCore/ChangeLog	2017-07-23 06:50:47 UTC (rev 219771)
+++ branches/safari-604-branch/Source/WebCore/ChangeLog	2017-07-23 06:50:50 UTC (rev 219772)
@@ -1,5 +1,28 @@
 2017-07-22  Jason Marcell  <[email protected]>
 
+        Cherry-pick r219591. rdar://problem/33464112
+
+    2017-07-17  Brady Eidson  <[email protected]>
+
+            REGRESSION(r219298): imported/w3c/IndexedDB-private-browsing/idbfactory_open.html is crashing occassionaly (UniqueIDBDatabase being taken from the IDBServer set twice).
+            <rdar://problem/33294987> and https://bugs.webkit.org/show_bug.cgi?id=174354
+
+            Reviewed by Alex Christensen.
+
+            No new tests (Covered by existing tests).
+
+            * Modules/indexeddb/server/IDBServer.cpp:
+            (WebCore::IDBServer::IDBServer::postDatabaseTaskReply): Remove a now invalid ASSERT
+
+            * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+            (WebCore::IDBServer::UniqueIDBDatabase::scheduleShutdownForClose): Add a RELEASE_ASSERT.
+            (WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore): Instead of an ad-hoc main thread dispatch, use the "schedule task reply" system
+              to keep dispatch ordering in tact.
+            (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): Remove a now invalid ASSERT
+            (WebCore::IDBServer::UniqueIDBDatabase::immediateCloseForUserDelete): Only take the owning pointer if the object doesn't already own itself.
+
+2017-07-22  Jason Marcell  <[email protected]>
+
         Cherry-pick r219585. rdar://problem/33465177
 
     2017-07-17  Wenson Hsieh  <[email protected]>

Modified: branches/safari-604-branch/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (219771 => 219772)


--- branches/safari-604-branch/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp	2017-07-23 06:50:47 UTC (rev 219771)
+++ branches/safari-604-branch/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp	2017-07-23 06:50:50 UTC (rev 219772)
@@ -493,10 +493,8 @@
 
 void IDBServer::postDatabaseTaskReply(CrossThreadTask&& task)
 {
-    ASSERT(!isMainThread());
     m_databaseReplyQueue.append(WTFMove(task));
 
-
     Locker<Lock> locker(m_mainThreadReplyLock);
     if (m_mainThreadReplyScheduled)
         return;

Modified: branches/safari-604-branch/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (219771 => 219772)


--- branches/safari-604-branch/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp	2017-07-23 06:50:47 UTC (rev 219771)
+++ branches/safari-604-branch/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp	2017-07-23 06:50:50 UTC (rev 219772)
@@ -274,7 +274,9 @@
 {
     ASSERT(isMainThread());
 
+    RELEASE_ASSERT(!m_owningPointerForClose);
     m_owningPointerForClose = m_server.closeAndTakeUniqueIDBDatabase(*this);
+
     postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::shutdownForClose));
 }
 
@@ -337,8 +339,12 @@
         ASSERT(m_databaseQueue.isEmpty());
         ASSERT(m_databaseReplyQueue.isEmpty());
         m_databaseQueue.kill();
-        m_databaseReplyQueue.kill();
-        callOnMainThread([owningRef = m_server.closeAndTakeUniqueIDBDatabase(*this)]{ });
+
+        RELEASE_ASSERT(!m_owningPointerForClose);
+        m_owningPointerForClose = m_server.closeAndTakeUniqueIDBDatabase(*this);
+        ASSERT(m_owningPointerForClose);
+
+        postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didShutdownForClose));
         return;
     }
 
@@ -1742,8 +1748,6 @@
 
 void UniqueIDBDatabase::postDatabaseTaskReply(CrossThreadTask&& task)
 {
-    ASSERT(!isMainThread());
-
     m_databaseReplyQueue.append(WTFMove(task));
     m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::executeNextDatabaseTaskReply));
 }
@@ -1777,6 +1781,10 @@
 void UniqueIDBDatabase::maybeFinishHardClose()
 {
     if (m_owningPointerForClose && isDoneWithHardClose()) {
+        if (m_owningPointerReleaseScheduled)
+            return;
+        m_owningPointerReleaseScheduled = true;
+
         callOnMainThread([this] {
             ASSERT(isDoneWithHardClose());
             m_owningPointerForClose = nullptr;
@@ -1864,11 +1872,15 @@
     // database connections confirm that they have closed.
     m_hardClosedForUserDelete = true;
 
-    // Remove this UniqueIDBDatabase from the IDBServer's set of open databases, and let it own itself.
-    // It will dispatch back to the main thread later to finalize deleting itself.
+    // If this database already owns itself, it is already closing on the background thread.
+    // After that close completes, the next database thread task will be "delete all currently closed databases"
+    // which will also cover this database.
+    if (m_owningPointerForClose)
+        return;
+
+    // Otherwise, this database is still potentially active.
+    // So we'll have it own itself and then perform a clean unconditional delete on the background thread.
     m_owningPointerForClose = m_server.closeAndTakeUniqueIDBDatabase(*this);
-
-    // Have the database unconditionally delete itself on the database task queue.
     postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performUnconditionalDeleteBackingStore));
 }
 

Modified: branches/safari-604-branch/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h (219771 => 219772)


--- branches/safari-604-branch/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h	2017-07-23 06:50:47 UTC (rev 219771)
+++ branches/safari-604-branch/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h	2017-07-23 06:50:50 UTC (rev 219772)
@@ -266,6 +266,7 @@
     CrossThreadQueue<CrossThreadTask> m_databaseReplyQueue;
 
     bool m_hardClosedForUserDelete { false };
+    bool m_owningPointerReleaseScheduled { false };
     std::unique_ptr<UniqueIDBDatabase> m_owningPointerForClose;
 
     HashSet<IDBResourceIdentifier> m_cursorPrefetches;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to