diff options
Diffstat (limited to 'tun/tun_darwin.go')
-rw-r--r-- | tun/tun_darwin.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tun/tun_darwin.go b/tun/tun_darwin.go index 04020cb..f692bbe 100644 --- a/tun/tun_darwin.go +++ b/tun/tun_darwin.go @@ -7,14 +7,15 @@ package tun import ( - "git.zx2c4.com/wireguard-go/rwcancel" "errors" "fmt" + "git.zx2c4.com/wireguard-go/rwcancel" "golang.org/x/net/ipv6" "golang.org/x/sys/unix" "io/ioutil" "net" "os" + "syscall" "unsafe" ) @@ -54,8 +55,12 @@ func (tun *nativeTun) routineRouteListener(tunIfindex int) { data := make([]byte, os.Getpagesize()) for { + retry: n, err := unix.Read(tun.routeSocket, data) if err != nil { + if errno, ok := err.(syscall.Errno); ok && errno == syscall.EINTR { + goto retry + } tun.errors <- err return } @@ -259,7 +264,7 @@ func (tun *nativeTun) doRead(buff []byte, offset int) (int, error) { func (tun *nativeTun) Read(buff []byte, offset int) (int, error) { for { n, err := tun.doRead(buff, offset) - if err == nil || !rwcancel.ErrorIsEAGAIN(err) { + if err == nil || !rwcancel.RetryAfterError(err) { return n, err } if !tun.rwcancel.ReadyRead() { |