@@ -106,26 +106,30 @@ void ClientImpl::start() {
106106 name_server_resolver_->start ();
107107
108108 client_config_.client_id = clientId ();
109-
110109 if (!client_manager_) {
111- client_manager_ = std::make_shared<ClientManagerImpl>(client_config_.resource_namespace , client_config_.withSsl );
110+ client_manager_ = std::make_shared<ClientManagerImpl>(
111+ client_config_.resource_namespace , client_config_.withSsl );
112+ client_manager_->start ();
112113 }
113- client_manager_->start ();
114114
115115 const auto & endpoint = name_server_resolver_->resolve ();
116116 if (endpoint.empty ()) {
117117 SPDLOG_ERROR (" Failed to resolve name server address" );
118- abort () ;
118+ return ;
119119 }
120120
121- createSession (endpoint, false );
122- {
123- absl::MutexLock lk (&session_map_mtx_);
124- session_map_[endpoint]->await ();
121+ while (true ) {
122+ createSession (endpoint, false );
123+ {
124+ absl::MutexLock lk (&session_map_mtx_);
125+ if (session_map_.contains (endpoint) && session_map_[endpoint]->await ()) {
126+ break ;
127+ }
128+ session_map_.erase (endpoint);
129+ }
125130 }
126131
127132 std::weak_ptr<ClientImpl> ptr (self ());
128-
129133 {
130134 // Query routes for topics of interest in synchronous
131135 std::vector<std::string> topics;
@@ -164,8 +168,9 @@ void ClientImpl::start() {
164168 }
165169 };
166170
167- route_update_handle_ = client_manager_->getScheduler ()->schedule (route_update_functor, UPDATE_ROUTE_TASK_NAME,
168- std::chrono::seconds (10 ), std::chrono::seconds (30 ));
171+ route_update_handle_ = client_manager_->getScheduler ()->schedule (
172+ route_update_functor, UPDATE_ROUTE_TASK_NAME,
173+ std::chrono::seconds (10 ), std::chrono::seconds (30 ));
169174
170175 auto telemetry_functor = [ptr]() {
171176 std::shared_ptr<ClientImpl> base = ptr.lock ();
@@ -597,8 +602,11 @@ void ClientImpl::notifyClientTermination(const NotifyClientTerminationRequest& r
597602 Signature::sign (client_config_, metadata);
598603
599604 for (const auto & endpoint : endpoints) {
600- client_manager_->notifyClientTermination (endpoint, metadata, request,
601- absl::ToChronoMilliseconds (client_config_.request_timeout ));
605+ std::error_code ec = client_manager_->notifyClientTermination (
606+ endpoint, metadata, request,absl::ToChronoMilliseconds (client_config_.request_timeout ));
607+ if (ec) {
608+ SPDLOG_WARN (" Notify client termination error, ErrorCode={}, Endpoint={}" , ec.message (), endpoint);
609+ }
602610 }
603611}
604612
0 commit comments