mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
stats: use appropriate Lock func's
This commit is contained in:
parent
01af8e2905
commit
9c90b5e77c
@ -102,8 +102,8 @@ func (s *StatsInfo) Bytes(bytes int64) {
|
|||||||
|
|
||||||
// GetBytes returns the number of bytes transferred so far
|
// GetBytes returns the number of bytes transferred so far
|
||||||
func (s *StatsInfo) GetBytes() int64 {
|
func (s *StatsInfo) GetBytes() int64 {
|
||||||
s.mu.Lock()
|
s.mu.RLock()
|
||||||
defer s.mu.Unlock()
|
defer s.mu.RUnlock()
|
||||||
return s.bytes
|
return s.bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,8 +138,8 @@ func (s *StatsInfo) Deletes(deletes int64) int64 {
|
|||||||
|
|
||||||
// ResetCounters sets the counters (bytes, checks, errors, transfers) to 0
|
// ResetCounters sets the counters (bytes, checks, errors, transfers) to 0
|
||||||
func (s *StatsInfo) ResetCounters() {
|
func (s *StatsInfo) ResetCounters() {
|
||||||
s.mu.RLock()
|
s.mu.Lock()
|
||||||
defer s.mu.RUnlock()
|
defer s.mu.Unlock()
|
||||||
s.bytes = 0
|
s.bytes = 0
|
||||||
s.errors = 0
|
s.errors = 0
|
||||||
s.checks = 0
|
s.checks = 0
|
||||||
@ -149,8 +149,8 @@ func (s *StatsInfo) ResetCounters() {
|
|||||||
|
|
||||||
// ResetErrors sets the errors count to 0
|
// ResetErrors sets the errors count to 0
|
||||||
func (s *StatsInfo) ResetErrors() {
|
func (s *StatsInfo) ResetErrors() {
|
||||||
s.mu.RLock()
|
s.mu.Lock()
|
||||||
defer s.mu.RUnlock()
|
defer s.mu.Unlock()
|
||||||
s.errors = 0
|
s.errors = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user