Skip to content

feat(sql): Prevent deadlock #1048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: php81
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion game/addons/sourcemod/scripting/include/sourcebanspp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#define SB_VERSION_MAJOR "1"
#define SB_VERSION_MINOR "8"
#define SB_VERSION_PATCH "4"
#define SB_VERSION_PATCH "5"

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

Expand Down
14 changes: 11 additions & 3 deletions game/addons/sourcemod/scripting/sbpp_main.sp
Original file line number Diff line number Diff line change
Expand Up @@ -2467,11 +2467,19 @@ public void InitializeBackupDB()

SQLiteDB = SQLite_UseDatabase("sourcebans-queue", error, sizeof(error));
if (SQLiteDB == INVALID_HANDLE)
{
SetFailState(error);
}

SQL_LockDatabase(SQLiteDB);
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);");
SQL_UnlockDatabase(SQLiteDB);
SQLiteDB.Query(ErrorCheckCallback,
"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);");
}

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