Commit 788c299c authored by mrowe@apple.com's avatar mrowe@apple.com

2007-11-12 Justin Haygood <jhaygood@reaktix.com>

        Reviewed by Brady.

        http://bugs.webkit.org/show_bug.cgi?id=15955
        Reimplement threading functions in IconDatabase and SQLiteDatabase in terms of the threading abstractions

        * loader/icon/IconDatabase.cpp:
        (WebCore::IconDatabase::open):
        (WebCore::IconDatabase::close):
        * loader/icon/IconDatabase.h:
        * platform/sql/SQLiteDatabase.cpp:
        (WebCore::SQLiteDatabase::SQLiteDatabase):
        (WebCore::SQLiteDatabase::open):
        (WebCore::SQLiteDatabase::close):
        * platform/sql/SQLiteDatabase.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@27717 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1840f962
2007-11-12 Justin Haygood <jhaygood@reaktix.com>
Reviewed by Brady.
http://bugs.webkit.org/show_bug.cgi?id=15955
Reimplement threading functions in IconDatabase and SQLiteDatabase in terms of the threading abstractions
* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::open):
(WebCore::IconDatabase::close):
* loader/icon/IconDatabase.h:
* platform/sql/SQLiteDatabase.cpp:
(WebCore::SQLiteDatabase::SQLiteDatabase):
(WebCore::SQLiteDatabase::open):
(WebCore::SQLiteDatabase::close):
* platform/sql/SQLiteDatabase.h:
2007-11-12 Adam Roben <aroben@apple.com>
Windows build fix
......
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -49,13 +50,17 @@
#include <sys/stat.h>
#endif
#if PLATFORM(DARWIN)
#include <pthread.h>
#endif
#include <errno.h>
// For methods that are meant to support API from the main thread - should not be called internally
#define ASSERT_NOT_SYNC_THREAD() ASSERT(!m_syncThreadRunning || !IS_ICON_SYNC_THREAD())
// For methods that are meant to support the sync thread ONLY
#define IS_ICON_SYNC_THREAD() pthread_equal(pthread_self(), m_syncThread)
#define IS_ICON_SYNC_THREAD() m_syncThread == currentThread()
#define ASSERT_ICON_SYNC_THREAD() ASSERT(IS_ICON_SYNC_THREAD())
namespace WebCore {
......@@ -136,13 +141,13 @@ bool IconDatabase::open(const String& databasePath)
// Formulate the full path for the database file
m_completeDatabasePath = pathByAppendingComponent(m_databaseDirectory, defaultDatabaseFilename());
// Lock here as well as first thing in the thread so the tread doesn't actually commence until the pthread_create() call
// Lock here as well as first thing in the thread so the thread doesn't actually commence until the createThread() call
// completes and m_syncThreadRunning is properly set
m_syncLock.lock();
m_syncThreadRunning = !pthread_create(&m_syncThread, NULL, IconDatabase::iconDatabaseSyncThreadStart, this);
m_syncLock.unlock();
return m_syncThreadRunning;
m_syncThread = createThread(IconDatabase::iconDatabaseSyncThreadStart, this);
if (!m_syncThread)
return false;
return true;
}
void IconDatabase::close()
......@@ -157,8 +162,7 @@ void IconDatabase::close()
wakeSyncThread();
// Wait for the sync thread to terminate
if (pthread_join(m_syncThread, NULL) == EDEADLK)
LOG_ERROR("m_syncThread was found to be deadlocked trying to quit");
waitForThreadCompletion(m_syncThread, 0);
}
m_syncThreadRunning = false;
......
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -120,7 +121,7 @@ private:
OwnPtr<Timer<IconDatabase> > m_syncTimer;
void syncTimerFired(Timer<IconDatabase>*);
pthread_t m_syncThread;
ThreadIdentifier m_syncThread;
bool m_syncThreadRunning;
HashSet<RefPtr<DocumentLoader> > m_loadersPendingDecision;
......
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -44,10 +45,8 @@ const int SQLResultSchema = SQLITE_SCHEMA;
SQLiteDatabase::SQLiteDatabase()
: m_db(0)
, m_transactionInProgress(false)
, m_openingThread(0)
{
#ifndef NDEBUG
memset(&m_openingThread, 0, sizeof(pthread_t));
#endif
}
SQLiteDatabase::~SQLiteDatabase()
......@@ -71,10 +70,8 @@ bool SQLiteDatabase::open(const String& filename)
return false;
}
#ifndef NDEBUG
if (isOpen())
m_openingThread = pthread_self();
#endif
m_openingThread = currentThread();
if (!SQLiteStatement(*this, "PRAGMA temp_store = MEMORY;").executeCommand())
LOG_ERROR("SQLite database could not set temp_store to memory");
......@@ -89,9 +86,8 @@ void SQLiteDatabase::close()
m_path.truncate(0);
m_db = 0;
}
#ifndef NDEBUG
memset(&m_openingThread, 0, sizeof(pthread_t));
#endif
m_openingThread = 0;
}
void SQLiteDatabase::setFullsync(bool fsync)
......@@ -296,5 +292,3 @@ void SQLiteDatabase::unlock()
}
} // namespace WebCore
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -31,10 +32,6 @@
#include <wtf/Noncopyable.h>
#include <wtf/Vector.h>
#ifndef NDEBUG
#include <pthread.h>
#endif
#if COMPILER(MSVC)
#pragma warning(disable: 4800)
#endif
......@@ -97,7 +94,7 @@ public:
const char* lastErrorMsg();
sqlite3* sqlite3Handle() const {
ASSERT(pthread_equal(m_openingThread, pthread_self()));
ASSERT(currentThread() == m_openingThread);
return m_db;
}
......@@ -119,9 +116,7 @@ private:
RefPtr<SQLiteAuthorizer> m_authorizer;
Mutex m_lockingMutex;
#ifndef NDEBUG
pthread_t m_openingThread;
#endif
ThreadIdentifier m_openingThread;
}; // class SQLiteDatabase
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment