fix fatal error: concurrent map read and map write

This commit is contained in:
gotang 2016-08-20 14:10:49 +08:00
parent bfcd1345fe
commit 6021814731
1 changed files with 2 additions and 0 deletions

View File

@ -61,11 +61,13 @@ func initEpollListener() *epollListener {
if err != nil { if err != nil {
panic(fmt.Sprintf("EpollWait error: %v", err)) panic(fmt.Sprintf("EpollWait error: %v", err))
} }
listener.mu.Lock()
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
if irq, ok := listener.interruptablePins[int(epollEvents[i].Fd)]; ok { if irq, ok := listener.interruptablePins[int(epollEvents[i].Fd)]; ok {
irq.Signal() irq.Signal()
} }
} }
listener.mu.Unlock()
} }
}() }()
return listener return listener