Browse Source

Merge pull request #1556 from sanimej/nilsb

Add a nil check before accessing sandbox.osSbox
Madhu Venugopal 8 năm trước cách đây
mục cha
commit
e3d20c50d7
1 tập tin đã thay đổi với 7 bổ sung1 xóa
  1. 7 1
      libnetwork/sandbox.go

+ 7 - 1
libnetwork/sandbox.go

@@ -427,7 +427,13 @@ func (sb *sandbox) ResolveIP(ip string) string {
 }
 
 func (sb *sandbox) ExecFunc(f func()) error {
-	return sb.osSbox.InvokeFunc(f)
+	sb.Lock()
+	osSbox := sb.osSbox
+	sb.Unlock()
+	if osSbox != nil {
+		return osSbox.InvokeFunc(f)
+	}
+	return fmt.Errorf("osl sandbox unavailable in ExecFunc for %v", sb.ContainerID())
 }
 
 func (sb *sandbox) ResolveService(name string) ([]*net.SRV, []net.IP) {