fix for amb253 - database now spinlocks instead of failing to lock
This commit is contained in:
parent
21ad8ba71b
commit
fcdd17480c
@ -7,6 +7,10 @@
|
|||||||
#if defined WIN32
|
#if defined WIN32
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#define strncasecmp strnicmp
|
#define strncasecmp strnicmp
|
||||||
|
#define WINDOWS_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
@ -21,6 +25,17 @@ const char *SqliteDriver::NameString()
|
|||||||
return "sqlite";
|
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)
|
IDatabase *SqliteDriver::Connect(DatabaseInfo *info, int *errcode, char *error, size_t maxlength)
|
||||||
{
|
{
|
||||||
sqlite3 *pSql;
|
sqlite3 *pSql;
|
||||||
@ -38,7 +53,9 @@ IDatabase *SqliteDriver::Connect(DatabaseInfo *info, int *errcode, char *error,
|
|||||||
sqlite3_close(pSql);
|
sqlite3_close(pSql);
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
|
sqlite3_busy_handler(pSql, busy_handler, NULL);
|
||||||
SqliteDatabase *pDb = new SqliteDatabase(pSql, this);
|
SqliteDatabase *pDb = new SqliteDatabase(pSql, this);
|
||||||
return static_cast<IDatabase *>(pDb);
|
return static_cast<IDatabase *>(pDb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user