updated to sqlite-3.5.1 now that it's stable
used new shared cache functionality (yay) --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401651
This commit is contained in:
@@ -67,11 +67,14 @@ SqDriver::SqDriver()
|
||||
{
|
||||
m_Handle = BAD_HANDLE;
|
||||
m_pOpenLock = NULL;
|
||||
m_bThreadSafe = false;
|
||||
}
|
||||
|
||||
void SqDriver::Initialize()
|
||||
{
|
||||
m_pOpenLock = threader->MakeMutex();
|
||||
|
||||
InitializeThreadSafety();
|
||||
}
|
||||
|
||||
void SqDriver::Shutdown()
|
||||
@@ -80,6 +83,11 @@ void SqDriver::Shutdown()
|
||||
{
|
||||
m_pOpenLock->DestroyThis();
|
||||
}
|
||||
|
||||
if (m_bThreadSafe)
|
||||
{
|
||||
sqlite3_enable_shared_cache(0);
|
||||
}
|
||||
}
|
||||
|
||||
bool SqDriver::IsThreadSafe()
|
||||
@@ -89,10 +97,23 @@ bool SqDriver::IsThreadSafe()
|
||||
|
||||
bool SqDriver::InitializeThreadSafety()
|
||||
{
|
||||
/* sqlite should be thread safe if the locks are done right.
|
||||
* we don't enable the "shared cache" because it can corrupt
|
||||
* open databases!
|
||||
*/
|
||||
if (m_bThreadSafe)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sqlite3_threadsafe() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sqlite3_enable_shared_cache(1) != SQLITE_OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_bThreadSafe = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ private:
|
||||
Handle_t m_Handle;
|
||||
IMutex *m_pOpenLock;
|
||||
List<SqDbInfo> m_Cache;
|
||||
bool m_bThreadSafe;
|
||||
};
|
||||
|
||||
extern SqDriver g_SqDriver;
|
||||
|
||||
Reference in New Issue
Block a user