Skip to content

Commit

Permalink
Merge pull request #1006 from vishh/gr-leak
Browse files Browse the repository at this point in the history
Fix goroutine leak in docker fs handler logic.
  • Loading branch information
dchen1107 committed Dec 4, 2015
2 parents 1d6e0ec + a6daa76 commit 1d2d38d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,7 @@ type ContainerHandler interface {

// Returns whether the container still exists.
Exists() bool

// Cleanup frees up any resources being held like fds or go routines, etc.
Cleanup()
}
4 changes: 4 additions & 0 deletions container/docker/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ func newDockerContainerHandler(
return handler, nil
}

func (self *dockerContainerHandler) Cleanup() {
self.fsHandler.stop()
}

func (self *dockerContainerHandler) ContainerReference() (info.ContainerReference, error) {
return info.ContainerReference{
Name: self.name,
Expand Down
2 changes: 2 additions & 0 deletions container/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func (self *MockContainerHandler) ContainerReference() (info.ContainerReference,
return args.Get(0).(info.ContainerReference), args.Error(1)
}

func (self *MockContainerHandler) Cleanup() {}

func (self *MockContainerHandler) GetSpec() (info.ContainerSpec, error) {
args := self.Called()
return args.Get(0).(info.ContainerSpec), args.Error(1)
Expand Down
3 changes: 3 additions & 0 deletions container/raw/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ func (self *rawContainerHandler) GetRootNetworkDevices() ([]info.NetInfo, error)
return nd, nil
}

// Nothing to clean up.
func (self *rawContainerHandler) Cleanup() {}

func (self *rawContainerHandler) GetSpec() (info.ContainerSpec, error) {
var spec info.ContainerSpec

Expand Down
2 changes: 2 additions & 0 deletions manager/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ func (c *containerData) housekeeping() {
for {
select {
case <-c.stop:
// Cleanup container resources before stopping housekeeping.
c.handler.Cleanup()
// Stop housekeeping when signaled.
return
default:
Expand Down

0 comments on commit 1d2d38d

Please sign in to comment.