Skip to content

Commit c84a49e

Browse files
committed
Fix newly added tsan issue
1 parent 9b72769 commit c84a49e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/cluster/impl/RepeatedTask.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include <boost/asio/spawn.hpp>
3131
#include <boost/asio/steady_timer.hpp>
3232
#include <boost/asio/strand.hpp>
33-
#include <boost/asio/use_future.hpp>
3433

3534
#include <atomic>
3635
#include <chrono>
@@ -96,7 +95,12 @@ class RepeatedTask {
9695
if (auto expected = State::Running; not state_.compare_exchange_strong(expected, State::Stopped))
9796
return; // Already stopped or not started
9897

99-
boost::asio::spawn(strand_, [this](auto&&) { timer_.cancel(); }, boost::asio::use_future).wait();
98+
std::binary_semaphore cancelSemaphore{0};
99+
boost::asio::post(strand_, [this, &cancelSemaphore]() {
100+
timer_.cancel();
101+
cancelSemaphore.release();
102+
});
103+
cancelSemaphore.acquire();
100104
semaphore_.acquire();
101105
}
102106
};

0 commit comments

Comments
 (0)