--- /dev/null
+/* SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2017-2021 WireGuard LLC. All Rights Reserved.
+ */
+
+package rwcancel
+
+import "golang.org/x/sys/unix"
+
+func poll(fds []unix.PollFd, timeout int) (n int, err error) {
+ var ts *unix.Timespec
+ if timeout >= 0 {
+ ts = new(unix.Timespec)
+ *ts = unix.NsecToTimespec(int64(timeout) * 1e6)
+ }
+ return unix.Ppoll(fds, ts, nil)
+}
--- /dev/null
+//go:build !windows && !linux
+// +build !windows,!linux
+
+/* SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2017-2021 WireGuard LLC. All Rights Reserved.
+ */
+
+package rwcancel
+
+import "golang.org/x/sys/unix"
+
+func poll(fds []unix.PollFd, timeout int) (n int, err error) {
+ return unix.Poll(fds, timeout)
+}
pollFds := []unix.PollFd{{Fd: int32(rw.fd), Events: unix.POLLIN}, {Fd: closeFd, Events: unix.POLLIN}}
var err error
for {
- _, err = unix.Poll(pollFds, -1)
+ _, err = poll(pollFds, -1)
if err == nil || !RetryAfterError(err) {
break
}
pollFds := []unix.PollFd{{Fd: int32(rw.fd), Events: unix.POLLOUT}, {Fd: closeFd, Events: unix.POLLOUT}}
var err error
for {
- _, err = unix.Poll(pollFds, -1)
+ _, err = poll(pollFds, -1)
if err == nil || !RetryAfterError(err) {
break
}