From ca7c1e5adabc2c94b58d984528eb45f8299c4ee8 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 20 Jun 2021 03:05:58 +0300 Subject: [PATCH] Dump network queries from oldest to newest. --- td/telegram/cli.cpp | 3 +-- td/telegram/net/NetQueryStats.cpp | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index dbc08fcf3..f6aa30ee1 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -145,7 +145,6 @@ static char *command_generator(const char *text, int state) { "CancelDownloadFile", "ImportContacts", "RemoveContacts", - "DumpNetQueries", "CreateSecretChat", "CreateNewSecretChat"}; static size_t cmd_i; @@ -4304,7 +4303,7 @@ class CliClient final : public Actor { } } else if (op == "q" || op == "Quit") { quit(); - } else if (op == "dnq" || op == "DumpNetQueries") { + } else if (op == "dnq") { dump_pending_network_queries(*net_query_stats_); } else if (op == "fatal") { LOG(FATAL) << "Fatal!"; diff --git a/td/telegram/net/NetQueryStats.cpp b/td/telegram/net/NetQueryStats.cpp index 4eab21464..a8ed0a489 100644 --- a/td/telegram/net/NetQueryStats.cpp +++ b/td/telegram/net/NetQueryStats.cpp @@ -31,7 +31,8 @@ void NetQueryStats::dump_pending_network_queries() { bool was_gap = false; auto &net_query_list = list_; auto guard = net_query_list.lock(); - for (auto end = net_query_list.end(), cur = net_query_list.begin(); cur != end; cur = cur->get_next(), i++) { + for (auto begin = net_query_list.begin(), cur = net_query_list.end(); cur != begin; i++) { + cur = cur->get_prev(); if (i < 20 || i + 20 > n || i % (n / 20 + 1) == 0) { if (was_gap) { LOG(WARNING) << "...";