This is an automated email from the ASF dual-hosted git repository.
dmeden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 994a04d0b0 traffic_top: avoid core when rpc node is not available.
(#10995)
994a04d0b0 is described below
commit 994a04d0b0ed937fe21c1c06e4463f832551eb6c
Author: Damian Meden <[email protected]>
AuthorDate: Fri Jan 19 10:14:39 2024 +0100
traffic_top: avoid core when rpc node is not available. (#10995)
This way, traffic_top just display the error when the node is not
avialable.
---
src/traffic_top/stats.h | 5 +++--
src/traffic_top/traffic_top.cc | 9 +++++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/traffic_top/stats.h b/src/traffic_top/stats.h
index c94482bfd9..ae68c37788 100644
--- a/src/traffic_top/stats.h
+++ b/src/traffic_top/stats.h
@@ -278,7 +278,7 @@ public:
lookup_table.insert(make_pair("client_dyn_ka", LookupItem("Dynamic KA",
"ka_total", "ka_count", 3)));
}
- void
+ bool
getStats()
{
if (_url == "") {
@@ -306,7 +306,7 @@ public:
// query the rpc node.
if (auto const &error = fetch_and_fill_stats(request, _stats);
!error.empty()) {
fprintf(stderr, "Error getting stats from the RPC node:\n%s",
error.c_str());
- abort();
+ return false;
}
_old_time = _now;
_now = now;
@@ -361,6 +361,7 @@ public:
}
#endif
}
+ return true;
}
int64_t
diff --git a/src/traffic_top/traffic_top.cc b/src/traffic_top/traffic_top.cc
index 645512dc83..57249af2b3 100644
--- a/src/traffic_top/traffic_top.cc
+++ b/src/traffic_top/traffic_top.cc
@@ -414,7 +414,10 @@ main(int argc, const char **argv)
}
Stats stats(url);
- stats.getStats();
+ if (!stats.getStats()) {
+ return 2;
+ }
+
const string &host = stats.getHost();
initscr();
@@ -482,7 +485,9 @@ main(int argc, const char **argv)
case 'a':
absolute = stats.toggleAbsolute();
}
- stats.getStats();
+ if (!stats.getStats()) {
+ goto quit;
+ }
clear();
}