From fcdd17480cb996be047c3e2b2b3065aa9f60f54c Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 2 Oct 2007 23:38:31 +0000 Subject: [PATCH] fix for amb253 - database now spinlocks instead of failing to lock --- dlls/sqlite/sqlitepp/SqliteDriver.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dlls/sqlite/sqlitepp/SqliteDriver.cpp b/dlls/sqlite/sqlitepp/SqliteDriver.cpp index a65a5ea6..b49447ba 100644 --- a/dlls/sqlite/sqlitepp/SqliteDriver.cpp +++ b/dlls/sqlite/sqlitepp/SqliteDriver.cpp @@ -7,6 +7,10 @@ #if defined WIN32 #define snprintf _snprintf #define strncasecmp strnicmp +#define WINDOWS_LEAN_AND_MEAN +#include +#else +#include #endif using namespace SourceMod; @@ -21,6 +25,17 @@ const char *SqliteDriver::NameString() return "sqlite"; } +int busy_handler(void *unused1, int unused2) +{ +#if defined __linux__ + usleep(100000); +#else + Sleep(100); +#endif + + return 1; +} + IDatabase *SqliteDriver::Connect(DatabaseInfo *info, int *errcode, char *error, size_t maxlength) { sqlite3 *pSql; @@ -38,7 +53,9 @@ IDatabase *SqliteDriver::Connect(DatabaseInfo *info, int *errcode, char *error, sqlite3_close(pSql); return NULL; } else { + sqlite3_busy_handler(pSql, busy_handler, NULL); SqliteDatabase *pDb = new SqliteDatabase(pSql, this); return static_cast(pDb); } } +