dont access storage on non running servers for metrics (segfault) #31

Closed
dan wants to merge 1 commits from segMetrics into trunk
1 changed files with 6 additions and 3 deletions

View File

@ -193,11 +193,14 @@ type Statistics struct {
// GetStatistics is a stub method for providing some high level information about // GetStatistics is a stub method for providing some high level information about
// the server operation to bundling applications (e.g. the UI) // the server operation to bundling applications (e.g. the UI)
func (s *server) GetStatistics() Statistics { func (s *server) GetStatistics() Statistics {
if s.running {
return Statistics{ return Statistics{
TotalMessages: s.messageStore.MessagesCount(), TotalMessages: s.messageStore.MessagesCount(),
TotalConnections: s.service.Metrics().ConnectionCount, TotalConnections: s.service.Metrics().ConnectionCount,
} }
} }
return Statistics{}
}
func (s *server) Delete(password string) error { func (s *server) Delete(password string) error {
s.lock.Lock() s.lock.Lock()