Skip to content

Commit

Permalink
Merge pull request shirou#487 from truthbk/fix-win-race
Browse files Browse the repository at this point in the history
[host] fix race condition to ret
  • Loading branch information
shirou authored Feb 13, 2018
2 parents c432be2 + 178e5ce commit 234a591
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cpu/cpu_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down

0 comments on commit 234a591

Please sign in to comment.