From 399025dc5f433711a48c0d3b7bdfc33c980b5c23 Mon Sep 17 00:00:00 2001 From: Guinness Date: Wed, 2 Dec 2020 13:17:20 +0100 Subject: [PATCH 1/3] When a channel hasn't seen client or cell log differently The time diffs were misleading and unpretty when a channel has not seen a client, a cell or transmitted a cell. This commit adds some prettier messages. Fixes #40182 --- changes/ticket40182 | 4 ++++ src/core/or/channel.c | 52 ++++++++++++++++++++++++++++--------------- 2 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 changes/ticket40182 diff --git a/changes/ticket40182 b/changes/ticket40182 new file mode 100644 index 0000000000..0accd7d704 --- /dev/null +++ b/changes/ticket40182 @@ -0,0 +1,4 @@ + o Minor features(logging): + - If a channel has never received, transmitted a cell or seen a client, + do not calculate time diffs against 1/1/1970 but log another prettier message + Fixes 40182 diff --git a/src/core/or/channel.c b/src/core/or/channel.c index 26c93d169f..cf9edef902 100644 --- a/src/core/or/channel.c +++ b/src/core/or/channel.c @@ -2629,24 +2629,40 @@ channel_dump_statistics, (channel_t *chan, int severity)) circuitmux_num_circuits(chan->cmux) : 0); /* Describe timestamps */ - tor_log(severity, LD_GENERAL, - " * Channel %"PRIu64 " was last used by a " - "client at %"PRIu64 " (%"PRIu64 " seconds ago)", - (chan->global_identifier), - (uint64_t)(chan->timestamp_client), - (uint64_t)(now - chan->timestamp_client)); - tor_log(severity, LD_GENERAL, - " * Channel %"PRIu64 " last received a cell " - "at %"PRIu64 " (%"PRIu64 " seconds ago)", - (chan->global_identifier), - (uint64_t)(chan->timestamp_recv), - (uint64_t)(now - chan->timestamp_recv)); - tor_log(severity, LD_GENERAL, - " * Channel %"PRIu64 " last transmitted a cell " - "at %"PRIu64 " (%"PRIu64 " seconds ago)", - (chan->global_identifier), - (uint64_t)(chan->timestamp_xmit), - (uint64_t)(now - chan->timestamp_xmit)); + if (chan->timestamp_client == 0) { + tor_log(severity, LD_GENERAL, + " * Channel %"PRIu64 " was never used by a " + "client", (chan->global_identifier)); + } else { + tor_log(severity, LD_GENERAL, + " * Channel %"PRIu64 " was last used by a " + "client at %"PRIu64 " (%"PRIu64 " seconds ago)", + (chan->global_identifier), + (uint64_t)(chan->timestamp_client), + (uint64_t)(now - chan->timestamp_client)); + } + if (chan->timestamp_recv == 0) { + tor_log(severity, LD_GENERAL, + " * Channel %"PRIu64 " never received a cell", (chan->global_identifier)); + } else { + tor_log(severity, LD_GENERAL, + " * Channel %"PRIu64 " last received a cell " + "at %"PRIu64 " (%"PRIu64 " seconds ago)", + (chan->global_identifier), + (uint64_t)(chan->timestamp_recv), + (uint64_t)(now - chan->timestamp_recv)); + } + if (chan->timestamp_xmit == 0) { + tor_log(severity, LD_GENERAL, + " * Channel %"PRIu64 " never transmitted a cell",(chan->global_identifier)); + } else { + tor_log(severity, LD_GENERAL, + " * Channel %"PRIu64 " last transmitted a cell " + "at %"PRIu64 " (%"PRIu64 " seconds ago)", + (chan->global_identifier), + (uint64_t)(chan->timestamp_xmit), + (uint64_t)(now - chan->timestamp_xmit)); + } /* Describe counters and rates */ tor_log(severity, LD_GENERAL, From 83a11f8a767f55e1f2cc6b4632e0fdec6f89f945 Mon Sep 17 00:00:00 2001 From: Guinness Date: Thu, 9 Sep 2021 13:59:33 +0200 Subject: [PATCH 2/3] Fix the line length in the patch --- src/core/or/channel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/or/channel.c b/src/core/or/channel.c index cf9edef902..94c6a8121c 100644 --- a/src/core/or/channel.c +++ b/src/core/or/channel.c @@ -2643,7 +2643,8 @@ channel_dump_statistics, (channel_t *chan, int severity)) } if (chan->timestamp_recv == 0) { tor_log(severity, LD_GENERAL, - " * Channel %"PRIu64 " never received a cell", (chan->global_identifier)); + " * Channel %"PRIu64 " never received a cell", + (chan->global_identifier)); } else { tor_log(severity, LD_GENERAL, " * Channel %"PRIu64 " last received a cell " @@ -2654,7 +2655,8 @@ channel_dump_statistics, (channel_t *chan, int severity)) } if (chan->timestamp_xmit == 0) { tor_log(severity, LD_GENERAL, - " * Channel %"PRIu64 " never transmitted a cell",(chan->global_identifier)); + " * Channel %"PRIu64 " never transmitted a cell", + (chan->global_identifier)); } else { tor_log(severity, LD_GENERAL, " * Channel %"PRIu64 " last transmitted a cell " From bd68668ac0e4fb11ac2bcab89ec6592c4721932f Mon Sep 17 00:00:00 2001 From: Guinness Date: Mon, 13 Sep 2021 19:02:23 +0200 Subject: [PATCH 3/3] Fix changes file --- changes/ticket40182 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/changes/ticket40182 b/changes/ticket40182 index 0accd7d704..0071ef9f93 100644 --- a/changes/ticket40182 +++ b/changes/ticket40182 @@ -1,4 +1,4 @@ o Minor features(logging): - If a channel has never received, transmitted a cell or seen a client, - do not calculate time diffs against 1/1/1970 but log another prettier message - Fixes 40182 + do not calculate time diffs against 1/1/1970 but log another prettier message + Fixes 40182