1
0
mirror of https://git.zx2c4.com/wireguard-go synced 2024-11-15 01:05:15 +01:00

tun: windows: Make writing persistent too

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2019-03-22 12:44:14 +01:00
parent 9748a52073
commit a80db5e65e

View File

@ -284,24 +284,26 @@ func (tun *NativeTun) Flush() error {
return nil
}
// Get TUN data pipe.
_, file, err := tun.getTUN()
if err != nil {
return err
}
// Flush write buffer.
_, err = file.Write(tun.wrBuff.data[:tun.wrBuff.offset])
tun.wrBuff.packetNum = 0
tun.wrBuff.offset = 0
if err != nil {
if tun.shouldReopenHandle(err) {
tun.closeTUN()
return nil
for {
// Get TUN data pipe.
_, file, err := tun.getTUN()
if err != nil {
return err
}
return err
// Flush write buffer.
_, err = file.Write(tun.wrBuff.data[:tun.wrBuff.offset])
tun.wrBuff.packetNum = 0
tun.wrBuff.offset = 0
if err != nil {
if tun.shouldReopenHandle(err) {
tun.closeTUN()
continue
}
return err
}
return nil
}
return nil
}
func (tun *NativeTun) putTunPacket(buff []byte) error {