diff --git a/td/telegram/net/DcAuthManager.cpp b/td/telegram/net/DcAuthManager.cpp index 43735a861..65112e274 100644 --- a/td/telegram/net/DcAuthManager.cpp +++ b/td/telegram/net/DcAuthManager.cpp @@ -187,13 +187,14 @@ void DcAuthManager::dc_loop(DcInfo &dc) { } } -void DcAuthManager::destroy(Promise<> promise) { +void DcAuthManager::destroy(Promise promise) { + need_destroy_auth_key_ = true; destroy_promise_ = std::move(promise); loop(); } void DcAuthManager::destroy_loop() { - if (!destroy_promise_) { + if (!need_destroy_auth_key_) { return; } bool is_ready{true}; @@ -204,6 +205,7 @@ void DcAuthManager::destroy_loop() { if (is_ready) { VLOG(dc) << "Destroy auth keys loop is ready, all keys are destroyed"; destroy_promise_.set_value(Unit()); + need_destroy_auth_key_ = false; } else { VLOG(dc) << "DC is not ready for destroying auth key"; } diff --git a/td/telegram/net/DcAuthManager.h b/td/telegram/net/DcAuthManager.h index 5d36efab5..328471849 100644 --- a/td/telegram/net/DcAuthManager.h +++ b/td/telegram/net/DcAuthManager.h @@ -53,7 +53,8 @@ class DcAuthManager final : public NetQueryCallback { DcId main_dc_id_; bool need_check_authorization_is_ok_{false}; bool close_flag_{false}; - Promise<> destroy_promise_; + bool need_destroy_auth_key_{false}; + Promise destroy_promise_; DcInfo &get_dc(int32 dc_id); DcInfo *find_dc(int32 dc_id);