diff options
author | uzhas <[email protected]> | 2023-08-17 19:25:50 +0300 |
---|---|---|
committer | uzhas <[email protected]> | 2023-08-17 21:34:45 +0300 |
commit | 616db8ee0c6ea55843553ac48612cc9cceb8bd28 (patch) | |
tree | 14b3c06edaa30924bee94419434f185744dae0ad | |
parent | 85afec20cc2bfe25376e941ba6ac691c5d35ca0d (diff) |
fix ta client logic to avoid crash
-rw-r--r-- | ydb/library/yql/providers/common/token_accessor/client/token_accessor_client.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ydb/library/yql/providers/common/token_accessor/client/token_accessor_client.cpp b/ydb/library/yql/providers/common/token_accessor/client/token_accessor_client.cpp index f29acf6fa34..cd5150afa31 100644 --- a/ydb/library/yql/providers/common/token_accessor/client/token_accessor_client.cpp +++ b/ydb/library/yql/providers/common/token_accessor/client/token_accessor_client.cpp @@ -46,8 +46,13 @@ private: RequestInflight = true; auto resultPromise = NThreading::NewPromise(); + auto context = Client->CreateContext(); + if (!context) { + throw yexception() << "Client is being shutted down"; + } std::weak_ptr<const TImpl> weakSelf = shared_from_this(); - auto cb = [weakSelf, resultPromise, sync](NGrpc::TGrpcStatus&& status, GetTokenResponse&& result) mutable { + // hold context until reply + auto cb = [weakSelf, resultPromise, sync, context](NGrpc::TGrpcStatus&& status, GetTokenResponse&& result) mutable { if (auto self = weakSelf.lock()) { self->ProcessResponse(std::move(status), std::move(result), sync); } @@ -66,7 +71,8 @@ private: &TokenAccessorService::Stub::AsyncGetToken, { {}, {}, RequestTimeout - } + }, + context.get() ); } if (sync) { |