aboutsummaryrefslogtreecommitdiffstats
path: root/tun/tun_windows.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-03-22 16:45:03 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-22 16:45:58 -0600
commit52ec440d7977fad966002c3710ed9df957943407 (patch)
tree384a6b9c2f97c0528dccd1f908539987469197b0 /tun/tun_windows.go
parenttun: windows: Make adapter rename asynchronous (diff)
downloadwireguard-go-52ec440d7977fad966002c3710ed9df957943407.tar.xz
wireguard-go-52ec440d7977fad966002c3710ed9df957943407.zip
tun: windows: delete interface before deleting file handles
Diffstat (limited to 'tun/tun_windows.go')
-rw-r--r--tun/tun_windows.go13
1 files changed, 4 insertions, 9 deletions
diff --git a/tun/tun_windows.go b/tun/tun_windows.go
index 2d8364d..b7f9947 100644
--- a/tun/tun_windows.go
+++ b/tun/tun_windows.go
@@ -214,18 +214,13 @@ func (tun *NativeTun) Events() chan TUNEvent {
func (tun *NativeTun) Close() error {
tun.close = true
- err1 := tun.closeTUN()
-
if tun.events != nil {
close(tun.events)
}
-
- _, _, err2 := tun.wt.DeleteInterface(0)
- if err1 == nil {
- err1 = err2
- }
-
- return err1
+ /* We delete it first, before closing, so that the close operations don't hang with the concurrent read operation. */
+ _, _, err := tun.wt.DeleteInterface(0)
+ tun.closeTUN()
+ return err
}
func (tun *NativeTun) MTU() (int, error) {