Skip to content

Commit

Permalink
Check GC loop is active/necessary before triggering GC
Browse files Browse the repository at this point in the history
Calling GC() without ever creating a network namespace (sandbox on
Linux) will hang as the GC loop is not running (and therefore the
channel is not being listened to).

Tested via Docker that this corrects a daemon shutdown error if the
daemon is started and stopped without any containers or networks being
created while the daemon is up.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
  • Loading branch information
estesp committed Jun 10, 2015
1 parent 40f7ffc commit 4e0ffd7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions sandbox/namespace_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,20 @@ func removeFromGarbagePaths(path string) {
// GC triggers garbage collection of namespace path right away
// and waits for it.
func GC() {
waitGC := make(chan struct{})
gpmLock.Lock()
if len(garbagePathMap) == 0 {
// No need for GC if map is empty
gpmLock.Unlock()
return
}
gpmLock.Unlock()

// Trigger GC now
// if content exists in the garbage paths
// we can trigger GC to run, providing a
// channel to be notified on completion
waitGC := make(chan struct{})
gpmChan <- waitGC

// wait for gc to complete
// wait for GC completion
<-waitGC
}

Expand Down

0 comments on commit 4e0ffd7

Please sign in to comment.