Commit 381f6a2e authored by Dmitriy Vyukov's avatar Dmitriy Vyukov Committed by Andrew Gerrand

syscall: make LazyDLL/LazyProc.Mutex unexported

They are seemingly not intended to be a part
of the public interface.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4873052
parent 00dd2b4a
...@@ -90,7 +90,7 @@ func getprocaddress(handle uintptr, procname uintptr) (proc uintptr) ...@@ -90,7 +90,7 @@ func getprocaddress(handle uintptr, procname uintptr) (proc uintptr)
// call to its Handle method or to one of its // call to its Handle method or to one of its
// LazyProc's Addr method. // LazyProc's Addr method.
type LazyDLL struct { type LazyDLL struct {
sync.Mutex mu sync.Mutex
Name string Name string
h uintptr // module handle once dll is loaded h uintptr // module handle once dll is loaded
} }
...@@ -98,8 +98,8 @@ type LazyDLL struct { ...@@ -98,8 +98,8 @@ type LazyDLL struct {
// Handle returns d's module handle. // Handle returns d's module handle.
func (d *LazyDLL) Handle() uintptr { func (d *LazyDLL) Handle() uintptr {
if d.h == 0 { if d.h == 0 {
d.Lock() d.mu.Lock()
defer d.Unlock() defer d.mu.Unlock()
if d.h == 0 { if d.h == 0 {
d.h = loadlibraryex(uintptr(unsafe.Pointer(StringBytePtr(d.Name)))) d.h = loadlibraryex(uintptr(unsafe.Pointer(StringBytePtr(d.Name))))
if d.h == 0 { if d.h == 0 {
...@@ -123,7 +123,7 @@ func NewLazyDLL(name string) *LazyDLL { ...@@ -123,7 +123,7 @@ func NewLazyDLL(name string) *LazyDLL {
// A LazyProc implements access to a procedure inside a LazyDLL. // A LazyProc implements access to a procedure inside a LazyDLL.
// It delays the lookup until the Addr method is called. // It delays the lookup until the Addr method is called.
type LazyProc struct { type LazyProc struct {
sync.Mutex mu sync.Mutex
Name string Name string
dll *LazyDLL dll *LazyDLL
addr uintptr addr uintptr
...@@ -133,8 +133,8 @@ type LazyProc struct { ...@@ -133,8 +133,8 @@ type LazyProc struct {
// The return value can be passed to Syscall to run the procedure. // The return value can be passed to Syscall to run the procedure.
func (s *LazyProc) Addr() uintptr { func (s *LazyProc) Addr() uintptr {
if s.addr == 0 { if s.addr == 0 {
s.Lock() s.mu.Lock()
defer s.Unlock() defer s.mu.Unlock()
if s.addr == 0 { if s.addr == 0 {
s.addr = getprocaddress(s.dll.Handle(), uintptr(unsafe.Pointer(StringBytePtr(s.Name)))) s.addr = getprocaddress(s.dll.Handle(), uintptr(unsafe.Pointer(StringBytePtr(s.Name))))
if s.addr == 0 { if s.addr == 0 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment