Merge pull request #1346 from krousey/inotify_bump
Updating inotify to fix memory leak
This commit is contained in:
commit
6351fbfc84
3
Godeps/Godeps.json
generated
3
Godeps/Godeps.json
generated
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"ImportPath": "github.com/google/cadvisor",
|
"ImportPath": "github.com/google/cadvisor",
|
||||||
"GoVersion": "go1.5",
|
"GoVersion": "go1.5",
|
||||||
|
"GodepVersion": "v74",
|
||||||
"Packages": [
|
"Packages": [
|
||||||
"./..."
|
"./..."
|
||||||
],
|
],
|
||||||
@ -459,7 +460,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "golang.org/x/exp/inotify",
|
"ImportPath": "golang.org/x/exp/inotify",
|
||||||
"Rev": "d00e13ec443927751b2bd49e97dea7bf3b6a6487"
|
"Rev": "292a51b8d262487dab23a588950e8052d63d9113"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "golang.org/x/net/context",
|
"ImportPath": "golang.org/x/net/context",
|
||||||
|
10
Godeps/_workspace/src/golang.org/x/exp/inotify/inotify_linux.go
generated
vendored
10
Godeps/_workspace/src/golang.org/x/exp/inotify/inotify_linux.go
generated
vendored
@ -144,6 +144,10 @@ func (w *Watcher) RemoveWatch(path string) error {
|
|||||||
return os.NewSyscallError("inotify_rm_watch", errno)
|
return os.NewSyscallError("inotify_rm_watch", errno)
|
||||||
}
|
}
|
||||||
delete(w.watches, path)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,8 +201,10 @@ func (w *Watcher) readEvents() {
|
|||||||
// the "Name" field with a valid filename. We retrieve the path of the watch from
|
// the "Name" field with a valid filename. We retrieve the path of the watch from
|
||||||
// the "paths" map.
|
// the "paths" map.
|
||||||
w.mu.Lock()
|
w.mu.Lock()
|
||||||
event.Name = w.paths[int(raw.Wd)]
|
name, ok := w.paths[int(raw.Wd)]
|
||||||
w.mu.Unlock()
|
w.mu.Unlock()
|
||||||
|
if ok {
|
||||||
|
event.Name = name
|
||||||
if nameLen > 0 {
|
if nameLen > 0 {
|
||||||
// Point "bytes" at the first byte of the filename
|
// Point "bytes" at the first byte of the filename
|
||||||
bytes := (*[syscall.PathMax]byte)(unsafe.Pointer(&buf[offset+syscall.SizeofInotifyEvent]))
|
bytes := (*[syscall.PathMax]byte)(unsafe.Pointer(&buf[offset+syscall.SizeofInotifyEvent]))
|
||||||
@ -207,7 +213,7 @@ func (w *Watcher) readEvents() {
|
|||||||
}
|
}
|
||||||
// Send the event on the events channel
|
// Send the event on the events channel
|
||||||
w.Event <- event
|
w.Event <- event
|
||||||
|
}
|
||||||
// Move to the next event in the buffer
|
// Move to the next event in the buffer
|
||||||
offset += syscall.SizeofInotifyEvent + nameLen
|
offset += syscall.SizeofInotifyEvent + nameLen
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user