diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-01-03 22:30:13 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-01-04 14:33:47 +0000 |
commit | 9ab256f72aea15c76514cf29566cd227f4a0c9f5 (patch) | |
tree | 02cba4c6959fbb5feab2b75491c8913d2115998c | |
parent | c78d3769f13946f70fda1f642ce5a3907035fa21 (diff) | |
download | podman-9ab256f72aea15c76514cf29566cd227f4a0c9f5.tar.gz podman-9ab256f72aea15c76514cf29566cd227f4a0c9f5.tar.bz2 podman-9ab256f72aea15c76514cf29566cd227f4a0c9f5.zip |
Make database write in syncContainer conditional
This should help with performance when executing many operations
on a single container
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #185
Approved by: rhatdan
-rw-r--r-- | libpod/container.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libpod/container.go b/libpod/container.go index 18f3ca5ae..2b70afec2 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -412,11 +412,16 @@ func (c *Container) syncContainer() error { // And then save back to disk if (c.state.State != ContainerStateUnknown) && (c.state.State != ContainerStateConfigured) { + oldState := c.state.State + // TODO: optionally replace this with a stat for the exit file if err := c.runtime.ociRuntime.updateContainerStatus(c); err != nil { return err } - if err := c.save(); err != nil { - return err + // Only save back to DB if state changed + if c.state.State != oldState { + if err := c.save(); err != nil { + return err + } } } |