Browse code

Windows: Avoid concurrent access to sysinfo

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2016/11/09 10:52:38
Showing 1 changed files
... ...
@@ -34,10 +34,9 @@ const (
34 34
 	ProcessorArchitectureArm  = 5 // PROCESSOR_ARCHITECTURE_ARM
35 35
 )
36 36
 
37
-var sysinfo systeminfo
38
-
39 37
 // runtimeArchitecture gets the name of the current architecture (x86, x86_64, …)
40 38
 func runtimeArchitecture() (string, error) {
39
+	var sysinfo systeminfo
41 40
 	syscall.Syscall(procGetSystemInfo.Addr(), 1, uintptr(unsafe.Pointer(&sysinfo)), 0, 0)
42 41
 	switch sysinfo.wProcessorArchitecture {
43 42
 	case ProcessorArchitecture64, ProcessorArchitectureIA64:
... ...
@@ -53,6 +52,7 @@ func runtimeArchitecture() (string, error) {
53 53
 
54 54
 // NumProcs returns the number of processors on the system
55 55
 func NumProcs() uint32 {
56
+	var sysinfo systeminfo
56 57
 	syscall.Syscall(procGetSystemInfo.Addr(), 1, uintptr(unsafe.Pointer(&sysinfo)), 0, 0)
57 58
 	return sysinfo.dwNumberOfProcessors
58 59
 }