Don't use promise emptiness to check that auth keys are being destroyed.

This commit is contained in:
levlam 2023-10-23 14:12:25 +03:00
parent 66757e2511
commit 9fdc48ac2d
2 changed files with 6 additions and 3 deletions

View File

@ -187,13 +187,14 @@ void DcAuthManager::dc_loop(DcInfo &dc) {
}
}
void DcAuthManager::destroy(Promise<> promise) {
void DcAuthManager::destroy(Promise<Unit> 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";
}

View File

@ -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<Unit> destroy_promise_;
DcInfo &get_dc(int32 dc_id);
DcInfo *find_dc(int32 dc_id);