summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-03-22 12:44:14 +0100
committerSimon Rozman <simon@rozman.si>2019-03-22 13:52:51 +0100
commita80db5e65e4c202bae184a32120017782549fdac (patch)
treee454e6cce4de7642e73ec9e1fdaec88cba80dd6c
parent9748a52073e247ece6110cf43f036beb940c80e4 (diff)
tun: windows: Make writing persistent too
Signed-off-by: Simon Rozman <simon@rozman.si>
-rw-r--r--tun/tun_windows.go32
1 files changed, 17 insertions, 15 deletions
diff --git a/tun/tun_windows.go b/tun/tun_windows.go
index ce6ec8c..9888e86 100644
--- a/tun/tun_windows.go
+++ b/tun/tun_windows.go
@@ -284,24 +284,26 @@ func (tun *NativeTun) Flush() error {
return nil
}
- // Get TUN data pipe.
- _, file, err := tun.getTUN()
- if err != nil {
- return err
- }
+ for {
+ // 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
+ // 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 err
+ return nil
}
- return nil
}
func (tun *NativeTun) putTunPacket(buff []byte) error {