diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/apps/worldserver/worldserver.conf.dist | 8 | ||||
-rw-r--r-- | src/server/database/Updater/DBUpdater.cpp | 5 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_go.cpp | 5 |
3 files changed, 14 insertions, 4 deletions
diff --git a/src/server/apps/worldserver/worldserver.conf.dist b/src/server/apps/worldserver/worldserver.conf.dist index 8f54e0dd0e..89863ac4f9 100644 --- a/src/server/apps/worldserver/worldserver.conf.dist +++ b/src/server/apps/worldserver/worldserver.conf.dist @@ -344,6 +344,14 @@ Updates.AllowRehash = 1 Updates.CleanDeadRefMaxCount = 3 # +# Updates.ExceptionShutdownDelay +# Description: Time (in milliseconds) to wait before shutting down after a fatal exception (e.g. failed SQL update). +# Default: 10000 - 10 seconds +# 0 - Disabled (immediate shutdown) + +Updates.ExceptionShutdownDelay = 10000 + +# ################################################################################################### ################################################################################################### diff --git a/src/server/database/Updater/DBUpdater.cpp b/src/server/database/Updater/DBUpdater.cpp index eecce68a12..442b48bcb8 100644 --- a/src/server/database/Updater/DBUpdater.cpp +++ b/src/server/database/Updater/DBUpdater.cpp @@ -518,7 +518,12 @@ void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& hos path.generic_string(), pool.GetConnectionInfo()->database); if (!sConfigMgr->isDryRun()) + { + if (uint32 delay = sConfigMgr->GetOption<uint32>("Updates.ExceptionShutdownDelay", 10000)) + std::this_thread::sleep_for(Milliseconds(delay)); + throw UpdateException("update failed"); + } } } diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp index 0e6bca4220..5f2e5a51d4 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -137,10 +137,7 @@ public: // Make sure we don't pass double quotes into the SQL query. Otherwise it causes a MySQL error std::string str = name.data(); // Making subtractions to the last character does not with in string_view - if (str.front() == '"') - str = str.substr(1); - if (str.back() == '"') - str = str.substr(0, str.size() - 1); + WorldDatabase.EscapeString(str); QueryResult result = WorldDatabase.Query("SELECT entry FROM creature_template WHERE name = \"{}\" LIMIT 1", str); if (!result) |