From 91bb48e82cff2004d80890540511a80a0d9dd3a0 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Mon, 20 Dec 2021 12:19:18 -0500 Subject: [PATCH] dont access storage on non running servers for metrics (segfault) --- server.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server.go b/server.go index 82bf1c1..56e7247 100644 --- a/server.go +++ b/server.go @@ -193,10 +193,13 @@ type Statistics struct { // GetStatistics is a stub method for providing some high level information about // the server operation to bundling applications (e.g. the UI) func (s *server) GetStatistics() Statistics { - return Statistics{ - TotalMessages: s.messageStore.MessagesCount(), - TotalConnections: s.service.Metrics().ConnectionCount, + if s.running { + return Statistics{ + TotalMessages: s.messageStore.MessagesCount(), + TotalConnections: s.service.Metrics().ConnectionCount, + } } + return Statistics{} } func (s *server) Delete(password string) error {