Keep reference to Td in TdDb::open to ensure that it isn't closed completely in the meanwhile.

This commit is contained in:
levlam 2024-02-15 19:45:27 +03:00
parent 6707463e85
commit e12b13bbb0
1 changed files with 5 additions and 4 deletions

View File

@ -2965,10 +2965,11 @@ void Td::run_request(uint64 id, tl_object_ptr<td_api::Function> function) {
!parameters.second.use_message_database_ &&
!parameters.first.use_secret_chats_;
auto promise = PromiseCreator::lambda([actor_id = actor_id(this), parameters = std::move(parameters.first)](
Result<TdDb::OpenedDatabase> r_opened_database) mutable {
send_closure(actor_id, &Td::init, std::move(parameters), std::move(r_opened_database));
});
auto promise = PromiseCreator::lambda(
[actor_id = actor_id(this), parameters = std::move(parameters.first),
parent = create_reference()](Result<TdDb::OpenedDatabase> r_opened_database) mutable {
send_closure(actor_id, &Td::init, std::move(parameters), std::move(r_opened_database));
});
auto use_sqlite_pmc = parameters.second.use_message_database_ || parameters.second.use_chat_info_database_ ||
parameters.second.use_file_database_;
return TdDb::open(use_sqlite_pmc ? G()->get_database_scheduler_id() : G()->get_slow_net_scheduler_id(),