Title: [194256] trunk
Revision
194256
Author
[email protected]
Date
2015-12-17 19:06:11 -0800 (Thu, 17 Dec 2015)

Log Message

Unreviewed, rolling out r194241 and r194252.
https://bugs.webkit.org/show_bug.cgi?id=152415

Caused crashes on GuardMalloc (Requested by ap on #webkit).

Reverted changesets:

"Modern IDB: Refactor open/delete requests to exist in the
same queue."
https://bugs.webkit.org/show_bug.cgi?id=152397
http://trac.webkit.org/changeset/194241

"Modern IDB: Refactor when opening the backing store takes
place."
https://bugs.webkit.org/show_bug.cgi?id=152405
http://trac.webkit.org/changeset/194252

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (194255 => 194256)


--- trunk/LayoutTests/ChangeLog	2015-12-18 02:46:47 UTC (rev 194255)
+++ trunk/LayoutTests/ChangeLog	2015-12-18 03:06:11 UTC (rev 194256)
@@ -1,3 +1,22 @@
+2015-12-17  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r194241 and r194252.
+        https://bugs.webkit.org/show_bug.cgi?id=152415
+
+        Caused crashes on GuardMalloc (Requested by ap on #webkit).
+
+        Reverted changesets:
+
+        "Modern IDB: Refactor open/delete requests to exist in the
+        same queue."
+        https://bugs.webkit.org/show_bug.cgi?id=152397
+        http://trac.webkit.org/changeset/194241
+
+        "Modern IDB: Refactor when opening the backing store takes
+        place."
+        https://bugs.webkit.org/show_bug.cgi?id=152405
+        http://trac.webkit.org/changeset/194252
+
 2015-12-17  Sukolsak Sakshuwong  <[email protected]>
 
         [INTL] Implement Collator Compare Functions

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (194255 => 194256)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2015-12-18 02:46:47 UTC (rev 194255)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2015-12-18 03:06:11 UTC (rev 194256)
@@ -99,6 +99,7 @@
 storage/indexeddb/intversion-two-opens-no-versions.html [ Failure ]
 storage/indexeddb/odd-strings.html [ Failure ]
 storage/indexeddb/open-db-private-browsing.html [ Failure ]
+storage/indexeddb/open-ordering.html [ Failure ]
 storage/indexeddb/properties-disabled-at-runtime.html [ Failure ]
 storage/indexeddb/setversion-blocked-by-versionchange-close.html [ Failure ]
 storage/indexeddb/transaction-basics.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (194255 => 194256)


--- trunk/Source/WebCore/ChangeLog	2015-12-18 02:46:47 UTC (rev 194255)
+++ trunk/Source/WebCore/ChangeLog	2015-12-18 03:06:11 UTC (rev 194256)
@@ -1,3 +1,22 @@
+2015-12-17  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r194241 and r194252.
+        https://bugs.webkit.org/show_bug.cgi?id=152415
+
+        Caused crashes on GuardMalloc (Requested by ap on #webkit).
+
+        Reverted changesets:
+
+        "Modern IDB: Refactor open/delete requests to exist in the
+        same queue."
+        https://bugs.webkit.org/show_bug.cgi?id=152397
+        http://trac.webkit.org/changeset/194241
+
+        "Modern IDB: Refactor when opening the backing store takes
+        place."
+        https://bugs.webkit.org/show_bug.cgi?id=152405
+        http://trac.webkit.org/changeset/194252
+
 2015-12-17  Brady Eidson  <[email protected]>
 
         Modern IDB: Refactor when opening the backing store takes place.

Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServerOperation.cpp (194255 => 194256)


--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServerOperation.cpp	2015-12-18 02:46:47 UTC (rev 194255)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServerOperation.cpp	2015-12-18 03:06:11 UTC (rev 194256)
@@ -28,7 +28,6 @@
 
 #if ENABLE(INDEXED_DATABASE)
 
-#include "IDBResultData.h"
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
@@ -55,22 +54,6 @@
     return m_requestData.isDeleteRequest();
 }
 
-void IDBServerOperation::notifyDeleteRequestBlocked(uint64_t currentVersion)
-{
-    ASSERT(isDeleteRequest());
-    ASSERT(!m_notifiedDeleteRequestBlocked);
-
-    m_connection.notifyOpenDBRequestBlocked(m_requestData.requestIdentifier(), currentVersion, 0);
-    m_notifiedDeleteRequestBlocked = true;
-}
-
-void IDBServerOperation::notifyDidDeleteDatabase(const IDBDatabaseInfo& info)
-{
-    ASSERT(isDeleteRequest());
-
-    m_connection.didDeleteDatabase(IDBResultData::deleteDatabaseSuccess(m_requestData.requestIdentifier(), info));
-}
-
 } // namespace IDBServer
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServerOperation.h (194255 => 194256)


--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServerOperation.h	2015-12-18 02:46:47 UTC (rev 194255)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServerOperation.h	2015-12-18 03:06:11 UTC (rev 194256)
@@ -34,9 +34,6 @@
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
-
-class IDBDatabaseInfo;
-
 namespace IDBServer {
 
 class IDBServerOperation : public RefCounted<IDBServerOperation> {
@@ -49,17 +46,11 @@
     bool isOpenRequest() const;
     bool isDeleteRequest() const;
 
-    void notifyDeleteRequestBlocked(uint64_t currentVersion);
-    void notifyDidDeleteDatabase(const IDBDatabaseInfo&);
-    bool hasNotifiedDeleteRequestBlocked() const { return m_notifiedDeleteRequestBlocked; }
-
 private:
     IDBServerOperation(IDBConnectionToClient&, const IDBRequestData&);
 
     IDBConnectionToClient& m_connection;
     IDBRequestData m_requestData;
-
-    bool m_notifiedDeleteRequestBlocked { false };
 };
 
 } // namespace IDBServer

Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (194255 => 194256)


--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp	2015-12-18 02:46:47 UTC (rev 194255)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp	2015-12-18 03:06:11 UTC (rev 194256)
@@ -51,15 +51,6 @@
 {
 }
 
-UniqueIDBDatabase::~UniqueIDBDatabase()
-{
-    LOG(IndexedDB, "UniqueIDBDatabase::~UniqueIDBDatabase()");
-    ASSERT(!hasAnyPendingCallbacks());
-    ASSERT(m_inProgressTransactions.isEmpty());
-    ASSERT(m_pendingTransactions.isEmpty());
-    ASSERT(m_openDatabaseConnections.isEmpty());
-}
-
 const IDBDatabaseInfo& UniqueIDBDatabase::info() const
 {
     RELEASE_ASSERT(m_databaseInfo);
@@ -69,13 +60,19 @@
 void UniqueIDBDatabase::openDatabaseConnection(IDBConnectionToClient& connection, const IDBRequestData& requestData)
 {
     auto operation = IDBServerOperation::create(connection, requestData);
-    m_pendingDatabaseOperations.append(WTF::move(operation));
+    m_pendingOpenDatabaseOperations.append(WTF::move(operation));
 
-    // An open operation is already in progress, so we can't possibly handle this one yet.
+    // An open operation is already in progress, so this one has to wait.
     if (m_isOpeningBackingStore)
         return;
 
-    handleDatabaseOperations();
+    if (m_databaseInfo) {
+        handleDatabaseOperations();
+        return;
+    }
+
+    m_isOpeningBackingStore = true;
+    m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::openBackingStore, m_identifier));
 }
 
 bool UniqueIDBDatabase::hasAnyPendingCallbacks() const
