diff --git a/td/mtproto/HandshakeActor.h b/td/mtproto/HandshakeActor.h index 296dae62c..930d3c8c9 100644 --- a/td/mtproto/HandshakeActor.h +++ b/td/mtproto/HandshakeActor.h @@ -39,6 +39,10 @@ class HandshakeActor : public Actor { void tear_down() override { finish(Status::OK()); } + void hangup() override { + finish(Status::Error(1, "Cancelled")); + stop(); + } void timeout_expired() override { finish(Status::Error("Timeout expired")); stop(); diff --git a/td/telegram/net/Session.cpp b/td/telegram/net/Session.cpp index 93963a4ce..4fb4c7682 100644 --- a/td/telegram/net/Session.cpp +++ b/td/telegram/net/Session.cpp @@ -78,6 +78,15 @@ class GenAuthKeyActor : public Actor { })); } + void hangup() override { + if (connection_promise_) { + connection_promise_.set_error(Status::Error(1, "Cancelled")); + } + if (handshake_promise_) { + handshake_promise_.set_error(Status::Error(1, "Cancelled")); + } + } + void on_connection(Result> r_raw_connection, bool dummy) { if (r_raw_connection.is_error()) { connection_promise_.set_error(r_raw_connection.move_as_error()); @@ -1082,8 +1091,8 @@ void Session::create_gen_auth_key_actor(HandshakeId handshake_id) { "GenAuthKey", std::move(info.handshake_), std::make_unique(DhCache::instance(), shared_auth_data_->public_rsa_key()), PromiseCreator::lambda([self = actor_id(this)](Result> r_connection) { - if (r_connection.is_error() && r_connection.error().code() != 1) { - LOG(WARNING) << r_connection.error(); + if (r_connection.is_error()) { + LOG_IF(WARNING, r_connection.error().code() != 1) << r_connection.error(); return; } send_closure(self, &Session::connection_add, r_connection.move_as_ok());