File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
ydb/library/yql/providers/dq/provider Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -558,6 +558,7 @@ class TDqGatewayImpl: public std::enable_shared_from_this<TDqGatewayImpl> {
558558 , Service(GrpcClient.CreateGRpcServiceConnection<Yql::DqsProto::DqService>(GrpcConf))
559559 , TaskScheduler()
560560 , OpenSessionTimeout(timeout)
561+ , IsStopped(false )
561562 {
562563 TaskScheduler.Start ();
563564 }
@@ -567,6 +568,11 @@ class TDqGatewayImpl: public std::enable_shared_from_this<TDqGatewayImpl> {
567568 }
568569
569570 void Stop () {
571+ bool expected = false ;
572+ if (!IsStopped.compare_exchange_strong (expected, true )) {
573+ return ;
574+ }
575+
570576 decltype (Sessions) sessions;
571577 with_lock (Mutex) {
572578 sessions = std::move (Sessions);
@@ -729,6 +735,8 @@ class TDqGatewayImpl: public std::enable_shared_from_this<TDqGatewayImpl> {
729735
730736 TMutex Mutex;
731737 THashMap<TString, std::shared_ptr<TDqGatewaySession>> Sessions;
738+
739+ std::atomic<bool > IsStopped;
732740};
733741
734742class TDqGateway : public IDqGateway {
@@ -741,6 +749,7 @@ class TDqGateway: public IDqGateway {
741749 }
742750
743751 ~TDqGateway () {
752+ Stop ();
744753 }
745754
746755 void Stop () override {
You can’t perform that action at this time.
0 commit comments