@@ -86,14 +83,39 @@
         || !m_countCallbacks.isEmpty();
 }
 
-bool UniqueIDBDatabase::isVersionChangeInProgress()
+bool UniqueIDBDatabase::maybeDeleteDatabase(IDBServerOperation* newestDeleteOperation)
 {
-#ifndef NDEBUG
-    if (m_versionChangeTransaction)
-        ASSERT(m_versionChangeDatabaseConnection);
-#endif
+    ASSERT(isMainThread());
+    LOG(IndexedDB, "(main) UniqueIDBDatabase::maybeDeleteDatabase");
 
-    return m_versionChangeDatabaseConnection;
+    if (hasAnyOpenConnections() || !m_closePendingDatabaseConnections.isEmpty()) {
+        // Exactly once, notify all open connections of the pending deletion.
+        if (!m_hasNotifiedConnectionsOfDelete) {
+            notifyConnectionsOfVersionChange(0);
+            m_hasNotifiedConnectionsOfDelete = true;
+        }
+
+        if (newestDeleteOperation)
+            newestDeleteOperation->connection().notifyOpenDBRequestBlocked(newestDeleteOperation->requestData().requestIdentifier(), m_databaseInfo->version(), 0);
+
+        return false;
+    }
+
+    ASSERT(!hasAnyPendingCallbacks());
+    ASSERT(m_inProgressTransactions.isEmpty());
+    ASSERT(m_pendingTransactions.isEmpty());
+    ASSERT(m_openDatabaseConnections.isEmpty());
+    ASSERT(m_pendingOpenDatabaseOperations.isEmpty());
+
+    for (auto& operation : m_pendingDeleteDatabaseOperations) {
+        ASSERT(m_databaseInfo);
+        ASSERT(operation->isDeleteRequest());
+        operation->connection().didDeleteDatabase(IDBResultData::deleteDatabaseSuccess(operation->requestData().requestIdentifier(), *m_databaseInfo));
+    }
+
+    m_server.deleteUniqueIDBDatabase(*this);
+
+    return true;
 }
 
 void UniqueIDBDatabase::performCurrentOpenOperation()
