Skip to content

Commit

Permalink
cgroup2: Don't retry on EINTR
Browse files Browse the repository at this point in the history
Follow-up from a similar change for cgroup1 package here. Since Go 1.15
the stdlib automatically retries IO on EINTR, and since this package
uses things from go 1.16, all consumers of this pkg should be on > 1.15
making any manual retries on EINTR unnecessary.

Signed-off-by: Danny Canter <danny@dcantah.dev>
  • Loading branch information
dcantah committed Dec 31, 2022
1 parent e8802a1 commit 2b3be83
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions cgroup2/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,11 @@ func (c *Value) write(path string, perm os.FileMode) error {
return ErrInvalidFormat
}

// Retry writes on EINTR; see:
// https://github.com/golang/go/issues/38033
for {
err := os.WriteFile(
filepath.Join(path, c.filename),
data,
perm,
)
if err == nil {
return nil
} else if !errors.Is(err, syscall.EINTR) {
return err
}
}
return os.WriteFile(
filepath.Join(path, c.filename),
data,
perm,
)
}

func writeValues(path string, values []Value) error {
Expand Down Expand Up @@ -763,7 +754,8 @@ func setDevices(path string, devices []specs.LinuxDeviceCgroup) error {
// the reason this is necessary is because the "-" character has a special meaning in
// systemd slice. For example, when creating a slice called "my-group-112233.slice",
// systemd will create a hierarchy like this:
// /sys/fs/cgroup/my.slice/my-group.slice/my-group-112233.slice
//
// /sys/fs/cgroup/my.slice/my-group.slice/my-group-112233.slice
func getSystemdFullPath(slice, group string) string {
return filepath.Join(defaultCgroup2Path, dashesToPath(slice), dashesToPath(group))
}
Expand Down

0 comments on commit 2b3be83

Please sign in to comment.