| Index: src/pkg/syscall/dll_windows.go |
| =================================================================== |
| --- a/src/pkg/syscall/dll_windows.go |
| +++ b/src/pkg/syscall/dll_windows.go |
| @@ -6,6 +6,8 @@ |
| import ( |
| "sync" |
| + "sync/atomic" |
| + "unsafe" |
| ) |
| // DLLError describes reasons for DLL load failures. |
| @@ -166,7 +168,7 @@ |
| // Load loads DLL file d.Name into memory. It returns an error if fails. |
| // Load will not try to load DLL, if it is already loaded into memory. |
| func (d *LazyDLL) Load() error { |
| - if d.dll == nil { |
| + if atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&d.dll))) == nil { |
| d.mu.Lock() |
| defer d.mu.Unlock() |
| if d.dll == nil { |
| @@ -174,7 +176,7 @@ |
| if e != nil { |
| return e |
| } |
| - d.dll = dll |
| + atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(&d.dll)), unsafe.Pointer(dll)) |
| brainman 2012/11/07 03:50:03 I do not think you need to change that line. d.mu. |
| } |
| } |
| return nil |
| @@ -217,7 +219,7 @@ |
| // an error if search fails. Find will not search procedure, |
| // if it is already found and loaded into memory. |
| func (p *LazyProc) Find() error { |
| - if p.proc == nil { |
| + if atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&p.proc))) == nil { |
| p.mu.Lock() |
| defer p.mu.Unlock() |
| if p.proc == nil { |
| @@ -229,7 +231,7 @@ |
| if e != nil { |
| return e |
| } |
| - p.proc = proc |
| + atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(&p.proc)), unsafe.Pointer(proc)) |
| brainman 2012/11/07 03:50:03 Same. Do not change that line. |
| } |
| } |
| return nil |