mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 15:40:45 +01:00
Core/Database: Fixed worldserver hanging if opening a connection to database failed
This commit is contained in:
@@ -149,14 +149,17 @@ uint32 DatabaseWorkerPool<T>::Open()
|
||||
|
||||
error = OpenConnections(IDX_SYNCH, _synch_threads);
|
||||
|
||||
if (!error)
|
||||
{
|
||||
TC_LOG_INFO("sql.driver", "DatabasePool '{}' opened successfully. "
|
||||
"{} total connections running.", GetDatabaseName(),
|
||||
(_connections[IDX_SYNCH].size() + _connections[IDX_ASYNC].size()));
|
||||
}
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
return error;
|
||||
for (std::unique_ptr<T> const& connection : _connections[IDX_ASYNC])
|
||||
connection->StartWorkerThread(_ioContext.get());
|
||||
|
||||
TC_LOG_INFO("sql.driver", "DatabasePool '{}' opened successfully. "
|
||||
"{} total connections running.", GetDatabaseName(),
|
||||
(_connections[IDX_SYNCH].size() + _connections[IDX_ASYNC].size()));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -428,21 +431,9 @@ uint32 DatabaseWorkerPool<T>::OpenConnections(InternalIndex type, uint8 numConne
|
||||
for (uint8 i = 0; i < numConnections; ++i)
|
||||
{
|
||||
// Create the connection
|
||||
auto connection = [&] {
|
||||
switch (type)
|
||||
{
|
||||
case IDX_ASYNC:
|
||||
{
|
||||
auto c = std::make_unique<T>(*_connectionInfo, CONNECTION_ASYNC);
|
||||
c->StartWorkerThread(_ioContext.get());
|
||||
return c;
|
||||
}
|
||||
case IDX_SYNCH:
|
||||
return std::make_unique<T>(*_connectionInfo, CONNECTION_SYNCH);
|
||||
default:
|
||||
ABORT();
|
||||
}
|
||||
}();
|
||||
constexpr std::array<ConnectionFlags, IDX_SIZE> flags = { { CONNECTION_ASYNC, CONNECTION_SYNCH } };
|
||||
|
||||
std::unique_ptr<T> connection = std::make_unique<T>(*_connectionInfo, flags[type]);
|
||||
|
||||
if (uint32 error = connection->Open())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user