From ffa86e398a06646336c03689345a3caa2cc4765b Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Thu, 27 Mar 2014 08:25:01 +0000 Subject: [PATCH] Fix compile and unit test errors after merge Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) --- cgroups/apply_raw.go | 23 +++++++++++++++++++++++ cgroups/cgroups.go | 19 ------------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/cgroups/apply_raw.go b/cgroups/apply_raw.go index 47a2a00..5fe3179 100644 --- a/cgroups/apply_raw.go +++ b/cgroups/apply_raw.go @@ -49,6 +49,9 @@ func rawApply(c *Cgroup, pid int) (ActiveCgroup, error) { if err := raw.setupCpu(c, pid); err != nil { return nil, err } + if err := raw.setupCpuset(c, pid); err != nil { + return nil, err + } return raw, nil } @@ -170,6 +173,25 @@ func (raw *rawCgroup) setupCpu(c *Cgroup, pid int) (err error) { return nil } +func (raw *rawCgroup) setupCpuset(c *Cgroup, pid int) (err error) { + if c.CpusetCpus != "" { + dir, err := raw.join("cpuset", pid) + if err != nil { + return err + } + defer func() { + if err != nil { + os.RemoveAll(dir) + } + }() + + if err := writeFile(dir, "cpuset.cpus", c.CpusetCpus); err != nil { + return err + } + } + return nil +} + func (raw *rawCgroup) Cleanup() error { get := func(subsystem string) string { path, _ := raw.path(subsystem) @@ -180,6 +202,7 @@ func (raw *rawCgroup) Cleanup() error { get("memory"), get("devices"), get("cpu"), + get("cpuset"), } { if path != "" { os.RemoveAll(path) diff --git a/cgroups/cgroups.go b/cgroups/cgroups.go index cdf2687..5fe1034 100644 --- a/cgroups/cgroups.go +++ b/cgroups/cgroups.go @@ -101,22 +101,3 @@ func (c *Cgroup) Apply(pid int) (ActiveCgroup, error) { return rawApply(c, pid) } } - -func (c *Cgroup) setupCpuset(cgroupRoot string, pid int) (err error) { - if c.CpusetCpus != "" { - dir, err := c.Join(cgroupRoot, "cpuset", pid) - if err != nil { - return err - } - defer func() { - if err != nil { - os.RemoveAll(dir) - } - }() - - if err := writeFile(dir, "cpuset.cpus", c.CpusetCpus); err != nil { - return err - } - } - return nil -}