cgroups: use Set instead of Apply in Freeze

So Apply function of freezer can be as sample as other subsystems.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
Qiang Huang 2015-03-04 13:45:44 +08:00
parent 903680701a
commit a8a798a7c9
2 changed files with 12 additions and 14 deletions

View File

@ -171,11 +171,16 @@ func (m *Manager) Freeze(state configs.FreezerState) error {
return err
}
dir, err := d.path("freezer")
if err != nil {
return err
}
prevState := m.Cgroups.Freezer
m.Cgroups.Freezer = state
freezer := subsystems["freezer"]
err = freezer.Apply(d)
err = freezer.Set(dir, m.Cgroups)
if err != nil {
m.Cgroups.Freezer = prevState
return err

View File

@ -12,21 +12,14 @@ type FreezerGroup struct {
}
func (s *FreezerGroup) Apply(d *data) error {
switch d.c.Freezer {
case configs.Frozen, configs.Thawed:
dir, err := d.path("freezer")
if err != nil {
dir, err := d.join("freezer")
if err != nil && !cgroups.IsNotFound(err) {
return err
}
if err := s.Set(dir, d.c); err != nil {
return err
}
default:
if _, err := d.join("freezer"); err != nil && !cgroups.IsNotFound(err) {
return err
}
}
return nil
}