aboutsummaryrefslogtreecommitdiffstats
path: root/tun/tun_windows.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-07-05 07:54:25 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-07-05 14:17:48 +0200
commit5c3d333f10c7238cae9b8ed1aabdb8c8ab6a7ebc (patch)
tree40662d471602887150a8b5329f59e1754b57139c /tun/tun_windows.go
parenttun: windows: decrease alignment to 4 (diff)
downloadwireguard-go-5c3d333f10c7238cae9b8ed1aabdb8c8ab6a7ebc.tar.xz
wireguard-go-5c3d333f10c7238cae9b8ed1aabdb8c8ab6a7ebc.zip
tun: windows: registration of write buffer no longer required
Diffstat (limited to '')
-rw-r--r--tun/tun_windows.go13
1 files changed, 1 insertions, 12 deletions
diff --git a/tun/tun_windows.go b/tun/tun_windows.go
index f0acc09..4ae5cf0 100644
--- a/tun/tun_windows.go
+++ b/tun/tun_windows.go
@@ -11,11 +11,11 @@ import (
"io"
"os"
"sync"
- "sync/atomic"
"time"
"unsafe"
"golang.org/x/sys/windows"
+
"golang.zx2c4.com/wireguard/tun/wintun"
)
@@ -42,7 +42,6 @@ type NativeTun struct {
wt *wintun.Wintun
tunFileRead *os.File
tunFileWrite *os.File
- haveRegisteredWriteBuffer int32
tunLock sync.Mutex
close bool
rdBuff *exchgBufRead
@@ -142,7 +141,6 @@ func (tun *NativeTun) openTUN() error {
}
return err
}
- atomic.StoreInt32(&tun.haveRegisteredWriteBuffer, 0)
}
return nil
}
@@ -321,15 +319,6 @@ func (tun *NativeTun) Flush() error {
return err
}
- if atomic.CompareAndSwapInt32(&tun.haveRegisteredWriteBuffer, 0, 1) {
- firstSize := (*uint32)(unsafe.Pointer(&tun.wrBuff.data[0]))
- saved := *firstSize
- *firstSize = 0
- // Set the maximum buffer length with an invalid write.
- tun.tunFileWrite.Write(tun.wrBuff.data[:])
- *firstSize = saved
- }
-
for {
_, err = file.Write(tun.wrBuff.data[:tun.wrBuff.offset])
if err != nil {