aboutsummaryrefslogtreecommitdiffstats
path: root/tun/tun_darwin.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-05-24 15:29:16 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-05-24 15:36:29 +0200
commit2f2eca894744baef365aaa07554f56979159d988 (patch)
tree56ecc658ff124222643a13ed9bd75c3a703e726b /tun/tun_darwin.go
parentRemove old makefile artifact (diff)
downloadwireguard-go-2f2eca894744baef365aaa07554f56979159d988.tar.xz
wireguard-go-2f2eca894744baef365aaa07554f56979159d988.zip
Catch EINTR
Diffstat (limited to 'tun/tun_darwin.go')
-rw-r--r--tun/tun_darwin.go9
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() {