diff --git a/stream/mts/encoder.go b/stream/mts/encoder.go index 7bc511ed..a5550644 100644 --- a/stream/mts/encoder.go +++ b/stream/mts/encoder.go @@ -127,37 +127,39 @@ const ( // timeLocation holds time and location data type timeLocation struct { - sync.RWMutex + mu sync.RWMutex time uint64 location string } // SetTimeStamp sets the time field of a TimeLocation. func (tl *timeLocation) SetTimeStamp(t uint64) { - tl.Lock() + tl.mu.Lock() tl.time = t - tl.Unlock() + tl.mu.Unlock() } // GetTimeStamp returns the location of a TimeLocation. func (tl *timeLocation) TimeStamp() uint64 { - tl.RLock() - defer tl.RUnlock() - return tl.time + tl.mu.RLock() + t := tl.time + tl.mu.RUnlock() + return t } // SetLocation sets the location of a TimeLocation. func (tl *timeLocation) SetLocation(l string) { - tl.Lock() + tl.mu.Lock() tl.location = l - tl.Unlock() + tl.mu.Unlock() } // GetLocation returns the location of a TimeLocation. func (tl *timeLocation) Location() string { - tl.RLock() - defer tl.RUnlock() - return tl.location + tl.mu.RLock() + l := tl.location + tl.mu.RUnlock() + return l } // MetData will hold time and location data which may be set externally if