summaryrefslogtreecommitdiffstats
path: root/tun/wintun/dll_fromfile_windows.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-12-09 01:46:55 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-01-07 14:49:44 +0100
commitca9edf1c6301ed1498a56124d018474a68d04b25 (patch)
treef44f3c7ba5c80c4eb559636fcca66697122ecdb5 /tun/wintun/dll_fromfile_windows.go
parenttun/tuntest: make genICMPv4 allocate less (diff)
downloadwireguard-go-ca9edf1c6301ed1498a56124d018474a68d04b25.tar.xz
wireguard-go-ca9edf1c6301ed1498a56124d018474a68d04b25.zip
wintun: do not load dll in init()
This prevents linking to wintun.dll until it's actually needed, which should improve startup time. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tun/wintun/dll_fromfile_windows.go')
-rw-r--r--tun/wintun/dll_fromfile_windows.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/tun/wintun/dll_fromfile_windows.go b/tun/wintun/dll_fromfile_windows.go
index 525812b..f40f8b3 100644
--- a/tun/wintun/dll_fromfile_windows.go
+++ b/tun/wintun/dll_fromfile_windows.go
@@ -20,6 +20,7 @@ type lazyDLL struct {
Name string
mu sync.Mutex
module windows.Handle
+ onLoad func(d *lazyDLL)
}
func (d *lazyDLL) Load() error {
@@ -42,6 +43,9 @@ func (d *lazyDLL) Load() error {
}
atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(&d.module)), unsafe.Pointer(module))
+ if d.onLoad != nil {
+ d.onLoad(d)
+ }
return nil
}