@@ -99,7 +99,7 @@ class ExtClientImpl : public ExtClient {
9999 promise = std::move (promise)](td::Result<td::BufferSlice> R) mutable {
100100 if (R.is_error () &&
101101 (R.error ().code () == ton::ErrorCode::timeout || R.error ().code () == ton::ErrorCode::cancelled)) {
102- td::actor::send_closure (SelfId, &ExtClientImpl::on_server_error , server_idx);
102+ td::actor::send_closure (SelfId, &ExtClientImpl::on_server_status , server_idx, false );
103103 }
104104 promise.set_result (std::move (R));
105105 };
@@ -163,9 +163,10 @@ class ExtClientImpl : public ExtClient {
163163 explicit Callback (td::actor::ActorId<ExtClientImpl> parent, size_t idx) : parent_(std::move(parent)), idx_(idx) {
164164 }
165165 void on_ready () override {
166+ td::actor::send_closure (parent_, &ExtClientImpl::on_server_status, idx_, true );
166167 }
167168 void on_stop_ready () override {
168- td::actor::send_closure (parent_, &ExtClientImpl::on_server_error , idx_);
169+ td::actor::send_closure (parent_, &ExtClientImpl::on_server_status , idx_, false );
169170 }
170171
171172 private:
@@ -199,19 +200,32 @@ class ExtClientImpl : public ExtClient {
199200 return ;
200201 }
201202 for (Server& server : servers_) {
202- if (server.timeout && server.timeout .is_in_past ()) {
203+ if (!server.timeout ) {
204+ continue ;
205+ }
206+ if (server.timeout .is_in_past ()) {
203207 LOG (INFO) << " Closing connection to liteserver #" << server.idx << " (" << server.config .addr .get_ip_str ()
204208 << " :" << server.config .addr .get_port () << " )" ;
205209 server.client .reset ();
206210 server.alive = false ;
207211 server.ignore_until = {};
212+ server.timeout = {};
213+ } else {
214+ alarm_timestamp ().relax (server.timeout );
208215 }
209216 }
210217 }
211218
212- void on_server_error (size_t idx) {
213- servers_[idx].alive = false ;
214- servers_[idx].ignore_until = td::Timestamp::in (BAD_SERVER_TIMEOUT);
219+ void on_server_status (size_t idx, bool ok) {
220+ if (ok) {
221+ if (connect_to_all_) {
222+ servers_[idx].alive = true ;
223+ servers_[idx].ignore_until = td::Timestamp::never ();
224+ }
225+ } else {
226+ servers_[idx].alive = false ;
227+ servers_[idx].ignore_until = td::Timestamp::in (BAD_SERVER_TIMEOUT);
228+ }
215229 }
216230};
217231
0 commit comments