Skip to content

Commit

Permalink
Improve logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
levlam committed Aug 15, 2021
1 parent d161323 commit d7dd6ff
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 32 deletions.
56 changes: 26 additions & 30 deletions td/telegram/UpdatesManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,18 @@ void UpdatesManager::fill_pts_gap(void *td) {
return;
}

auto td_ptr = static_cast<Td *>(td);
string source = PSTRING() << "pts from " << td_ptr->updates_manager_->get_pts() << " to "
<< td_ptr->updates_manager_->get_min_pending_pts();
auto updates_manager = static_cast<Td *>(td)->updates_manager_.get();
auto min_pts = std::numeric_limits<int32>::max();
auto max_pts = 0;
if (!updates_manager->pending_pts_updates_.empty()) {
min_pts = min(min_pts, updates_manager->pending_pts_updates_.begin()->first);
max_pts = max(max_pts, updates_manager->pending_pts_updates_.rbegin()->first);
}
if (!updates_manager->postponed_pts_updates_.empty()) {
min_pts = min(min_pts, updates_manager->postponed_pts_updates_.begin()->first);
max_pts = max(max_pts, updates_manager->postponed_pts_updates_.rbegin()->first);
}
string source = PSTRING() << "pts from " << updates_manager->get_pts() << " to " << min_pts << '-' << max_pts;
fill_gap(td, source.c_str());
}

Expand All @@ -193,12 +202,14 @@ void UpdatesManager::fill_seq_gap(void *td) {
return;
}

auto td_ptr = static_cast<Td *>(td);
auto seq = std::numeric_limits<int32>::max();
if (!td_ptr->updates_manager_->pending_seq_updates_.empty()) {
seq = td_ptr->updates_manager_->pending_seq_updates_.begin()->first;
auto updates_manager = static_cast<Td *>(td)->updates_manager_.get();
auto min_seq = std::numeric_limits<int32>::max();
auto max_seq = 0;
if (!updates_manager->pending_seq_updates_.empty()) {
min_seq = updates_manager->pending_seq_updates_.begin()->first;
max_seq = updates_manager->pending_seq_updates_.rbegin()->second.seq_end;
}
string source = PSTRING() << "seq from " << td_ptr->updates_manager_->seq_ << " to " << seq;
string source = PSTRING() << "seq from " << updates_manager->seq_ << " to " << min_seq << '-' << max_seq;
fill_gap(td, source.c_str());
}

Expand All @@ -208,12 +219,14 @@ void UpdatesManager::fill_qts_gap(void *td) {
return;
}

auto td_ptr = static_cast<Td *>(td);
auto qts = std::numeric_limits<int32>::max();
if (!td_ptr->updates_manager_->pending_qts_updates_.empty()) {
qts = td_ptr->updates_manager_->pending_qts_updates_.begin()->first;
auto updates_manager = static_cast<Td *>(td)->updates_manager_.get();
auto min_qts = std::numeric_limits<int32>::max();
auto max_qts = 0;
if (!updates_manager->pending_qts_updates_.empty()) {
min_qts = updates_manager->pending_qts_updates_.begin()->first;
max_qts = updates_manager->pending_qts_updates_.rbegin()->first;
}
string source = PSTRING() << "qts from " << td_ptr->updates_manager_->get_qts() << " to " << qts;
string source = PSTRING() << "qts from " << updates_manager->get_qts() << " to " << min_qts << '-' << max_qts;
fill_gap(td, source.c_str());
}

Expand Down Expand Up @@ -1817,23 +1830,6 @@ void UpdatesManager::process_updates(vector<tl_object_ptr<telegram_api::Update>>
lock.set_value(Unit());
}

int32 UpdatesManager::get_min_pending_pts() const {
int32 result = std::numeric_limits<int32>::max();
if (!pending_pts_updates_.empty()) {
auto pts = pending_pts_updates_.begin()->first;
if (pts < result) {
result = pts;
}
}
if (!postponed_pts_updates_.empty()) {
auto pts = postponed_pts_updates_.begin()->first;
if (pts < result) {
result = pts;
}
}
return result;
}

void UpdatesManager::process_pts_update(tl_object_ptr<telegram_api::Update> &&update) {
CHECK(update != nullptr);

Expand Down
2 changes: 0 additions & 2 deletions td/telegram/UpdatesManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,6 @@ class UpdatesManager final : public Actor {

void after_get_difference();

int32 get_min_pending_pts() const;

static bool have_update_pts_changed(const vector<tl_object_ptr<telegram_api::Update>> &updates);

static bool check_pts_update_dialog_id(DialogId dialog_id);
Expand Down

0 comments on commit d7dd6ff

Please sign in to comment.