From 612b897f5e31c64a168c8e6f9c9100fe6e1c3cea Mon Sep 17 00:00:00 2001 From: Rushaway Date: Thu, 27 Aug 2026 08:09:33 +0200 Subject: [PATCH 1/3] fix(db): drop blocking SQLite fallback connect in Connect_DB() Connect_DB() fell back to a synchronous SQLite_UseDatabase() (SQL_ConnectCustom()) connect whenever no "vip_test" entry existed in databases.cfg, blocking the game thread on every (re)connect in that configuration. SQL_TConnect() already falls back to an implicit local SQLite database for an unrecognized config name, so a single async call now covers both the MySQL and SQLite cases. Bumped plugin version to 1.0.9. --- addons/sourcemod/scripting/VIP_Test.sp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/addons/sourcemod/scripting/VIP_Test.sp b/addons/sourcemod/scripting/VIP_Test.sp index efda982..98f02d5 100644 --- a/addons/sourcemod/scripting/VIP_Test.sp +++ b/addons/sourcemod/scripting/VIP_Test.sp @@ -50,7 +50,7 @@ public Plugin myinfo = name = "[VIP] Test", author = "Loneypro", description = "Players can test vip features for a set of time", - version = "1.0.8", + version = "1.0.9", url = "" }; @@ -102,17 +102,10 @@ public void OnTestGroupChange(ConVar hCvar, const char[] oldVal, const char[] ne stock void Connect_DB() { - if (SQL_CheckConfig("vip_test")) - { - SQL_TConnect(DB_OnConnect, "vip_test", 1); - } - else - { - char sError[256]; - sError[0] = '\0'; - g_hDatabase = SQLite_UseDatabase("vip_test", sError, sizeof(sError)); - DB_OnConnect(g_hDatabase, g_hDatabase, sError, 2); - } + // SQL_TConnect() implicitly falls back to a local SQLite database named + // "vip_test" when no matching entry exists in databases.cfg, so this + // single async call covers both the MySQL and SQLite cases. + SQL_TConnect(DB_OnConnect, "vip_test", 1); } stock void DB_OnConnect(Handle owner, Handle hndl, const char[] sError, any data) From 4702511736743a5763fc610b890c882a9dfde55a Mon Sep 17 00:00:00 2001 From: Rushaway Date: Thu, 27 Aug 2026 08:16:01 +0200 Subject: [PATCH 2/3] fix(db): use Database.Connect() instead of legacy SQL_TConnect() SQL_TConnect() is non-blocking, but it's the legacy Handle-based connect API. Standardize on the newer Database.Connect() methodmap so the connect path isn't mixing the old SQLTCallback style with the modern Database/ SQLConnectCallback style. Also drops the now-dead data==1/2 branch in DB_OnConnect() that only existed to distinguish the removed sync fallback from the async connect. --- addons/sourcemod/scripting/VIP_Test.sp | 28 +++++++++----------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/addons/sourcemod/scripting/VIP_Test.sp b/addons/sourcemod/scripting/VIP_Test.sp index 98f02d5..aed6324 100644 --- a/addons/sourcemod/scripting/VIP_Test.sp +++ b/addons/sourcemod/scripting/VIP_Test.sp @@ -102,34 +102,24 @@ public void OnTestGroupChange(ConVar hCvar, const char[] oldVal, const char[] ne stock void Connect_DB() { - // SQL_TConnect() implicitly falls back to a local SQLite database named - // "vip_test" when no matching entry exists in databases.cfg, so this - // single async call covers both the MySQL and SQLite cases. - SQL_TConnect(DB_OnConnect, "vip_test", 1); + // Database.Connect() implicitly falls back to a local SQLite database + // named "vip_test" when no matching entry exists in databases.cfg, so + // this single async call covers both the MySQL and SQLite cases. + Database.Connect(DB_OnConnect, "vip_test"); } -stock void DB_OnConnect(Handle owner, Handle hndl, const char[] sError, any data) +public void DB_OnConnect(Database db, const char[] sError, any data) { - g_hDatabase = hndl; - - if (g_hDatabase == INVALID_HANDLE || sError[0]) + g_hDatabase = db; + + if (g_hDatabase == null || sError[0]) { SetFailState("DB Connect %s", sError); return; } char sDriver[16]; - switch (data) - { - case 1 : - { - SQL_GetDriverIdent(owner, sDriver, sizeof(sDriver)); - } - default : - { - SQL_ReadDriver(owner, sDriver, sizeof(sDriver)); - } - } + db.Driver.GetIdentifier(sDriver, sizeof(sDriver)); g_bDBMySQL = (strcmp(sDriver, "mysql", false) == 0); From f2222ff015ab2ffb82fdb1e1c6864985f56f8f9f Mon Sep 17 00:00:00 2001 From: Rushaway Date: Thu, 27 Aug 2026 15:34:36 +0200 Subject: [PATCH 3/3] Simplify database connection logic to use async connect --- addons/sourcemod/scripting/VIP_Test.sp | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/sourcemod/scripting/VIP_Test.sp b/addons/sourcemod/scripting/VIP_Test.sp index aed6324..869a394 100644 --- a/addons/sourcemod/scripting/VIP_Test.sp +++ b/addons/sourcemod/scripting/VIP_Test.sp @@ -35,6 +35,7 @@ Fix FI translation. 1.0.7 - Upgrade to utf8mb4 1.0.8 - No need to lock/unlock database - All queries are asynchronous. + 1.0.9 - Simplify connect db logic - Use async connect. */ #pragma semicolon 1 #pragma newdecls required