⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244027 in webkit


Ignore:
Timestamp:
Apr 8, 2019, 10:29:51 AM (7 years ago)
Author:
youenn@apple.com
Message:

Make sure UniqueIDBDatabaseConnection unregisters itself even if its database is gone
https://bugs.webkit.org/show_bug.cgi?id=196651

Reviewed by Brady Eidson.

In UniqueIDBDatabase methods, many operations are refing the transaction
so that it stays alive until a quota check decision is made.
This extends the lifetime of the transaction which may be lasting
longer than its database that may be cleared without waiting for the quota check decisions.

We therefore need to make sure that the transaction is cleaning itself correctly at destruction time.

Make sure that the transaction is unregistering itself from its IDBServer.
To do so, the transaction keeps a weak ref to the IDBServer.

This is timing sensitive hence difficult to test.

  • Modules/indexeddb/server/IDBServer.h:
  • Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp:

(WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction):
Like done below for UniqueIDBDatabaseConnection::didCommitTransaction,
add a check to ensure that either the database is we are in an error case.

  • Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:

(WebCore::IDBServer::UniqueIDBDatabaseTransaction::UniqueIDBDatabaseTransaction):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::~UniqueIDBDatabaseTransaction):

  • Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r244025 r244027  
     12019-04-08  Youenn Fablet  <youenn@apple.com>
     2
     3        Make sure UniqueIDBDatabaseConnection unregisters itself even if its database is gone
     4        https://bugs.webkit.org/show_bug.cgi?id=196651
     5
     6        Reviewed by Brady Eidson.
     7
     8        In UniqueIDBDatabase methods, many operations are refing the transaction
     9        so that it stays alive until a quota check decision is made.
     10        This extends the lifetime of the transaction which may be lasting
     11        longer than its database that may be cleared without waiting for the quota check decisions.
     12
     13        We therefore need to make sure that the transaction is cleaning itself correctly at destruction time.
     14
     15        Make sure that the transaction is unregistering itself from its IDBServer.
     16        To do so, the transaction keeps a weak ref to the IDBServer.
     17
     18        This is timing sensitive hence difficult to test.
     19
     20        * Modules/indexeddb/server/IDBServer.h:
     21        * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp:
     22        (WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction):
     23        Like done below for UniqueIDBDatabaseConnection::didCommitTransaction,
     24        add a check to ensure that either the database is we are in an error case.
     25        * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
     26        (WebCore::IDBServer::UniqueIDBDatabaseTransaction::UniqueIDBDatabaseTransaction):
     27        (WebCore::IDBServer::UniqueIDBDatabaseTransaction::~UniqueIDBDatabaseTransaction):
     28        * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h:
     29
    1302019-04-08  Christopher Reid  <chris.reid@sony.com>
    231
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h

    r243339 r244027  
    4242#include <wtf/RefCounted.h>
    4343#include <wtf/RefPtr.h>
     44#include <wtf/WeakPtr.h>
    4445
    4546namespace WebCore {
     
    5859class IDBBackingStoreTemporaryFileHandler;
    5960
    60 class IDBServer : public RefCounted<IDBServer>, public CrossThreadTaskHandler {
     61class IDBServer : public RefCounted<IDBServer>, public CrossThreadTaskHandler, public CanMakeWeakPtr<IDBServer> {
    6162public:
    6263    using QuotaManagerGetter = WTF::Function<StorageQuotaManager*(PAL::SessionID, const ClientOrigin&)>;
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp

    r243401 r244027  
    170170    auto takenTransaction = m_transactionMap.take(transactionIdentifier);
    171171
    172     ASSERT(m_database);
    173     ASSERT(takenTransaction || m_database->hardClosedForUserDelete());
     172    ASSERT(takenTransaction || (!m_database && !error.isNull()) || (m_database && m_database->hardClosedForUserDelete()));
    174173    if (takenTransaction)
    175174        m_connectionToClient->didAbortTransaction(transactionIdentifier, error);
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp

    r243270 r244027  
    5454        m_originalDatabaseInfo = std::make_unique<IDBDatabaseInfo>(database->info());
    5555
    56     database->server().registerTransaction(*this);
     56    auto& server = database->server();
     57    m_server = makeWeakPtr(server);
     58    server.registerTransaction(*this);
    5759}
    5860
    5961UniqueIDBDatabaseTransaction::~UniqueIDBDatabaseTransaction()
    6062{
    61     auto database = m_databaseConnection->database();
    62     if (!database)
    63         return;
    64 
    65     database->transactionDestroyed(*this);
    66     database->server().unregisterTransaction(*this);
     63    if (auto database = m_databaseConnection->database())
     64        database->transactionDestroyed(*this);
     65
     66    if (m_server)
     67        m_server->unregisterTransaction(*this);
    6768}
    6869
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h

    r208486 r244027  
    5151namespace IDBServer {
    5252
     53class IDBServer;
    5354class UniqueIDBDatabaseConnection;
    5455
     
    9495    Ref<UniqueIDBDatabaseConnection> m_databaseConnection;
    9596    IDBTransactionInfo m_transactionInfo;
     97    WeakPtr<IDBServer> m_server;
    9698
    9799    std::unique_ptr<IDBDatabaseInfo> m_originalDatabaseInfo;
Note: See TracChangeset for help on using the changeset viewer.