@@ -103,20 +125,6 @@
     ASSERT(m_currentOperation);
     ASSERT(m_currentOperation->isOpenRequest());
 
-    if (!m_databaseInfo) {
-        m_isOpeningBackingStore = true;
-        m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::openBackingStore, m_identifier));
-        return;
-    }
-
-    // If we previously started a version change operation but were blocked by having open connections,
-    // we might now be unblocked.
-    if (m_versionChangeDatabaseConnection) {
-        if (!m_versionChangeTransaction && !hasAnyOpenConnections())
-            startVersionChangeTransaction();
-        return;
-    }
-
     // 3.3.1 Opening a database
     // If requested version is undefined, then let requested version be 1 if db was created in the previous step,
     // or the current version of db otherwise.
@@ -168,83 +176,36 @@
 {
     LOG(IndexedDB, "(main) UniqueIDBDatabase::performCurrentDeleteOperation");
 
-    ASSERT(m_databaseInfo);
-    ASSERT(m_currentOperation);
-    ASSERT(m_currentOperation->isDeleteRequest());
-
-    if (hasAnyOpenConnections()) {
-        // Exactly once, notify all open connections of the pending deletion.
-        if (!m_hasNotifiedConnectionsOfDelete) {
-            notifyConnectionsOfVersionChange(0);
-            m_hasNotifiedConnectionsOfDelete = true;
-        }
-
-        if (!m_currentOperation->hasNotifiedDeleteRequestBlocked())
-            m_currentOperation->notifyDeleteRequestBlocked(m_databaseInfo->version());
-
-        return;
-    }
-
-    ASSERT(!hasAnyPendingCallbacks());
-    ASSERT(m_inProgressTransactions.isEmpty());
-    ASSERT(m_pendingTransactions.isEmpty());
-    ASSERT(m_openDatabaseConnections.isEmpty());
-
-    m_currentOperation->notifyDidDeleteDatabase(*m_databaseInfo);
-    m_currentOperation = nullptr;
-    m_hasNotifiedConnectionsOfDelete = false;
-    m_deletePending = false;
-
-    if (m_pendingDatabaseOperations.isEmpty())
-        m_server.deleteUniqueIDBDatabase(*this);
-    else
-        invokeOperationAndTransactionTimer();
+    // Not used yet.
 }
 
 void UniqueIDBDatabase::handleDatabaseOperations()
 {
     ASSERT(isMainThread());
-    LOG(IndexedDB, "(main) UniqueIDBDatabase::handleDatabaseOperations - There are %zu pending", m_pendingDatabaseOperations.size());
+    LOG(IndexedDB, "(main) UniqueIDBDatabase::handleDatabaseOperations");
 
-    if (m_versionChangeDatabaseConnection || m_currentOperation) {
-        // We can't start the next database operation quite yet, but we might need to notify all open connections
-        // about a pending delete.
-        if (!m_pendingDatabaseOperations.isEmpty() && m_pendingDatabaseOperations.first()->isDeleteRequest() && !m_hasNotifiedConnectionsOfDelete) {
-            m_hasNotifiedConnectionsOfDelete = true;
-            notifyConnectionsOfVersionChange(0);
-        }
+    // If a version change transaction is currently in progress, no new connections can be opened right now.
+    // We will try again later.
+    if (m_versionChangeDatabaseConnection)
+        return;
 
-        // Some operations (such as the first open operation after a delete) require multiple passes to completely handle
-        if (m_currentOperation)
-            handleCurrentOperation();
-
+    if (m_pendingOpenDatabaseOperations.isEmpty())
         return;
-    }
 
-    if (m_pendingDatabaseOperations.isEmpty())
+    if (m_currentOperation)
         return;
 
-    m_currentOperation = m_pendingDatabaseOperations.takeFirst();
-    LOG(IndexedDB, "UniqueIDBDatabase::handleDatabaseOperations - Popped an operation, now there are %zu pending", m_pendingDatabaseOperations.size());
+    m_currentOperation = m_pendingOpenDatabaseOperations.takeFirst();
 
-    handleCurrentOperation();
-}
+    // FIXME: Once handleDatabaseOperations also handles delete operations, remove this ASSERT.
+    ASSERT(m_currentOperation->isOpenRequest());
 
