summaryrefslogtreecommitdiffstats
path: root/tun/tun_openbsd.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_openbsd.go
parentRemove old makefile artifact (diff)
downloadwireguard-go-2f2eca894744baef365aaa07554f56979159d988.tar.xz
wireguard-go-2f2eca894744baef365aaa07554f56979159d988.zip
Catch EINTR
Diffstat (limited to 'tun/tun_openbsd.go')
-rw-r--r--tun/tun_openbsd.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/tun/tun_openbsd.go b/tun/tun_openbsd.go
index 709b5cd..3c1878b 100644
--- a/tun/tun_openbsd.go
+++ b/tun/tun_openbsd.go
@@ -6,9 +6,9 @@
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"
@@ -46,8 +46,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
}
@@ -90,9 +94,7 @@ func (tun *nativeTun) routineRouteListener(tunIfindex int) {
func errorIsEBUSY(err error) bool {
if pe, ok := err.(*os.PathError); ok {
- if errno, ok := pe.Err.(syscall.Errno); ok && errno == syscall.EBUSY {
- return true
- }
+ err = pe.Err
}
if errno, ok := err.(syscall.Errno); ok && errno == syscall.EBUSY {
return true
@@ -237,7 +239,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() {