Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add check future object valid before wait on it #1986

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/common/http/AsynCurlRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ bool AsynCurlRunner::Init() {
void AsynCurlRunner::Stop() {
mIsFlush = true;
future_status s = mThreadRes.wait_for(chrono::seconds(1));
if (!mThreadRes.valid()) {
return;
}
if (s == future_status::ready) {
LOG_INFO(sLogger, ("async curl runner", "stopped successfully"));
} else {
Expand Down
3 changes: 3 additions & 0 deletions core/common/timer/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ void Timer::Stop() {
mIsThreadRunning = false;
}
mCV.notify_one();
if (!mThreadRes.valid()) {
return;
}
future_status s = mThreadRes.wait_for(chrono::seconds(1));
if (s == future_status::ready) {
LOG_INFO(sLogger, ("timer", "stopped successfully"));
Expand Down
3 changes: 3 additions & 0 deletions core/monitor/SelfMonitorServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ void SelfMonitorServer::Stop() {
mIsThreadRunning = false;
}
mStopCV.notify_one();
if (!mThreadRes.valid()) {
return;
}
future_status s = mThreadRes.wait_for(chrono::seconds(1));
if (s == future_status::ready) {
LOG_INFO(sLogger, ("self-monitor", "stopped successfully"));
Expand Down
6 changes: 3 additions & 3 deletions core/unittest/polling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ project(polling_unittest)
# add_executable(polling_unittest PollingUnittest.cpp)
# target_link_libraries(polling_unittest ${UT_BASE_TARGET})

# add_executable(polling_preserved_dir_depth_unittest PollingPreservedDirDepthUnittest.cpp)
# target_link_libraries(polling_preserved_dir_depth_unittest ${UT_BASE_TARGET})
add_executable(polling_preserved_dir_depth_unittest PollingPreservedDirDepthUnittest.cpp)
target_link_libraries(polling_preserved_dir_depth_unittest ${UT_BASE_TARGET})

include(GoogleTest)
# gtest_discover_tests(polling_preserved_dir_depth_unittest)
gtest_discover_tests(polling_preserved_dir_depth_unittest)
Loading