-void UniqueIDBDatabase::handleCurrentOperation()
-{
-    ASSERT(m_currentOperation);
-
-    RefPtr<UniqueIDBDatabase> protector(this);
-
     if (m_currentOperation->isOpenRequest())
         performCurrentOpenOperation();
     else if (m_currentOperation->isDeleteRequest())
         performCurrentDeleteOperation();
     else
         ASSERT_NOT_REACHED();
-
-    if (!m_currentOperation)
-        invokeOperationAndTransactionTimer();
 }
 
 bool UniqueIDBDatabase::hasAnyOpenConnections() const
@@ -295,8 +256,18 @@
 {
     LOG(IndexedDB, "(main) UniqueIDBDatabase::handleDelete");
 
-    m_pendingDatabaseOperations.append(IDBServerOperation::create(connection, requestData));
-    handleDatabaseOperations();
+    auto operation = IDBServerOperation::create(connection, requestData);
+    auto* rawOperation = &operation.get();
+    m_pendingDeleteDatabaseOperations.append(WTF::move(operation));
+
+    // If a different request has already come in to delete this database, there's nothing left to do.
+    // A delete is already in progress, and this request will be handled along with all the rest.
+    if (m_deletePending)
+        return;
+
+    m_deletePending = true;
+
+    maybeDeleteDatabase(rawOperation);
 }
 
 void UniqueIDBDatabase::startVersionChangeTransaction()
@@ -966,7 +937,6 @@
 
 void UniqueIDBDatabase::invokeOperationAndTransactionTimer()
 {
-    LOG(IndexedDB, "UniqueIDBDatabase::invokeOperationAndTransactionTimer()");
     if (!m_operationAndTransactionTimer.isActive())
         m_operationAndTransactionTimer.startOneShot(0);
 }
@@ -975,14 +945,19 @@
 {
     LOG(IndexedDB, "(main) UniqueIDBDatabase::operationAndTransactionTimerFired");
 
-    // The current operation might require multiple attempts to handle, so try to
-    // make further progress on it now.
-    if (m_currentOperation)
-        handleCurrentOperation();
+    handleDatabaseOperations();
 
-    if (!m_currentOperation)
-        handleDatabaseOperations();
+    if (m_deletePending && maybeDeleteDatabase(nullptr))
+        return;
 
+    // If the database was not deleted in the previous step, try to run a transaction now.
+    if (m_pendingTransactions.isEmpty()) {
+        if (!hasAnyOpenConnections() && m_currentOperation) {
+            startVersionChangeTransaction();
+            return;
+        }
+    }
+
     bool hadDeferredTransactions = false;
     auto transaction = takeNextRunnableTransaction(hadDeferredTransactions);
 

Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h (194255 => 194256)


--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h	2015-12-18 02:46:47 UTC (rev 194255)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h	2015-12-18 03:06:11 UTC (rev 194256)
@@ -71,8 +71,6 @@
         return adoptRef(*new UniqueIDBDatabase(server, identifier));
     }
 
-    ~UniqueIDBDatabase();
-
     void openDatabaseConnection(IDBConnectionToClient&, const IDBRequestData&);
 
     const IDBDatabaseInfo& info() const;
@@ -107,16 +105,15 @@
     UniqueIDBDatabase(IDBServer&, const IDBDatabaseIdentifier&);
     
     void handleDatabaseOperations();
-    void handleCurrentOperation();
     void performCurrentOpenOperation();
     void performCurrentDeleteOperation();
     void addOpenDatabaseConnection(Ref<UniqueIDBDatabaseConnection>&&);
+    bool maybeDeleteDatabase(IDBServerOperation*);
     bool hasAnyOpenConnections() const;
 
     void startVersionChangeTransaction();
     void notifyConnectionsOfVersionChangeForUpgrade();
     void notifyConnectionsOfVersionChange(uint64_t requestedVersion);
-    bool isVersionChangeInProgress();
 
     void activateTransactionInBackingStore(UniqueIDBDatabaseTransaction&);
     void inProgressTransactionCompleted(const IDBResourceIdentifier&);
@@ -176,7 +173,8 @@
     IDBServer& m_server;
     IDBDatabaseIdentifier m_identifier;
     
-    Deque<Ref<IDBServerOperation>> m_pendingDatabaseOperations;
+    Deque<Ref<IDBServerOperation>> m_pendingOpenDatabaseOperations;
+    Deque<Ref<IDBServerOperation>> m_pendingDeleteDatabaseOperations;
     RefPtr<IDBServerOperation> m_currentOperation;
 
     HashSet<RefPtr<UniqueIDBDatabaseConnection>> m_openDatabaseConnections;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to