mirror of
https://github.com/moby/moby.git
synced 2026-08-08 09:01:44 +00:00
Merge pull request #272 from estesp/gc-startup-fix
Check GC loop is active/necessary before triggering GC
This commit is contained in:
@@ -107,12 +107,20 @@ func removeFromGarbagePaths(path string) {
|
||||
// GC triggers garbage collection of namespace path right away
|
||||
// and waits for it.
|
||||
func GC() {
|
||||
gpmLock.Lock()
|
||||
if len(garbagePathMap) == 0 {
|
||||
// No need for GC if map is empty
|
||||
gpmLock.Unlock()
|
||||
return
|
||||
}
|
||||
gpmLock.Unlock()
|
||||
|
||||
// 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{})
|
||||
|
||||
// Trigger GC now
|
||||
gpmChan <- waitGC
|
||||
|
||||
// wait for gc to complete
|
||||
// wait for GC completion
|
||||
<-waitGC
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user