summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCelina Tala <celinahtala@gmail.com>2022-11-02 21:31:46 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-11-02 22:16:00 +0000
commite39ef953f5836461e8593f9dd77e90b484390a4c (patch)
tree4f23834e3baccaf51debdcff8d8d6171f2ddabbf
parent660a4274bf88a46734619a6606c320da30e868ab (diff)
downloadmongo-e39ef953f5836461e8593f9dd77e90b484390a4c.tar.gz
SERVER-69945 Changed `_timer` in transport_layer_asio to synchronized_value
-rw-r--r--src/mongo/transport/transport_layer_asio.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/mongo/transport/transport_layer_asio.cpp b/src/mongo/transport/transport_layer_asio.cpp
index 9727456429c..f073c9ec79b 100644
--- a/src/mongo/transport/transport_layer_asio.cpp
+++ b/src/mongo/transport/transport_layer_asio.cpp
@@ -133,8 +133,9 @@ SSLConnectionContext::~SSLConnectionContext() = default;
class ASIOReactorTimer final : public ReactorTimer {
public:
+ using TimerType = synchronized_value<asio::system_timer, RawSynchronizedValueMutexPolicy>;
explicit ASIOReactorTimer(asio::io_context& ctx)
- : _timer(std::make_shared<asio::system_timer>(ctx)) {}
+ : _timer(std::make_shared<TimerType>(asio::system_timer(ctx))) {}
~ASIOReactorTimer() {
// The underlying timer won't get destroyed until the last promise from _asyncWait
@@ -150,7 +151,7 @@ public:
}
// Otherwise there could be a previous timer that was scheduled normally.
- _timer->cancel();
+ (**_timer)->cancel();
}
@@ -159,7 +160,7 @@ public:
return _asyncWait([&] { return baton->networking()->waitUntil(*this, expiration); },
baton);
} else {
- return _asyncWait([&] { _timer->expires_at(expiration.toSystemTimePoint()); });
+ return _asyncWait([&] { (**_timer)->expires_at(expiration.toSystemTimePoint()); });
}
}
@@ -170,15 +171,17 @@ private:
cancel();
armTimer();
- return _timer->async_wait(UseFuture{}).tapError([timer = _timer](const Status& status) {
- if (status != ErrorCodes::CallbackCanceled) {
- LOGV2_DEBUG(23011,
- 2,
- "Timer received error: {error}",
- "Timer received error",
- "error"_attr = status);
- }
- });
+ return (**_timer)
+ ->async_wait(UseFuture{})
+ .tapError([timer = _timer](const Status& status) {
+ if (status != ErrorCodes::CallbackCanceled) {
+ LOGV2_DEBUG(23011,
+ 2,
+ "Timer received error: {error}",
+ "Timer received error",
+ "error"_attr = status);
+ }
+ });
} catch (asio::system_error& ex) {
return futurize(ex.code());
@@ -201,7 +204,7 @@ private:
return std::move(pf.future);
}
- std::shared_ptr<asio::system_timer> _timer;
+ std::shared_ptr<TimerType> _timer;
};
class TransportLayerASIO::ASIOReactor final : public Reactor {