Skip to content

Commit

Permalink
Reworkkgarbage collection code to use tick
Browse files Browse the repository at this point in the history
Instead of sleeping reworked the code to use recurring ticks.
Also cleaned up unnecessary defers.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
  • Loading branch information
mrjana committed May 27, 2015
1 parent 051f4cc commit b028371
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions sandbox/namespace_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ func createBasePath() {
}

func removeUnusedPaths() {
for {
time.Sleep(time.Duration(gpmCleanupPeriod))

for range time.Tick(gpmCleanupPeriod) {
gpmLock.Lock()
pathList := make([]string, 0, len(garbagePathMap))
for path := range garbagePathMap {
Expand All @@ -78,13 +76,13 @@ func removeUnusedPaths() {
func addToGarbagePaths(path string) {
gpmLock.Lock()
garbagePathMap[path] = true
defer gpmLock.Unlock()
gpmLock.Unlock()
}

func removeFromGarbagePaths(path string) {
gpmLock.Lock()
delete(garbagePathMap, path)
defer gpmLock.Unlock()
gpmLock.Unlock()
}

// GenerateKey generates a sandbox key based on the passed
Expand Down

0 comments on commit b028371

Please sign in to comment.