@@ -453,18 +453,18 @@ void TWriteSessionImpl::DoConnect(const TDuration& delay, const std::string& end
453
453
}
454
454
++ConnectionGeneration;
455
455
auto subclient = Client->GetClientForEndpoint (endpoint);
456
- connectionFactory = subclient->CreateWriteSessionConnectionProcessorFactory ();
457
456
auto clientContext = subclient->CreateContext ();
458
- ConnectionFactory = connectionFactory;
459
-
460
- ClientContext = std::move (clientContext);
461
- ServerMessage = std::make_shared<TServerMessage>();
462
-
463
- if (!ClientContext) {
457
+ if (!clientContext) {
464
458
AbortImpl ();
465
459
// Grpc and WriteSession is closing right now.
466
460
return ;
467
461
}
462
+ auto prevClientContext = std::exchange (ClientContext, clientContext);
463
+
464
+ ServerMessage = std::make_shared<TServerMessage>();
465
+
466
+ connectionFactory = subclient->CreateWriteSessionConnectionProcessorFactory ();
467
+ ConnectionFactory = connectionFactory;
468
468
469
469
connectContext = ClientContext->CreateContext ();
470
470
if (delay)
@@ -485,8 +485,10 @@ void TWriteSessionImpl::DoConnect(const TDuration& delay, const std::string& end
485
485
if (prevConnectDelayContext)
486
486
Cancel (prevConnectDelayContext);
487
487
Cancel (prevConnectTimeoutContext);
488
+ Cancel (prevClientContext);
488
489
Y_ASSERT (connectContext);
489
490
Y_ASSERT (connectTimeoutContext);
491
+
490
492
reqSettings = TRpcRequestSettings::Make (Settings);
491
493
492
494
connectCallback = [cbContext = SelfContext,
0 commit comments