Skip to content

Commit

Permalink
cgroup: retry file writes on EINTR errors
Browse files Browse the repository at this point in the history
  • Loading branch information
adunham-stripe committed Jun 29, 2020
1 parent e8f1a5c commit e9fe638
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions runsc/cgroup/cgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,15 @@ func setOptionalValueUint16(path, name string, val *uint16) error {

func setValue(path, name, data string) error {
fullpath := filepath.Join(path, name)
return ioutil.WriteFile(fullpath, []byte(data), 0700)

// Retry writes on EINTR; see:
// https://github.com/golang/go/issues/38033
for {
err := ioutil.WriteFile(fullpath, []byte(data), 0700)
if err != syscall.EINTR {
return err
}
}
}

func getValue(path, name string) (string, error) {
Expand Down Expand Up @@ -132,8 +140,16 @@ func fillFromAncestor(path string) (string, error) {
if err != nil {
return "", err
}
if err := ioutil.WriteFile(path, []byte(val), 0700); err != nil {
return "", err

// Retry writes on EINTR; see:
// https://github.com/golang/go/issues/38033
for {
err := ioutil.WriteFile(path, []byte(val), 0700)
if err == nil {
break
} else if err != syscall.EINTR {
return "", err
}
}
return val, nil
}
Expand Down

0 comments on commit e9fe638

Please sign in to comment.