aboutsummaryrefslogtreecommitdiffhomepage
path: root/tddb
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2022-12-20 16:37:22 +0300
committerlevlam <levlam@telegram.org>2022-12-20 16:37:22 +0300
commitf99fb4fc06c4f150e7d22f13e3cf9032aa00a53b (patch)
tree78b48273550de5ae3de2189ab1b6ed38a9204b68 /tddb
parent6cb9371061b35f1a3a1216042ec9b4b1f489e731 (diff)
Delete events from callback before forgetting them in TQueue.
Diffstat (limited to 'tddb')
-rw-r--r--tddb/td/db/TQueue.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/tddb/td/db/TQueue.cpp b/tddb/td/db/TQueue.cpp
index c94d7defa..0e6fd8057 100644
--- a/tddb/td/db/TQueue.cpp
+++ b/tddb/td/db/TQueue.cpp
@@ -236,6 +236,26 @@ class TQueueImpl final : public TQueue {
for (size_t i = 0; i < keep_count; i++) {
--end_it;
}
+
+ if (callback_ != nullptr) {
+ vector<uint64> deleted_log_event_ids;
+ auto callback_end_it = end_it;
+ if (keep_count == 0) {
+ --callback_end_it;
+ }
+ for (auto it = q.events.begin(); it != callback_end_it; ++it) {
+ auto &event = it->second;
+ if (event.log_event_id != 0) {
+ deleted_log_event_ids.push_back(event.log_event_id);
+ event.log_event_id = 0;
+ }
+ }
+ for (auto log_event_id : deleted_log_event_ids) {
+ callback_->pop(log_event_id);
+ }
+ }
+ auto callback_clear_time = Time::now() - start_time;
+
for (auto it = q.events.begin(); it != end_it;) {
pop(q, queue_id, it, q.tail_id);
}
@@ -243,7 +263,8 @@ class TQueueImpl final : public TQueue {
auto clear_time = Time::now() - start_time;
if (clear_time > 0.1) {
LOG(WARNING) << "Cleared " << (size - keep_count) << " TQueue events with total size "
- << (total_event_length - q.total_event_length) << " in " << clear_time << " seconds";
+ << (total_event_length - q.total_event_length) << " in " << clear_time - callback_clear_time
+ << " seconds and deleted them from callback in " << callback_clear_time << " seconds";
}
}