diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-02-01 12:55:28 -0500 |
---|---|---|
committer | Matthew Heon <matthew.heon@gmail.com> | 2018-02-01 12:55:28 -0500 |
commit | ae89dc28d07e1c6142201c282a76d3f237821710 (patch) | |
tree | a729a757fec7c22c5df9f1f65c4cc27556005e7e /vendor/github.com/containerd/cgroups/systemd.go | |
parent | 03cfe5ebbee306ee4aa84c74bbff83712e50fb1c (diff) | |
download | podman-ae89dc28d07e1c6142201c282a76d3f237821710.tar.gz podman-ae89dc28d07e1c6142201c282a76d3f237821710.tar.bz2 podman-ae89dc28d07e1c6142201c282a76d3f237821710.zip |
Update containerd/cgroups repo fix perf issue
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'vendor/github.com/containerd/cgroups/systemd.go')
-rw-r--r-- | vendor/github.com/containerd/cgroups/systemd.go | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/vendor/github.com/containerd/cgroups/systemd.go b/vendor/github.com/containerd/cgroups/systemd.go index 5e052a821..fd816e32e 100644 --- a/vendor/github.com/containerd/cgroups/systemd.go +++ b/vendor/github.com/containerd/cgroups/systemd.go @@ -43,19 +43,13 @@ func Slice(slice, name string) Path { } func NewSystemd(root string) (*SystemdController, error) { - conn, err := systemdDbus.New() - if err != nil { - return nil, err - } return &SystemdController{ root: root, - conn: conn, }, nil } type SystemdController struct { mu sync.Mutex - conn *systemdDbus.Conn root string } @@ -64,6 +58,11 @@ func (s *SystemdController) Name() Name { } func (s *SystemdController) Create(path string, resources *specs.LinuxResources) error { + conn, err := systemdDbus.New() + if err != nil { + return err + } + defer conn.Close() slice, name := splitName(path) properties := []systemdDbus.Property{ systemdDbus.PropDescription(fmt.Sprintf("cgroup %s", name)), @@ -74,14 +73,29 @@ func (s *SystemdController) Create(path string, resources *specs.LinuxResources) newProperty("CPUAccounting", true), newProperty("BlockIOAccounting", true), } - _, err := s.conn.StartTransientUnit(name, "replace", properties, nil) - return err + ch := make(chan string) + _, err = conn.StartTransientUnit(name, "replace", properties, ch) + if err != nil { + return err + } + <-ch + return nil } func (s *SystemdController) Delete(path string) error { + conn, err := systemdDbus.New() + if err != nil { + return err + } + defer conn.Close() _, name := splitName(path) - _, err := s.conn.StopUnit(name, "replace", nil) - return err + ch := make(chan string) + _, err = conn.StopUnit(name, "replace", ch) + if err != nil { + return err + } + <-ch + return nil } func newProperty(name string, units interface{}) systemdDbus.Property { |