Skip to content

Commit 0365ab5

Browse files
authored
feat(sql): Prevent deadlock (#1048)
1 parent 48897e4 commit 0365ab5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

game/addons/sourcemod/scripting/include/sourcebanspp.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#define SB_VERSION_MAJOR "1"
3333
#define SB_VERSION_MINOR "8"
34-
#define SB_VERSION_PATCH "4"
34+
#define SB_VERSION_PATCH "5"
3535

3636
#define SB_VERSION SB_VERSION_MAJOR..."."...SB_VERSION_MINOR..."."...SB_VERSION_PATCH
3737

game/addons/sourcemod/scripting/sbpp_main.sp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2467,11 +2467,19 @@ public void InitializeBackupDB()
24672467

24682468
SQLiteDB = SQLite_UseDatabase("sourcebans-queue", error, sizeof(error));
24692469
if (SQLiteDB == INVALID_HANDLE)
2470+
{
24702471
SetFailState(error);
2472+
}
24712473

2472-
SQL_LockDatabase(SQLiteDB);
2473-
SQL_FastQuery(SQLiteDB, "CREATE TABLE IF NOT EXISTS queue (steam_id TEXT PRIMARY KEY ON CONFLICT REPLACE, time INTEGER, start_time INTEGER, reason TEXT, name TEXT, ip TEXT, admin_id TEXT, admin_ip TEXT);");
2474-
SQL_UnlockDatabase(SQLiteDB);
2474+
SQLiteDB.Query(ErrorCheckCallback,
2475+
"CREATE TABLE IF NOT EXISTS queue ( \
2476+
steam_id TEXT PRIMARY KEY ON CONFLICT REPLACE, \
2477+
time INTEGER, \
2478+
start_time INTEGER, \
2479+
reason TEXT, \
2480+
name TEXT, \
2481+
ip TEXT, \
2482+
admin_id TEXT, admin_ip TEXT);");
24752483
}
24762484

24772485
public bool CreateBan(int client, int target, int time, const char[] reason)

0 commit comments

Comments
 (0)