wintun: Simplify Read method()

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2019-02-08 14:31:05 +01:00
parent 713477cfb1
commit f05f52637f

View file

@ -203,8 +203,9 @@ func (tun *nativeTun) Read(buff []byte, offset int) (int, error) {
select { select {
case err := <-tun.errors: case err := <-tun.errors:
return 0, err return 0, err
default: default:
}
for { for {
if tun.rdNextPacket < tun.rdBuff.numPackets { if tun.rdNextPacket < tun.rdBuff.numPackets {
// Get packet from the queue. // Get packet from the queue.
@ -262,7 +263,6 @@ func (tun *nativeTun) Read(buff []byte, offset int) (int, error) {
continue continue
} }
} }
}
} }
// Note: flush() and putTunPacket() assume the caller comes only from a single thread; there's no locking. // Note: flush() and putTunPacket() assume the caller comes only from a single thread; there's no locking.