Skip to content

Commit cf1f978

Browse files
committed
v2: flip error handling for readKVStat("memory.events") to reduce indentation
Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
1 parent 6a46df2 commit cf1f978

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

v2/manager.go

+7-8
Original file line numberDiff line numberDiff line change
@@ -660,20 +660,19 @@ func (c *Manager) waitForEvents(ec chan<- Event, errCh chan<- error) {
660660
}
661661
if bytesRead >= syscall.SizeofInotifyEvent {
662662
out := make(map[string]interface{})
663-
if err := readKVStatsFile(c.path, "memory.events", out); err == nil {
664-
e, err := parseMemoryEvents(out)
665-
if err != nil {
666-
errCh <- err
667-
return
668-
}
669-
ec <- e
670-
} else {
663+
if err := readKVStatsFile(c.path, "memory.events", out); err != nil {
671664
// When cgroup is deleted read may return -ENODEV instead of -ENOENT from open.
672665
if _, statErr := os.Lstat(filepath.Join(c.path, "memory.events")); !os.IsNotExist(statErr) {
673666
errCh <- err
674667
}
675668
return
676669
}
670+
e, err := parseMemoryEvents(out)
671+
if err != nil {
672+
errCh <- err
673+
return
674+
}
675+
ec <- e
677676
if c.isCgroupEmpty() {
678677
return
679678
}

0 commit comments

Comments
 (0)