summaryrefslogtreecommitdiff
path: root/libpod/container_internal.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-08-02 03:44:43 +0200
committerGitHub <noreply@github.com>2019-08-02 03:44:43 +0200
commite3240daa471dee1bbc118e6b3871c4a73890d0e0 (patch)
tree402bfadad932067a96635f799d3c3fd98282d5b2 /libpod/container_internal.go
parente48dc506d18335b36d1ffbbc8df1890ee3b99e2c (diff)
parent8da24f2f7d3472d2be4ccde8e7b42790671d464f (diff)
downloadpodman-e3240daa471dee1bbc118e6b3871c4a73890d0e0.tar.gz
podman-e3240daa471dee1bbc118e6b3871c4a73890d0e0.tar.bz2
podman-e3240daa471dee1bbc118e6b3871c4a73890d0e0.zip
Merge pull request #3551 from mheon/fix_memory_leak
Fix memory leak with exit files
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r--libpod/container_internal.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 83ee5640e..aba9c5b93 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -634,19 +634,15 @@ func (c *Container) removeConmonFiles() error {
return errors.Wrapf(err, "error removing container %s OOM file", c.ID())
}
- // Instead of outright deleting the exit file, rename it (if it exists).
- // We want to retain it so we can get the exit code of containers which
- // are removed (at least until we have a workable events system)
+ // Remove the exit file so we don't leak memory in tmpfs
exitFile := filepath.Join(c.ociRuntime.exitsDir, c.ID())
- oldExitFile := filepath.Join(c.ociRuntime.exitsDir, fmt.Sprintf("%s-old", c.ID()))
if _, err := os.Stat(exitFile); err != nil {
if !os.IsNotExist(err) {
return errors.Wrapf(err, "error running stat on container %s exit file", c.ID())
}
} else {
- // Rename should replace the old exit file (if it exists)
- if err := os.Rename(exitFile, oldExitFile); err != nil {
- return errors.Wrapf(err, "error renaming container %s exit file", c.ID())
+ if err := os.Remove(exitFile); err != nil {
+ return errors.Wrapf(err, "error removing container %s exit file", c.ID())
}
}
@@ -1112,7 +1108,13 @@ func (c *Container) stop(timeout uint) error {
}
// Wait until we have an exit file, and sync once we do
- return c.waitForExitFileAndSync()
+ if err := c.waitForExitFileAndSync(); err != nil {
+ return err
+ }
+
+ c.newContainerEvent(events.Stop)
+
+ return nil
}
// Internal, non-locking function to pause a container