diff options
author | Steve Block <steveblock@google.com> | 2010-08-04 11:41:34 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-08-09 12:04:44 +0100 |
commit | db14019a23d96bc8a444b6576a5da8bd1cfbc8b0 (patch) | |
tree | 9f793c5b0f5e1f2aca8247158920e2c4bf962bbf /WebCore/platform/sql/SQLiteDatabase.cpp | |
parent | bf916837aa84f1e4b00e6ed6268516c2acd27545 (diff) | |
download | external_webkit-db14019a23d96bc8a444b6576a5da8bd1cfbc8b0.zip external_webkit-db14019a23d96bc8a444b6576a5da8bd1cfbc8b0.tar.gz external_webkit-db14019a23d96bc8a444b6576a5da8bd1cfbc8b0.tar.bz2 |
Merge WebKit at r64523 : Initial merge by git.
Change-Id: Ibb796c6802e757b1d9b40f58205cfbe4da95fcd4
Diffstat (limited to 'WebCore/platform/sql/SQLiteDatabase.cpp')
-rw-r--r-- | WebCore/platform/sql/SQLiteDatabase.cpp | 43 |
1 files changed, 29 insertions, 14 deletions
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 <sqlite3.h> +#include <wtf/Threading.h> 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. <rdar://problem/5739818> // 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); |