mirror of
https://gitcode.com/GitHub_Trending/az/azerothcore-wotlk.git
synced 2026-10-10 07:06:38 +08:00
fix(Core/Database): allow reopening a DatabaseWorkerPool after a failed Open() (#27585)
This commit is contained in:
@@ -102,6 +102,15 @@ public:
|
||||
_condition.notify_all();
|
||||
}
|
||||
|
||||
// Reopens the queue after Cancel()/Shutdown() so new consumers can be attached.
|
||||
// Callers must make sure the previous consumers have already stopped.
|
||||
void Reset()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_queueLock);
|
||||
_cancel = false;
|
||||
_shutdown = false;
|
||||
}
|
||||
|
||||
private:
|
||||
template<typename E = T>
|
||||
typename std::enable_if<std::is_pointer<E>::value>::type DeleteQueuedObject(E& obj)
|
||||
|
||||
@@ -91,6 +91,11 @@ uint32 DatabaseWorkerPool<T>::Open()
|
||||
LOG_INFO("sql.driver", "Opening DatabasePool '{}'. Asynchronous connections: {}, synchronous connections: {}.",
|
||||
GetDatabaseName(), _async_threads, _synch_threads);
|
||||
|
||||
_queue->Cancel();
|
||||
_connections[IDX_ASYNC].clear();
|
||||
_connections[IDX_SYNCH].clear();
|
||||
_queue->Reset();
|
||||
|
||||
uint32 error = OpenConnections(IDX_ASYNC, _async_threads);
|
||||
|
||||
if (error)
|
||||
|
||||
Reference in New Issue
Block a user