From 178e5ce997a611592ed881b61258d6dd6e03e555 Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Mon, 12 Feb 2018 15:04:20 +0100 Subject: [PATCH] [host] fix race condition to ret --- cpu/cpu_windows.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cpu/cpu_windows.go b/cpu/cpu_windows.go index af65721f..a95df9f8 100644 --- a/cpu/cpu_windows.go +++ b/cpu/cpu_windows.go @@ -132,6 +132,10 @@ func PerfInfoWithContext(ctx context.Context) ([]Win32_PerfFormattedData_Counter ctx, cancel := context.WithTimeout(context.Background(), common.Timeout) defer cancel() err := common.WMIQueryWithContext(ctx, q, &ret) + if err != nil { + return Win32_PerfFormattedData_Counters_ProcessorInformation{}, err + } + return ret, err } @@ -147,6 +151,9 @@ func ProcInfoWithContext(ctx context.Context) ([]Win32_PerfFormattedData_PerfOS_ ctx, cancel := context.WithTimeout(context.Background(), common.Timeout) defer cancel() err := common.WMIQueryWithContext(ctx, q, &ret) + if err != nil { + return Win32_PerfFormattedData_PerfOS_System{}, err + } return ret, err }