stats: use appropriate Lock func's

This commit is contained in:
Fabian Möller 2018-07-22 11:33:19 +02:00
parent 01af8e2905
commit 9c90b5e77c

View File

@ -102,8 +102,8 @@ func (s *StatsInfo) Bytes(bytes int64) {
// GetBytes returns the number of bytes transferred so far
func (s *StatsInfo) GetBytes() int64 {
s.mu.Lock()
defer s.mu.Unlock()
s.mu.RLock()
defer s.mu.RUnlock()
return s.bytes
}
@ -138,8 +138,8 @@ func (s *StatsInfo) Deletes(deletes int64) int64 {
// ResetCounters sets the counters (bytes, checks, errors, transfers) to 0
func (s *StatsInfo) ResetCounters() {
s.mu.RLock()
defer s.mu.RUnlock()
s.mu.Lock()
defer s.mu.Unlock()
s.bytes = 0
s.errors = 0
s.checks = 0
@ -149,8 +149,8 @@ func (s *StatsInfo) ResetCounters() {
// ResetErrors sets the errors count to 0
func (s *StatsInfo) ResetErrors() {
s.mu.RLock()
defer s.mu.RUnlock()
s.mu.Lock()
defer s.mu.Unlock()
s.errors = 0
}