Bugfixes
This commit is contained in:
parent
801f14fa9c
commit
a84a9f472d
@ -145,10 +145,9 @@ AnimationsManager::AnimationsManager(Td *td, ActorShared<> parent) : td_(td), pa
|
||||
}
|
||||
|
||||
void AnimationsManager::tear_down() {
|
||||
parent_.reset();
|
||||
// Completely clear memory when closing, to avoid memory leaks
|
||||
memory_cleanup(true);
|
||||
|
||||
parent_.reset();
|
||||
}
|
||||
|
||||
int32 AnimationsManager::get_animation_duration(FileId file_id) const {
|
||||
|
@ -2952,9 +2952,9 @@ ContactsManager::ContactsManager(Td *td, ActorShared<> parent) : td_(td), parent
|
||||
}
|
||||
|
||||
void ContactsManager::tear_down() {
|
||||
parent_.reset();
|
||||
// Completely clear memory when closing, to avoid memory leaks
|
||||
memory_cleanup(true);
|
||||
parent_.reset();
|
||||
}
|
||||
|
||||
UserId ContactsManager::load_my_id() {
|
||||
@ -14689,9 +14689,9 @@ void ContactsManager::memory_cleanup() {
|
||||
void ContactsManager::memory_cleanup(bool full) {
|
||||
auto time = std::time(nullptr);
|
||||
|
||||
auto user_ttl = !G()->shared_config().get_option_integer("delete_user_reference_after_seconds", 3600);
|
||||
auto chat_ttl = !G()->shared_config().get_option_integer("delete_chat_reference_after_seconds", 3600);
|
||||
auto chat_access_hash_cleanup = !G()->shared_config().get_option_boolean("experiment_enable_chat_access_hash_cleanup", true);
|
||||
auto user_ttl = full ? 0 : !G()->shared_config().get_option_integer("delete_user_reference_after_seconds", 3600);
|
||||
auto chat_ttl = full ? 0 : !G()->shared_config().get_option_integer("delete_chat_reference_after_seconds", 3600);
|
||||
auto chat_access_hash_cleanup = full ? true : !G()->shared_config().get_option_boolean("experiment_enable_chat_access_hash_cleanup", true);
|
||||
|
||||
/* DESTROY INVALID USERS */
|
||||
if (full) {
|
||||
|
@ -466,9 +466,9 @@ GroupCallManager::GroupCallManager(Td *td, ActorShared<> parent) : td_(td), pare
|
||||
GroupCallManager::~GroupCallManager() = default;
|
||||
|
||||
void GroupCallManager::tear_down() {
|
||||
parent_.reset();
|
||||
// Completely clear memory when closing, to avoid memory leaks
|
||||
memory_cleanup(true);
|
||||
parent_.reset();
|
||||
}
|
||||
|
||||
void GroupCallManager::memory_cleanup() {
|
||||
|
@ -165,9 +165,9 @@ InlineQueriesManager::InlineQueriesManager(Td *td, ActorShared<> parent) : td_(t
|
||||
}
|
||||
|
||||
void InlineQueriesManager::tear_down() {
|
||||
parent_.reset();
|
||||
// Completely clear memory when closing, to avoid memory leaks
|
||||
memory_cleanup(true);
|
||||
parent_.reset();
|
||||
}
|
||||
|
||||
void InlineQueriesManager::on_drop_inline_query_result_timeout_callback(void *inline_queries_manager_ptr,
|
||||
|
@ -5929,7 +5929,10 @@ void MessagesManager::memory_cleanup() {
|
||||
|
||||
void MessagesManager::memory_cleanup(bool full) {
|
||||
/* CLEAR DELETED MESSAGES CACHE */
|
||||
{
|
||||
if (full) {
|
||||
dialogs_.clear();
|
||||
dialogs_.rehash(0);
|
||||
} else {
|
||||
auto it = dialogs_.begin();
|
||||
while (it != dialogs_.end()) {
|
||||
auto &dialog = it->second;
|
||||
@ -5942,16 +5945,18 @@ void MessagesManager::memory_cleanup(bool full) {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
clear_recently_found_dialogs();
|
||||
if (full) {
|
||||
recently_found_dialogs_loaded_ = 2;
|
||||
recently_found_dialog_ids_.clear();
|
||||
} else {
|
||||
clear_recently_found_dialogs();
|
||||
}
|
||||
found_public_dialogs_.clear();
|
||||
found_public_dialogs_.rehash(0);
|
||||
found_on_server_dialogs_.clear();
|
||||
found_on_server_dialogs_.rehash(0);
|
||||
full_message_id_to_file_source_id_.clear();
|
||||
full_message_id_to_file_source_id_.rehash(0);
|
||||
if (full) {
|
||||
dialogs_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesManager::memory_stats(vector<string> &output) {
|
||||
@ -11994,9 +11999,9 @@ class MessagesManager::DialogFiltersLogEvent {
|
||||
};
|
||||
|
||||
void MessagesManager::tear_down() {
|
||||
parent_.reset();
|
||||
// Completely clear memory when closing, to avoid memory leaks
|
||||
memory_cleanup(true);
|
||||
parent_.reset();
|
||||
}
|
||||
|
||||
void MessagesManager::start_up() {
|
||||
|
@ -265,6 +265,8 @@ void PollManager::start_up() {
|
||||
|
||||
void PollManager::tear_down() {
|
||||
parent_.reset();
|
||||
// Completely clear memory when closing, to avoid memory leaks
|
||||
memory_cleanup(true);
|
||||
}
|
||||
|
||||
PollManager::~PollManager() = default;
|
||||
@ -496,6 +498,7 @@ vector<int32> PollManager::get_vote_percentage(const vector<int32> &voter_counts
|
||||
td_api::object_ptr<td_api::poll> PollManager::get_poll_object(PollId poll_id) const {
|
||||
auto poll = get_poll(poll_id);
|
||||
if (!(poll != nullptr)) {
|
||||
//todo: find better alternative, rather than just creating a fake poll to avoid crashes...
|
||||
vector<td_api::object_ptr<td_api::pollOption>> poll_options;
|
||||
poll_options.push_back(td_api::make_object<td_api::pollOption>(
|
||||
"empty", 0, 0, false,
|
||||
@ -1711,8 +1714,6 @@ void PollManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
}
|
||||
|
||||
void PollManager::memory_cleanup() {
|
||||
// Completely clear memory when closing, to avoid memory leaks
|
||||
memory_cleanup(true);
|
||||
memory_cleanup(false);
|
||||
}
|
||||
|
||||
|
@ -1320,9 +1320,9 @@ void StickersManager::on_load_special_sticker_set(const SpecialStickerSetType &t
|
||||
}
|
||||
|
||||
void StickersManager::tear_down() {
|
||||
parent_.reset();
|
||||
// Completely clear memory when closing, to avoid memory leaks
|
||||
memory_cleanup();
|
||||
parent_.reset();
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::MaskPoint> StickersManager::get_mask_point_object(int32 point) {
|
||||
|
@ -405,9 +405,9 @@ WebPagesManager::WebPagesManager(Td *td, ActorShared<> parent) : td_(td), parent
|
||||
}
|
||||
|
||||
void WebPagesManager::tear_down() {
|
||||
parent_.reset();
|
||||
// Completely clear memory when closing, to avoid memory leaks
|
||||
memory_cleanup();
|
||||
parent_.reset();
|
||||
}
|
||||
|
||||
WebPagesManager::~WebPagesManager() = default;
|
||||
|
@ -3799,11 +3799,13 @@ void FileManager::memory_cleanup() {
|
||||
}
|
||||
|
||||
void FileManager::memory_cleanup(bool full) {
|
||||
LOG(ERROR) << "Initial registered ids: " << file_id_info_.size() << " registered nodes: " << file_nodes_.size();
|
||||
if (!full) {
|
||||
LOG(INFO) << "Initial registered ids: " << file_id_info_.size() << " registered nodes: " << file_nodes_.size();
|
||||
}
|
||||
|
||||
std::unordered_set<int32> file_to_be_deleted = {};
|
||||
|
||||
auto file_ttl = !G()->shared_config().get_option_integer("delete_file_reference_after_seconds", 30);
|
||||
auto file_ttl = full ? 0 : !G()->shared_config().get_option_integer("delete_file_reference_after_seconds", 30);
|
||||
|
||||
/* DESTROY OLD file_id_info_ */
|
||||
if (full) {
|
||||
@ -3837,10 +3839,10 @@ void FileManager::memory_cleanup(bool full) {
|
||||
}
|
||||
|
||||
if (can_reset) {
|
||||
node->main_file_id_.reset_time(); // delete last access time of FileId
|
||||
node->main_file_id_.reset_time(); // delete last access time of FileId
|
||||
|
||||
for (auto &file_id : node->file_ids_) {
|
||||
file_id.reset_time(); // delete last access time of FileId
|
||||
file_id.reset_time(); // delete last access time of FileId
|
||||
|
||||
/* DESTROY ASSOCIATED QUERIES */
|
||||
destroy_query(file_id.get());
|
||||
@ -4090,13 +4092,19 @@ void FileManager::memory_cleanup(bool full) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!full) {
|
||||
if (full) {
|
||||
file_nodes_.rehash(0);
|
||||
file_hash_to_file_id_.rehash(0);
|
||||
file_id_info_.rehash(0);
|
||||
} else {
|
||||
file_nodes_.rehash(file_nodes_.size() + 1);
|
||||
file_hash_to_file_id_.rehash(file_hash_to_file_id_.size() + 1);
|
||||
file_id_info_.rehash(file_id_info_.size() + 1);
|
||||
}
|
||||
|
||||
LOG(ERROR) << "Final registered ids: " << file_id_info_.size() << " registered nodes: " << file_nodes_.size();
|
||||
if (!full) {
|
||||
LOG(INFO) << "Final registered ids: " << file_id_info_.size() << " registered nodes: " << file_nodes_.size();
|
||||
}
|
||||
}
|
||||
void FileManager::memory_stats(vector<string> &output) {
|
||||
output.push_back("\"file_id_info_\":"); output.push_back(std::to_string(file_id_info_.size()));
|
||||
@ -4111,8 +4119,8 @@ void FileManager::memory_stats(vector<string> &output) {
|
||||
}
|
||||
|
||||
void FileManager::tear_down() {
|
||||
parent_.reset();
|
||||
// Completely clear memory when closing, to avoid memory leaks
|
||||
memory_cleanup(true);
|
||||
parent_.reset();
|
||||
}
|
||||
} // namespace td
|
||||
|
Loading…
Reference in New Issue
Block a user