Ensure mutexes are unlocked right before panics, where defers aren’t easily usable.
Change-Id: I67c9870e7a626f590a8de8df6c8341c5483918dc
GitHub-Last-Rev:
bb8ffe538b3956892b55884fd64eadfce326f7b0
GitHub-Pull-Request: golang/go#37143
Reviewed-on: https://go-review.googlesource.com/c/go/+/218717
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
func (s *sequencer) End(id uint) {
s.mu.Lock()
if s.id != id {
+ s.mu.Unlock()
panic("out of sync")
}
id++
rwm.RLock()
n := atomic.AddInt32(activity, 1)
if n < 1 || n >= 10000 {
+ rwm.RUnlock()
panic(fmt.Sprintf("wlock(%d)\n", n))
}
for i := 0; i < 100; i++ {
rwm.Lock()
n := atomic.AddInt32(activity, 10000)
if n != 10000 {
+ rwm.Unlock()
panic(fmt.Sprintf("wlock(%d)\n", n))
}
for i := 0; i < 100; i++ {