Prevent multiple parallel SystemDiskUsage call
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
parent
cf7d246ab0
commit
5a9f2a3ce6
2 changed files with 12 additions and 0 deletions
|
@ -111,6 +111,12 @@ type Daemon struct {
|
|||
|
||||
seccompProfile []byte
|
||||
seccompProfilePath string
|
||||
|
||||
diskUsageRunning int32
|
||||
containersPruneRunning int32
|
||||
volumesPruneRunning int32
|
||||
imagesPruneRunning int32
|
||||
networksPruneRunning int32
|
||||
}
|
||||
|
||||
// HasExperimental returns whether the experimental features of the daemon are enabled or not
|
||||
|
|
|
@ -2,6 +2,7 @@ package daemon
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sync/atomic"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
|
@ -37,6 +38,11 @@ func (daemon *Daemon) getLayerRefs() map[layer.ChainID]int {
|
|||
|
||||
// SystemDiskUsage returns information about the daemon data disk usage
|
||||
func (daemon *Daemon) SystemDiskUsage(ctx context.Context) (*types.DiskUsage, error) {
|
||||
if !atomic.CompareAndSwapInt32(&daemon.diskUsageRunning, 0, 1) {
|
||||
return nil, fmt.Errorf("a disk usage operation is already running")
|
||||
}
|
||||
defer atomic.StoreInt32(&daemon.diskUsageRunning, 0)
|
||||
|
||||
// Retrieve container list
|
||||
allContainers, err := daemon.Containers(&types.ContainerListOptions{
|
||||
Size: true,
|
||||
|
|
Loading…
Add table
Reference in a new issue