diff --git a/cgroup2/manager.go b/cgroup2/manager.go index 3536fc97..f7d8a58c 100644 --- a/cgroup2/manager.go +++ b/cgroup2/manager.go @@ -796,7 +796,7 @@ func (c *Manager) memoryEventNonBlockFD() (_ *os.File, retErr error) { } func (c *Manager) EventChan() (<-chan Event, <-chan error) { - ec := make(chan Event, 1) + ec := make(chan Event, 16) errCh := make(chan error, 1) fd, err := c.memoryEventNonBlockFD() @@ -821,12 +821,6 @@ func (c *Manager) EventChan() (<-chan Event, <-chan error) { continue } - // Check cgroup.events first - shouldExit := false - if c.isCgroupEmpty() { - shouldExit = true - } - out := make(map[string]uint64) if err := readKVStatsFile(c.path, "memory.events", out); err != nil { // When cgroup is deleted read may return -ENODEV instead of -ENOENT from open. @@ -844,7 +838,7 @@ func (c *Manager) EventChan() (<-chan Event, <-chan error) { OOMKill: out["oom_kill"], } - if shouldExit { + if c.isCgroupEmpty() { return } }