aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbabenko <babenko@yandex-team.com>2024-09-10 09:18:42 +0300
committerbabenko <babenko@yandex-team.com>2024-09-10 09:30:57 +0300
commit3129b5d3576b7d2eacd46bb11e49d0b33f2f433b (patch)
tree5d2e319ebf17ec10a33a60f6278a681f86cabaf7
parentb01a836f3b5720897241587572ecae5f60dfc74e (diff)
downloadydb-3129b5d3576b7d2eacd46bb11e49d0b33f2f433b.tar.gz
YT-22846: Fix vptr race in TRoamingRequestControl
09883f9b14b10cfd69e95d7afb810a49aa054682
-rw-r--r--yt/yt/core/rpc/roaming_channel.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/yt/yt/core/rpc/roaming_channel.cpp b/yt/yt/core/rpc/roaming_channel.cpp
index 93717ea4f1..d79ee7e35a 100644
--- a/yt/yt/core/rpc/roaming_channel.cpp
+++ b/yt/yt/core/rpc/roaming_channel.cpp
@@ -17,18 +17,19 @@ class TRoamingRequestControl
{
public:
TRoamingRequestControl(
- TFuture<IChannelPtr> asyncChannel,
IClientRequestPtr request,
IClientResponseHandlerPtr responseHandler,
const TSendOptions& options)
: Request_(std::move(request))
, ResponseHandler_(std::move(responseHandler))
, Options_(options)
- , StartTime_(TInstant::Now())
+ { }
+
+ void Initialize(TFuture<IChannelPtr> asyncChannel)
{
if (Options_.Timeout) {
asyncChannel = asyncChannel.WithTimeout(*Options_.Timeout, TFutureTimeoutOptions{
- .Error = TError("Error getting channel")
+ .Error = TError("Error getting channel"),
});
}
@@ -56,7 +57,7 @@ private:
IClientRequestPtr Request_;
IClientResponseHandlerPtr ResponseHandler_;
const TSendOptions Options_;
- const TInstant StartTime_;
+ const TInstant StartTime_ = TInstant::Now();
std::atomic<bool> Semaphore_ = false;
@@ -160,11 +161,12 @@ public:
}
}
- return New<TRoamingRequestControl>(
- std::move(asyncChannel),
+ auto control = New<TRoamingRequestControl>(
std::move(request),
std::move(responseHandler),
options);
+ control->Initialize(std::move(asyncChannel));
+ return control;
}
void Terminate(const TError& error) override