1
0
mirror of https://github.com/golang/go synced 2024-11-17 06:54:48 -07:00

net/textproto, sync: add unlock before panic

This commit is contained in:
BurtonQin 2020-02-09 17:20:40 +08:00
parent cfe2ab42e7
commit bb8ffe538b
2 changed files with 3 additions and 0 deletions

View File

@ -99,6 +99,7 @@ func (s *sequencer) Start(id uint) {
func (s *sequencer) End(id uint) {
s.mu.Lock()
if s.id != id {
s.mu.Unlock()
panic("out of sync")
}
id++

View File

@ -59,6 +59,7 @@ func reader(rwm *RWMutex, num_iterations int, activity *int32, cdone chan bool)
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++ {
@ -74,6 +75,7 @@ func writer(rwm *RWMutex, num_iterations int, activity *int32, cdone chan bool)
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++ {