diff options
Diffstat (limited to 'WebCore/storage')
-rw-r--r-- | WebCore/storage/SQLTransaction.cpp | 13 | ||||
-rw-r--r-- | WebCore/storage/SQLTransaction.h | 1 | ||||
-rw-r--r-- | WebCore/storage/SQLTransactionCoordinator.cpp | 14 |
3 files changed, 28 insertions, 0 deletions
diff --git a/WebCore/storage/SQLTransaction.cpp b/WebCore/storage/SQLTransaction.cpp index de615ca..db25e1a 100644 --- a/WebCore/storage/SQLTransaction.cpp +++ b/WebCore/storage/SQLTransaction.cpp @@ -35,6 +35,7 @@ #include "Database.h" #include "DatabaseAuthorizer.h" #include "DatabaseDetails.h" +#include "DatabaseThread.h" #include "ExceptionCode.h" #include "Logging.h" #include "Page.h" @@ -83,6 +84,7 @@ SQLTransaction::SQLTransaction(Database* db, PassRefPtr<SQLTransactionCallback> SQLTransaction::~SQLTransaction() { + ASSERT(!m_sqliteTransaction); } void SQLTransaction::executeSQL(const String& sqlStatement, const Vector<SQLValue>& arguments, PassRefPtr<SQLStatementCallback> callback, PassRefPtr<SQLStatementErrorCallback> callbackError, ExceptionCode& e) @@ -203,6 +205,16 @@ void SQLTransaction::performPendingCallback() (this->*m_nextStep)(); } +void SQLTransaction::notifyDatabaseThreadIsShuttingDown() +{ + ASSERT(currentThread() == database()->scriptExecutionContext()->databaseThread()->getThreadID()); + + // If the transaction is in progress, we should roll it back here, since this is our last + // oportunity to do something related to this transaction on the DB thread. + // Clearing m_sqliteTransaction invokes SQLiteTransaction's destructor which does just that. + m_sqliteTransaction.clear(); +} + void SQLTransaction::acquireLock() { m_database->transactionCoordinator()->acquireLock(this); @@ -491,6 +503,7 @@ void SQLTransaction::cleanupAfterSuccessCallback() // There is no next step LOG(StorageAPI, "Transaction %p is complete\n", this); ASSERT(!m_database->m_sqliteDatabase.transactionInProgress()); + m_sqliteTransaction.clear(); m_nextStep = 0; // Release the lock on this database diff --git a/WebCore/storage/SQLTransaction.h b/WebCore/storage/SQLTransaction.h index 6d6a8d7..1b02d01 100644 --- a/WebCore/storage/SQLTransaction.h +++ b/WebCore/storage/SQLTransaction.h @@ -80,6 +80,7 @@ public: Database* database() { return m_database.get(); } bool isReadOnly() { return m_readOnly; } + void notifyDatabaseThreadIsShuttingDown(); private: SQLTransaction(Database*, PassRefPtr<SQLTransactionCallback>, PassRefPtr<SQLTransactionErrorCallback>, diff --git a/WebCore/storage/SQLTransactionCoordinator.cpp b/WebCore/storage/SQLTransactionCoordinator.cpp index efdcd1d..0fe5bda 100644 --- a/WebCore/storage/SQLTransactionCoordinator.cpp +++ b/WebCore/storage/SQLTransactionCoordinator.cpp @@ -109,6 +109,20 @@ void SQLTransactionCoordinator::releaseLock(SQLTransaction* transaction) void SQLTransactionCoordinator::shutdown() { + // Notify all transactions in progress that the database thread is shutting down + for (CoordinationInfoMap::iterator coordinationInfoIterator = m_coordinationInfoMap.begin(); + coordinationInfoIterator != m_coordinationInfoMap.end(); ++coordinationInfoIterator) { + CoordinationInfo& info = coordinationInfoIterator->second; + if (info.activeWriteTransaction) + info.activeWriteTransaction->notifyDatabaseThreadIsShuttingDown(); + for (HashSet<RefPtr<SQLTransaction> >::iterator activeReadTransactionsIterator = + info.activeReadTransactions.begin(); + activeReadTransactionsIterator != info.activeReadTransactions.end(); + ++activeReadTransactionsIterator) { + (*activeReadTransactionsIterator)->notifyDatabaseThreadIsShuttingDown(); + } + } + // Clean up all pending transactions for all databases m_coordinationInfoMap.clear(); } |