瀏覽代碼

Fix a hang when shutting down Android (#772)

John Maguire 2 年之前
父節點
當前提交
85f5849d0b
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      overlay/tun_android.go

+ 3 - 1
overlay/tun_android.go

@@ -28,11 +28,13 @@ func newTunFromFd(l *logrus.Logger, deviceFd int, cidr *net.IPNet, _ int, routes
 		return nil, err
 	}
 
+	// XXX Android returns an fd in non-blocking mode which is necessary for shutdown to work properly.
+	// Be sure not to call file.Fd() as it will set the fd to blocking mode.
 	file := os.NewFile(uintptr(deviceFd), "/dev/net/tun")
 
 	return &tun{
 		ReadWriteCloser: file,
-		fd:              int(file.Fd()),
+		fd:              deviceFd,
 		cidr:            cidr,
 		l:               l,
 		routeTree:       routeTree,