««« backport
8b3bf65c620c
os: fix data race in epipecheck()
Fixes #3860.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/
6443051
»»»
package os
import (
+ "sync/atomic"
"syscall"
"time"
)
func epipecheck(file *File, e error) {
if e == syscall.EPIPE {
- file.nepipe++
- if file.nepipe >= 10 {
+ if atomic.AddInt32(&file.nepipe, 1) >= 10 {
sigpipe()
}
} else {
- file.nepipe = 0
+ atomic.StoreInt32(&file.nepipe, 0)
}
}
fd int
name string
dirinfo *dirInfo // nil unless directory being read
- nepipe int // number of consecutive EPIPE in Write
+ nepipe int32 // number of consecutive EPIPE in Write
}
// Fd returns the integer Unix file descriptor referencing the open file.
fd syscall.Handle
name string
dirinfo *dirInfo // nil unless directory being read
- nepipe int // number of consecutive EPIPE in Write
l sync.Mutex // used to implement windows pread/pwrite
}