From db14019a23d96bc8a444b6576a5da8bd1cfbc8b0 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Wed, 4 Aug 2010 11:41:34 +0100 Subject: Merge WebKit at r64523 : Initial merge by git. Change-Id: Ibb796c6802e757b1d9b40f58205cfbe4da95fcd4 --- WebCore/platform/sql/SQLiteDatabase.cpp | 43 ++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'WebCore/platform/sql/SQLiteDatabase.cpp') diff --git a/WebCore/platform/sql/SQLiteDatabase.cpp b/WebCore/platform/sql/SQLiteDatabase.cpp index 75fc032..05a2a22 100644 --- a/WebCore/platform/sql/SQLiteDatabase.cpp +++ b/WebCore/platform/sql/SQLiteDatabase.cpp @@ -31,8 +31,8 @@ #include "Logging.h" #include "SQLiteFileSystem.h" #include "SQLiteStatement.h" - #include +#include namespace WebCore { @@ -42,7 +42,7 @@ const int SQLResultOk = SQLITE_OK; const int SQLResultRow = SQLITE_ROW; const int SQLResultSchema = SQLITE_SCHEMA; const int SQLResultFull = SQLITE_FULL; - +const int SQLResultInterrupt = SQLITE_INTERRUPT; SQLiteDatabase::SQLiteDatabase() : m_db(0) @@ -50,6 +50,7 @@ SQLiteDatabase::SQLiteDatabase() , m_transactionInProgress(false) , m_sharable(false) , m_openingThread(0) + , m_interrupted(false) { } @@ -85,13 +86,37 @@ void SQLiteDatabase::close() if (m_db) { // FIXME: This is being called on themain thread during JS GC. // ASSERT(currentThread() == m_openingThread); - sqlite3_close(m_db); - m_db = 0; + sqlite3* db = m_db; + { + MutexLocker locker(m_databaseClosingMutex); + m_db = 0; + } + sqlite3_close(db); } m_openingThread = 0; } +void SQLiteDatabase::interrupt() +{ + m_interrupted = true; + while (!m_lockingMutex.tryLock()) { + MutexLocker locker(m_databaseClosingMutex); + if (!m_db) + return; + sqlite3_interrupt(m_db); + yield(); + } + + m_lockingMutex.unlock(); +} + +bool SQLiteDatabase::isInterrupted() +{ + ASSERT(!m_lockingMutex.tryLock()); + return m_interrupted; +} + void SQLiteDatabase::setFullsync(bool fsync) { if (fsync) @@ -397,16 +422,6 @@ void SQLiteDatabase::enableAuthorizer(bool enable) sqlite3_set_authorizer(m_db, NULL, 0); } -void SQLiteDatabase::lock() -{ - m_lockingMutex.lock(); -} - -void SQLiteDatabase::unlock() -{ - m_lockingMutex.unlock(); -} - bool SQLiteDatabase::isAutoCommitOn() const { return sqlite3_get_autocommit(m_db); -- cgit v1.1