Group call patches
Add disable_group_calls boolean option Add memory_cleanup and memory_stats to FileReferenceManager Add memory_cleanup and memory_stats to GroupCallManager
This commit is contained in:
parent
5a480a10a6
commit
7ef40eea0c
@ -365,6 +365,10 @@ void FileReferenceManager::reload_photo(PhotoSizeSource source, Promise<Unit> pr
|
||||
}
|
||||
}
|
||||
|
||||
void FileReferenceManager::memory_cleanup() {
|
||||
|
||||
}
|
||||
|
||||
void FileReferenceManager::memory_cleanup(NodeId node_id) {
|
||||
auto find_node = nodes_.find(node_id);
|
||||
if (find_node != nodes_.end()) {
|
||||
@ -375,4 +379,10 @@ void FileReferenceManager::memory_cleanup(NodeId node_id) {
|
||||
}
|
||||
}
|
||||
|
||||
void FileReferenceManager::memory_stats(vector<string> &output) {
|
||||
output.push_back("\"nodes_\":"); output.push_back(std::to_string(nodes_.size()));
|
||||
output.push_back(",");
|
||||
output.push_back("\"file_sources_\":"); output.push_back(std::to_string(file_sources_.size()));
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -74,6 +74,10 @@ class FileReferenceManager : public Actor {
|
||||
|
||||
void memory_cleanup(NodeId node_id);
|
||||
|
||||
void memory_cleanup();
|
||||
|
||||
void memory_stats(vector<string> &output);
|
||||
|
||||
private:
|
||||
struct Destination {
|
||||
bool empty() const {
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
#include "td/telegram/AccessRights.h"
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/ConfigManager.h"
|
||||
#include "td/telegram/ConfigShared.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DialogParticipant.h"
|
||||
#include "td/telegram/Global.h"
|
||||
@ -456,6 +458,34 @@ void GroupCallManager::tear_down() {
|
||||
parent_.reset();
|
||||
}
|
||||
|
||||
void GroupCallManager::memory_cleanup() {
|
||||
this->group_call_participants_.clear();
|
||||
this->group_call_participants_.rehash(0);
|
||||
this->group_call_recent_speakers_.clear();
|
||||
this->group_call_recent_speakers_.rehash(0);
|
||||
this->group_calls_.clear();
|
||||
this->group_calls_.rehash(0);
|
||||
|
||||
//todo: check if we can clear call ids vector
|
||||
// this->input_group_call_ids_.clear();
|
||||
|
||||
this->pending_join_requests_.clear();
|
||||
this->pending_join_requests_.rehash(0);
|
||||
|
||||
}
|
||||
|
||||
void GroupCallManager::memory_stats(vector<string> &output) {
|
||||
output.push_back("\"group_call_participants_\":"); output.push_back(std::to_string(group_call_participants_.size()));
|
||||
output.push_back(",");
|
||||
output.push_back("\"group_call_recent_speakers_\":"); output.push_back(std::to_string(group_call_recent_speakers_.size()));
|
||||
output.push_back(",");
|
||||
output.push_back("\"group_calls_\":"); output.push_back(std::to_string(group_calls_.size()));
|
||||
output.push_back(",");
|
||||
output.push_back("\"input_group_call_ids_\":"); output.push_back(std::to_string(input_group_call_ids_.size()));
|
||||
output.push_back(",");
|
||||
output.push_back("\"pending_join_requests_\":"); output.push_back(std::to_string(pending_join_requests_.size()));
|
||||
}
|
||||
|
||||
void GroupCallManager::on_pending_send_speaking_action_timeout_callback(void *group_call_manager_ptr,
|
||||
int64 group_call_id_int) {
|
||||
if (G()->close_flag()) {
|
||||
@ -536,7 +566,7 @@ void GroupCallManager::on_sync_participants_timeout(GroupCallId group_call_id) {
|
||||
}
|
||||
|
||||
GroupCallId GroupCallManager::get_group_call_id(InputGroupCallId input_group_call_id, DialogId dialog_id) {
|
||||
if (td_->auth_manager_->is_bot() || !input_group_call_id.is_valid()) {
|
||||
if (G()->shared_config().get_option_boolean("disable_group_calls") || td_->auth_manager_->is_bot() || !input_group_call_id.is_valid()) {
|
||||
return GroupCallId();
|
||||
}
|
||||
return add_group_call(input_group_call_id, dialog_id)->group_call_id;
|
||||
@ -1825,7 +1855,7 @@ void GroupCallManager::discard_group_call(GroupCallId group_call_id, Promise<Uni
|
||||
}
|
||||
|
||||
void GroupCallManager::on_update_group_call(tl_object_ptr<telegram_api::GroupCall> group_call_ptr, DialogId dialog_id) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
if (G()->shared_config().get_option_boolean("disable_group_calls") || td_->auth_manager_->is_bot()) {
|
||||
LOG(ERROR) << "Receive " << to_string(group_call_ptr);
|
||||
return;
|
||||
}
|
||||
@ -2258,17 +2288,26 @@ tl_object_ptr<td_api::updateGroupCallParticipant> GroupCallManager::get_update_g
|
||||
|
||||
void GroupCallManager::send_update_group_call(const GroupCall *group_call, const char *source) {
|
||||
LOG(INFO) << "Send update about " << group_call->group_call_id << " from " << source;
|
||||
if (G()->shared_config().get_option_boolean("disable_group_calls")) {
|
||||
return;
|
||||
}
|
||||
send_closure(G()->td(), &Td::send_update,
|
||||
get_update_group_call_object(group_call, get_recent_speaker_user_ids(group_call, true)));
|
||||
}
|
||||
|
||||
void GroupCallManager::send_update_group_call_participant(GroupCallId group_call_id,
|
||||
const GroupCallParticipant &participant) {
|
||||
if (G()->shared_config().get_option_boolean("disable_group_calls")) {
|
||||
return;
|
||||
}
|
||||
send_closure(G()->td(), &Td::send_update, get_update_group_call_participant_object(group_call_id, participant));
|
||||
}
|
||||
|
||||
void GroupCallManager::send_update_group_call_participant(InputGroupCallId input_group_call_id,
|
||||
const GroupCallParticipant &participant) {
|
||||
if (G()->shared_config().get_option_boolean("disable_group_calls")) {
|
||||
return;
|
||||
}
|
||||
auto group_call = get_group_call(input_group_call_id);
|
||||
CHECK(group_call != nullptr && group_call->is_inited);
|
||||
send_update_group_call_participant(group_call->group_call_id, participant);
|
||||
|
@ -37,6 +37,10 @@ class GroupCallManager : public Actor {
|
||||
GroupCallManager &operator=(GroupCallManager &&) = delete;
|
||||
~GroupCallManager() override;
|
||||
|
||||
void memory_cleanup();
|
||||
|
||||
void memory_stats(vector<string> &output);
|
||||
|
||||
GroupCallId get_group_call_id(InputGroupCallId input_group_call_id, DialogId dialog_id);
|
||||
|
||||
void create_voice_chat(DialogId dialog_id, Promise<GroupCallId> &&promise);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "td/telegram/VideosManager.h"
|
||||
#include "td/telegram/AudiosManager.h"
|
||||
#include "td/telegram/AnimationsManager.h"
|
||||
#include "td/telegram/GroupCallManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/LanguagePackManager.h"
|
||||
@ -150,6 +151,18 @@ void MemoryManager::get_memory_stats(bool full, Promise<MemoryStats> promise) co
|
||||
td_->file_manager_->memory_stats(output);
|
||||
output.push_back("}");
|
||||
|
||||
output.push_back(",");
|
||||
|
||||
output.push_back("\"file_reference_manager_\":{");
|
||||
td_->file_reference_manager_->memory_stats(output);
|
||||
output.push_back("}");
|
||||
|
||||
output.push_back(",");
|
||||
|
||||
output.push_back("\"group_call_manager_\":{");
|
||||
td_->group_call_manager_->memory_stats(output);
|
||||
output.push_back("}");
|
||||
|
||||
output.push_back("}}");
|
||||
|
||||
string s;
|
||||
@ -175,6 +188,8 @@ void MemoryManager::clean_memory(bool full, Promise<Unit> promise) const {
|
||||
td_->audios_manager_->memory_cleanup();
|
||||
td_->animations_manager_->memory_cleanup();
|
||||
td_->file_manager_->memory_cleanup();
|
||||
td_->file_reference_manager_->memory_cleanup();
|
||||
td_->group_call_manager_->memory_cleanup();
|
||||
|
||||
#ifdef __linux__
|
||||
#if defined(__GLIBC__) && !defined(__UCLIBC__) && !defined(__MUSL__)
|
||||
|
@ -5916,6 +5916,7 @@ void MessagesManager::memory_cleanup() {
|
||||
full_message_id_to_file_source_id_.clear();
|
||||
full_message_id_to_file_source_id_.rehash(0);
|
||||
}
|
||||
|
||||
void MessagesManager::memory_stats(vector<string> &output) {
|
||||
output.push_back("\"being_sent_messages_\":"); output.push_back(std::to_string(this->being_sent_messages_.size()));
|
||||
output.push_back(",");
|
||||
|
@ -7315,6 +7315,9 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
|
||||
if (set_boolean_option("disable_notifications")) {
|
||||
return;
|
||||
}
|
||||
if (set_boolean_option("disable_group_calls")) {
|
||||
return;
|
||||
}
|
||||
if (set_integer_option("delete_file_reference_after_seconds")) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user