diff --git a/BSQL.dll b/BSQL.dll index 4e19139307f..861492c8b47 100644 Binary files a/BSQL.dll and b/BSQL.dll differ diff --git a/code/__DEFINES/bsql.dm b/code/__DEFINES/bsql.dm index cd15115c7d4..e5a11f9a32f 100644 --- a/code/__DEFINES/bsql.dm +++ b/code/__DEFINES/bsql.dm @@ -1,10 +1,12 @@ -//BSQL - DMAPI v1.2.0.1 +//BSQL - DMAPI +#define BSQL_VERSION "v1.3.0.0" //types of connections #define BSQL_CONNECTION_TYPE_MARIADB "MySql" #define BSQL_CONNECTION_TYPE_SQLSERVER "SqlServer" #define BSQL_DEFAULT_TIMEOUT 5 +#define BSQL_DEFAULT_THREAD_LIMIT 50 //Call this before rebooting or shutting down your world to clean up gracefully. This invalidates all active connection and operation datums /world/proc/BSQL_Shutdown() @@ -22,8 +24,9 @@ Create a new database connection, does not perform the actual connect connection_type: The BSQL connection_type to use asyncTimeout: The timeout to use for normal operations, 0 for infinite, defaults to BSQL_DEFAULT_TIMEOUT blockingTimeout: The timeout to use for blocking operations, must be less than or equal to asyncTimeout, 0 for infinite, defaults to asyncTimeout + threadLimit: The limit of additional threads BSQL will run simultaneously, defaults to BSQL_DEFAULT_THREAD_LIMIT */ -/datum/BSQL_Connection/New(connection_type, asyncTimeout, blockingTimeout) +/datum/BSQL_Connection/New(connection_type, asyncTimeout, blockingTimeout, threadLimit) return ..() /* diff --git a/code/controllers/configuration/entries/dbconfig.dm b/code/controllers/configuration/entries/dbconfig.dm index 72f190c2f17..b0341952414 100644 --- a/code/controllers/configuration/entries/dbconfig.dm +++ b/code/controllers/configuration/entries/dbconfig.dm @@ -44,4 +44,8 @@ min_val = 0 protection = CONFIG_ENTRY_LOCKED +/datum/config_entry/number/bsql_thread_limit + config_entry_value = 50 + min_val = 1 + /datum/config_entry/flag/bsql_debug diff --git a/code/controllers/subsystem/dbcore.dm b/code/controllers/subsystem/dbcore.dm index b445056e761..6309d46020f 100644 --- a/code/controllers/subsystem/dbcore.dm +++ b/code/controllers/subsystem/dbcore.dm @@ -76,7 +76,7 @@ SUBSYSTEM_DEF(dbcore) var/address = CONFIG_GET(string/address) var/port = CONFIG_GET(number/port) - connection = new /datum/BSQL_Connection(BSQL_CONNECTION_TYPE_MARIADB, CONFIG_GET(number/async_query_timeout), CONFIG_GET(number/blocking_query_timeout)) + connection = new /datum/BSQL_Connection(BSQL_CONNECTION_TYPE_MARIADB, CONFIG_GET(number/async_query_timeout), CONFIG_GET(number/blocking_query_timeout), CONFIG_GET(number/bsql_thread_limit)) var/error if(QDELETED(connection)) connection = null diff --git a/code/modules/bsql/core/connection.dm b/code/modules/bsql/core/connection.dm index 39425578729..692d1333f00 100644 --- a/code/modules/bsql/core/connection.dm +++ b/code/modules/bsql/core/connection.dm @@ -4,17 +4,19 @@ BSQL_PROTECT_DATUM(/datum/BSQL_Connection) -/datum/BSQL_Connection/New(connection_type, asyncTimeout, blockingTimeout) +/datum/BSQL_Connection/New(connection_type, asyncTimeout, blockingTimeout, threadLimit) if(asyncTimeout == null) asyncTimeout = BSQL_DEFAULT_TIMEOUT if(blockingTimeout == null) blockingTimeout = asyncTimeout + if(threadLimit == null) + threadLimit = BSQL_DEFAULT_THREAD_LIMIT src.connection_type = connection_type world._BSQL_InitCheck(src) - var/error = world._BSQL_Internal_Call("CreateConnection", connection_type, "[asyncTimeout]", "[blockingTimeout]") + var/error = world._BSQL_Internal_Call("CreateConnection", connection_type, "[asyncTimeout]", "[blockingTimeout]", "[threadLimit]") if(error) BSQL_ERROR(error) return diff --git a/code/modules/bsql/core/library.dm b/code/modules/bsql/core/library.dm index b8e764a16d9..3325768e01b 100644 --- a/code/modules/bsql/core/library.dm +++ b/code/modules/bsql/core/library.dm @@ -17,6 +17,12 @@ BSQL_ERROR("Could not find [libPath]!") return + var/version = _BSQL_Internal_Call("Version") + if(version != BSQL_VERSION) + BSQL_DEL_CALL(caller) + BSQL_ERROR("BSQL DMAPI version mismatch! Expected [BSQL_VERSION], got [version == null ? "NULL" : version]!") + return + var/result = _BSQL_Internal_Call("Initialize") if(result) BSQL_DEL_CALL(caller) diff --git a/config/dbconfig.txt b/config/dbconfig.txt index 35f599261ef..3a058fe5632 100644 --- a/config/dbconfig.txt +++ b/config/dbconfig.txt @@ -38,5 +38,8 @@ ASYNC_QUERY_TIMEOUT 10 ## Must be less than or equal to ASYNC_QUERY_TIMEOUT BLOCKING_QUERY_TIMEOUT 5 +## The maximum number of additional threads BSQL is allowed to run at once +BSQL_THREAD_LIMIT 50 + ## Uncomment to enable verbose BSQL communication logs #BSQL_DEBUG diff --git a/dependencies.sh b/dependencies.sh index b31ec2fb7ef..7a4cca92e44 100755 --- a/dependencies.sh +++ b/dependencies.sh @@ -13,7 +13,7 @@ export BYOND_MINOR=1441 export RUST_G_VERSION=0.3.0 #bsql git tag -export BSQL_VERSION=v1.3.0.2 +export BSQL_VERSION=v1.4.0.0 #node version export NODE_VERSION=4