fix:[2.6] avoid potential race conditions when updating the executor (#45232)

issue: #43040 
pr: #45230

Signed-off-by: Shawn Wang <shawn.wang@zilliz.com>
This commit is contained in:
sparknack 2025-11-04 16:11:33 +08:00 committed by GitHub
parent f21d7ce05b
commit efaa538238
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -359,15 +359,16 @@ class FileWriteWorkerPool {
bool
AddTask(std::function<void()> task) {
std::lock_guard<std::mutex> lock(executor_mutex_);
if (executor_ == nullptr) {
return false;
}
std::lock_guard<std::mutex> lock(executor_mutex_);
executor_->add(std::move(task));
return true;
}
~FileWriteWorkerPool() {
std::lock_guard<std::mutex> lock(executor_mutex_);
if (executor_ != nullptr) {
executor_->stop();
executor_->join();