From 751af3a838d7a334d1576453fe2779d91da1e055 Mon Sep 17 00:00:00 2001 From: Kris Date: Wed, 22 Jun 2016 18:27:06 -0700 Subject: [PATCH] Bump inotify to pickup fix for memory leak --- Godeps/Godeps.json | 4 ++-- .../golang.org/x/exp/inotify/inotify_linux.go | 24 ++++++++++++------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 60ec7a96c5d..5002e112908 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,7 +1,7 @@ { "ImportPath": "k8s.io/kubernetes", "GoVersion": "go1.6", - "GodepVersion": "v69", + "GodepVersion": "v74", "Packages": [ "github.com/ugorji/go/codec/codecgen", "github.com/onsi/ginkgo/ginkgo", @@ -1973,7 +1973,7 @@ }, { "ImportPath": "golang.org/x/exp/inotify", - "Rev": "d00e13ec443927751b2bd49e97dea7bf3b6a6487" + "Rev": "292a51b8d262487dab23a588950e8052d63d9113" }, { "ImportPath": "golang.org/x/net/context", diff --git a/vendor/golang.org/x/exp/inotify/inotify_linux.go b/vendor/golang.org/x/exp/inotify/inotify_linux.go index 41ac5583828..901f308d84a 100644 --- a/vendor/golang.org/x/exp/inotify/inotify_linux.go +++ b/vendor/golang.org/x/exp/inotify/inotify_linux.go @@ -144,6 +144,10 @@ func (w *Watcher) RemoveWatch(path string) error { return os.NewSyscallError("inotify_rm_watch", errno) } delete(w.watches, path) + // Locking here to protect the read from paths in readEvents. + w.mu.Lock() + delete(w.paths, int(watch.wd)) + w.mu.Unlock() return nil } @@ -197,17 +201,19 @@ func (w *Watcher) readEvents() { // the "Name" field with a valid filename. We retrieve the path of the watch from // the "paths" map. w.mu.Lock() - event.Name = w.paths[int(raw.Wd)] + name, ok := w.paths[int(raw.Wd)] w.mu.Unlock() - if nameLen > 0 { - // Point "bytes" at the first byte of the filename - bytes := (*[syscall.PathMax]byte)(unsafe.Pointer(&buf[offset+syscall.SizeofInotifyEvent])) - // The filename is padded with NUL bytes. TrimRight() gets rid of those. - event.Name += "/" + strings.TrimRight(string(bytes[0:nameLen]), "\000") + if ok { + event.Name = name + if nameLen > 0 { + // Point "bytes" at the first byte of the filename + bytes := (*[syscall.PathMax]byte)(unsafe.Pointer(&buf[offset+syscall.SizeofInotifyEvent])) + // The filename is padded with NUL bytes. TrimRight() gets rid of those. + event.Name += "/" + strings.TrimRight(string(bytes[0:nameLen]), "\000") + } + // Send the event on the events channel + w.Event <- event } - // Send the event on the events channel - w.Event <- event - // Move to the next event in the buffer offset += syscall.SizeofInotifyEvent + nameLen }