@@ -36,10 +36,10 @@ func (daemon *Daemon) ContainerInspectCurrent(name string, size bool) (*types.Co
3636 }
3737
3838 container .Lock ()
39- defer container .Unlock ()
4039
41- base , err := daemon .getInspectData (container , size )
40+ base , err := daemon .getInspectData (container )
4241 if err != nil {
42+ container .Unlock ()
4343 return nil , err
4444 }
4545
@@ -73,6 +73,14 @@ func (daemon *Daemon) ContainerInspectCurrent(name string, size bool) (*types.Co
7373 }
7474 networkSettings .NetworkSettingsBase .Ports = ports
7575
76+ container .Unlock ()
77+
78+ if size {
79+ sizeRw , sizeRootFs := daemon .getSize (base .ID )
80+ base .SizeRw = & sizeRw
81+ base .SizeRootFs = & sizeRootFs
82+ }
83+
7684 return & types.ContainerJSON {
7785 ContainerJSONBase : base ,
7886 Mounts : mountPoints ,
@@ -91,7 +99,7 @@ func (daemon *Daemon) containerInspect120(name string) (*v1p20.ContainerJSON, er
9199 container .Lock ()
92100 defer container .Unlock ()
93101
94- base , err := daemon .getInspectData (container , false )
102+ base , err := daemon .getInspectData (container )
95103 if err != nil {
96104 return nil , err
97105 }
@@ -114,7 +122,7 @@ func (daemon *Daemon) containerInspect120(name string) (*v1p20.ContainerJSON, er
114122 }, nil
115123}
116124
117- func (daemon * Daemon ) getInspectData (container * container.Container , size bool ) (* types.ContainerJSONBase , error ) {
125+ func (daemon * Daemon ) getInspectData (container * container.Container ) (* types.ContainerJSONBase , error ) {
118126 // make a copy to play with
119127 hostConfig := * container .HostConfig
120128
@@ -168,16 +176,6 @@ func (daemon *Daemon) getInspectData(container *container.Container, size bool)
168176 HostConfig : & hostConfig ,
169177 }
170178
171- var (
172- sizeRw int64
173- sizeRootFs int64
174- )
175- if size {
176- sizeRw , sizeRootFs = daemon .getSize (container )
177- contJSONBase .SizeRw = & sizeRw
178- contJSONBase .SizeRootFs = & sizeRootFs
179- }
180-
181179 // Now set any platform-specific fields
182180 contJSONBase = setPlatformSpecificContainerFields (container , contJSONBase )
183181
0 commit comments