Some checks failed
Release CLI / Pre-release build (push) Has been cancelled
Release CLI / Pre-release test (macos-12) (push) Has been cancelled
Release CLI / Pre-release test (ubuntu-22.04) (push) Has been cancelled
Release CLI / Pre-release test (windows-2022) (push) Has been cancelled
Release CLI / Release (push) Has been cancelled
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com> Signed-off-by: Adrian Cole <adrian@tetrate.io> Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com> Co-authored-by: Achille <achille.roussel@gmail.com> Co-authored-by: Adrian Cole <adrian@tetrate.io>
31 lines
733 B
Go
31 lines
733 B
Go
//go:build linux || darwin
|
|
|
|
package sysfs
|
|
|
|
import (
|
|
"net"
|
|
"syscall"
|
|
|
|
"github.com/tetratelabs/wazero/internal/platform"
|
|
)
|
|
|
|
const MSG_PEEK = syscall.MSG_PEEK
|
|
|
|
// recvfromPeek exposes syscall.Recvfrom with flag MSG_PEEK on POSIX systems.
|
|
func recvfromPeek(conn *net.TCPConn, p []byte) (n int, errno syscall.Errno) {
|
|
syscallConn, err := conn.SyscallConn()
|
|
if err != nil {
|
|
return 0, platform.UnwrapOSError(err)
|
|
}
|
|
|
|
// Prioritize the error from Recvfrom over Control
|
|
if controlErr := syscallConn.Control(func(fd uintptr) {
|
|
var recvfromErr error
|
|
n, _, recvfromErr = syscall.Recvfrom(int(fd), p, MSG_PEEK)
|
|
errno = platform.UnwrapOSError(recvfromErr)
|
|
}); errno == 0 {
|
|
errno = platform.UnwrapOSError(controlErr)
|
|
}
|
|
return
|
|
}
|