浏览代码

Windows: Fix docker info not to SIGSEGV

Signed-off-by: John Howard <jhoward@microsoft.com>
John Howard 10 年之前
父节点
当前提交
4348ad68f8
共有 1 个文件被更改,包括 12 次插入5 次删除
  1. 12 5
      daemon/info.go

+ 12 - 5
daemon/info.go

@@ -62,16 +62,11 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
 		Images:             imgcount,
 		Driver:             daemon.GraphDriver().String(),
 		DriverStatus:       daemon.GraphDriver().Status(),
-		MemoryLimit:        daemon.SystemConfig().MemoryLimit,
-		SwapLimit:          daemon.SystemConfig().SwapLimit,
-		CpuCfsPeriod:       daemon.SystemConfig().CpuCfsPeriod,
-		CpuCfsQuota:        daemon.SystemConfig().CpuCfsQuota,
 		IPv4Forwarding:     !daemon.SystemConfig().IPv4ForwardingDisabled,
 		BridgeNfIptables:   !daemon.SystemConfig().BridgeNfCallIptablesDisabled,
 		BridgeNfIp6tables:  !daemon.SystemConfig().BridgeNfCallIp6tablesDisabled,
 		Debug:              os.Getenv("DEBUG") != "",
 		NFd:                fileutils.GetTotalUsedFds(),
-		OomKillDisable:     daemon.SystemConfig().OomKillDisable,
 		NGoroutines:        runtime.NumGoroutine(),
 		SystemTime:         time.Now().Format(time.RFC3339Nano),
 		ExecutionDriver:    daemon.ExecutionDriver().Name(),
@@ -90,6 +85,18 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
 		ExperimentalBuild:  utils.ExperimentalBuild(),
 	}
 
+	// TODO Windows. Refactor this more once sysinfo is refactored into
+	// platform specific code. On Windows, sysinfo.cgroupMemInfo and
+	// sysinfo.cgroupCpuInfo will be nil otherwise and cause a SIGSEGV if
+	// an attempt is made to access through them.
+	if runtime.GOOS != "windows" {
+		v.MemoryLimit = daemon.SystemConfig().MemoryLimit
+		v.SwapLimit = daemon.SystemConfig().SwapLimit
+		v.OomKillDisable = daemon.SystemConfig().OomKillDisable
+		v.CpuCfsPeriod = daemon.SystemConfig().CpuCfsPeriod
+		v.CpuCfsQuota = daemon.SystemConfig().CpuCfsQuota
+	}
+
 	if httpProxy := os.Getenv("http_proxy"); httpProxy != "" {
 		v.HttpProxy = httpProxy
 	}