diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-12-09 01:46:55 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-01-07 14:49:44 +0100 |
commit | ca9edf1c6301ed1498a56124d018474a68d04b25 (patch) | |
tree | f44f3c7ba5c80c4eb559636fcca66697122ecdb5 /tun/wintun/dll_fromrsrc_windows.go | |
parent | 347ce76bbcc6d2351dc298a1c8ca5604534bebec (diff) |
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_fromrsrc_windows.go')
-rw-r--r-- | tun/wintun/dll_fromrsrc_windows.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tun/wintun/dll_fromrsrc_windows.go b/tun/wintun/dll_fromrsrc_windows.go index e6e393f..d107ba9 100644 --- a/tun/wintun/dll_fromrsrc_windows.go +++ b/tun/wintun/dll_fromrsrc_windows.go @@ -23,6 +23,7 @@ type lazyDLL struct { Name string mu sync.Mutex module *memmod.Module + onLoad func(d *lazyDLL) } func (d *lazyDLL) Load() error { @@ -50,6 +51,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 } |