poll

Imports

Imports #

"internal/byteorder"
"sync/atomic"
"syscall"
"unsafe"
"syscall"
_ "unsafe"
"io"
"runtime"
"syscall"
"syscall"
"syscall"
"syscall"
"internal/itoa"
"runtime"
"sync"
"syscall"
"errors"
"internal/stringslite"
"io"
"sync"
"syscall"
"time"
"internal/syscall/unix"
"syscall"
"syscall"
"syscall"
"time"
"io"
"syscall"
"syscall"
"unsafe"
"syscall"
"syscall"
"syscall"
"errors"
"errors"
"internal/syscall/unix"
"syscall"
"syscall"
"internal/itoa"
"internal/syscall/unix"
"io"
"sync/atomic"
"syscall"
"io"
"syscall"
"syscall"
"sync/atomic"
"syscall"
"internal/syscall/unix"
"runtime"
"sync"
"syscall"
"unsafe"
"io"
"runtime"
"syscall"
"internal/syscall/unix"
"syscall"
"errors"
"internal/race"
"internal/syscall/windows"
"io"
"sync"
"syscall"
"unicode/utf16"
"unicode/utf8"
"unsafe"
"internal/syscall/unix"
"syscall"
_ "unsafe"
"errors"
"sync"
"syscall"
"time"
_ "unsafe"
"syscall"
"internal/syscall/unix"
"sync"
"syscall"
"syscall"
"unsafe"
"syscall"
"syscall"
"syscall"
"syscall"
"syscall"

Constants & Variables

Accept4Func var #

Accept4Func is used to hook the accept4 call.

var Accept4Func func(int, int) (int, syscall.Sockaddr, error) = syscall.Accept4

AcceptFunc var #

AcceptFunc is used to hook the accept call.

var AcceptFunc func(int) (int, syscall.Sockaddr, error) = syscall.Accept

AcceptFunc var #

AcceptFunc is used to hook the accept call.

var AcceptFunc func(syscall.Handle, syscall.Handle, *byte, uint32, uint32, uint32, *uint32, *syscall.Overlapped) error = syscall.AcceptEx

CloseFunc var #

CloseFunc is used to hook the close call.

var CloseFunc func(int) error = syscall.Close

CloseFunc var #

CloseFunc is used to hook the close call.

var CloseFunc func(syscall.Handle) error = syscall.Closesocket

ConnectExFunc var #

ConnectExFunc is used to hook the ConnectEx call.

var ConnectExFunc func(syscall.Handle, syscall.Sockaddr, *byte, uint32, *uint32, *syscall.Overlapped) error = syscall.ConnectEx

ErrDeadlineExceeded var #

ErrDeadlineExceeded is returned for an expired deadline. This is exported by the os package as os.ErrDeadlineExceeded.

var ErrDeadlineExceeded error = *ast.UnaryExpr

ErrFileClosing var #

ErrFileClosing is returned when a file descriptor is used after it has been closed.

var ErrFileClosing = *ast.CallExpr

ErrNetClosing var #

ErrNetClosing is returned when a network descriptor is used after it has been closed.

var ErrNetClosing = errNetClosing{...}

ErrNoDeadline var #

ErrNoDeadline is returned when a request is made to set a deadline on a file type that does not use the poller.

var ErrNoDeadline = *ast.CallExpr

ErrNotPollable var #

ErrNotPollable is returned when the file or socket is not suitable for event notification.

var ErrNotPollable = *ast.CallExpr

InitWSA var #

InitWSA initiates the use of the Winsock DLL by the current process. It is called from the net package at init time to avoid loading ws2_32.dll when net is not used.

var InitWSA = *ast.CallExpr

ReadConsole var #

var ReadConsole = syscall.ReadConsole

TestHookDidSendFile var #

var TestHookDidSendFile = *ast.FuncLit

TestHookDidWritev var #

TestHookDidWritev is a hook for testing writev.

var TestHookDidWritev = *ast.FuncLit

dupCloexecUnsupported var #

dupCloexecUnsupported indicates whether F_DUPFD_CLOEXEC is supported by the kernel.

var dupCloexecUnsupported atomic.Bool

errEAGAIN var #

Do the interface allocations only once for common Errno values.

var errEAGAIN error = syscall.EAGAIN

errEINVAL var #

Do the interface allocations only once for common Errno values.

var errEINVAL error = syscall.EINVAL

errENOENT var #

Do the interface allocations only once for common Errno values.

var errENOENT error = syscall.ENOENT

errERROR_IO_PENDING var #

var errERROR_IO_PENDING error = *ast.CallExpr

initErr var #

var initErr error

ioSync var #

var ioSync uint64

isKernelVersionGE53 var #

var isKernelVersionGE53 = *ast.CallExpr

kindConsole const #

const kindConsole

kindFile const #

const kindFile

kindNet const #

const kindNet fileKind = iota

kindPipe const #

const kindPipe

logInitFD var #

logInitFD is set by tests to enable file descriptor initialization logging.

var logInitFD func(net string, fd *FD, err error)

maxCopyFileRangeRound const #

For best performance, call copy_file_range() with the largest len value possible. Linux sets up a limitation of data transfer for most of its I/O system calls, as MAX_RW_COUNT (INT_MAX & PAGE_MASK). This value equals to the maximum integer value minus a page size that is typically 2^12=4096 bytes. That is to say, it's the maximum integer value with the lowest 12 bits unset, which is 0x7ffff000.

const maxCopyFileRangeRound = 0x7ffff000

maxCopyFileRangeRound const #

For best performance, call copy_file_range() with the largest len value possible. It is interruptible on most file systems, so there is no penalty for using very large len values, even SSIZE_MAX.

const maxCopyFileRangeRound = *ast.BinaryExpr

maxRW const #

Darwin and FreeBSD can't read or write 2GB+ files at a time, even on 64-bit systems. The same is true of socket implementations on many systems. See golang.org/issue/7812 and golang.org/issue/16266. Use 1GB instead of, say, 2GB-1, to keep subsequent reads aligned.

const maxRW = *ast.BinaryExpr

maxRW const #

Windows ReadFile and WSARecv use DWORD (uint32) parameter to pass buffer length. This prevents us reading blocks larger than 4GB. See golang.org/issue/26923.

const maxRW = *ast.BinaryExpr

maxSpliceSize const #

maxSpliceSize is the maximum amount of data Splice asks the kernel to move in a single call to splice(2). We use 1MB as Splice writes data through a pipe, and 1MB is the default maximum pipe buffer size, which is determined by /proc/sys/fs/pipe-max-size.

const maxSpliceSize = *ast.BinaryExpr

mutexClosed const #

fdMutex.state is organized as follows: 1 bit - whether FD is closed, if set all subsequent lock operations will fail. 1 bit - lock for read operations. 1 bit - lock for write operations. 20 bits - total number of references (read+write+misc). 20 bits - number of outstanding read waiters. 20 bits - number of outstanding write waiters.

const mutexClosed = *ast.BinaryExpr

mutexRLock const #

fdMutex.state is organized as follows: 1 bit - whether FD is closed, if set all subsequent lock operations will fail. 1 bit - lock for read operations. 1 bit - lock for write operations. 20 bits - total number of references (read+write+misc). 20 bits - number of outstanding read waiters. 20 bits - number of outstanding write waiters.

const mutexRLock = *ast.BinaryExpr

mutexRMask const #

fdMutex.state is organized as follows: 1 bit - whether FD is closed, if set all subsequent lock operations will fail. 1 bit - lock for read operations. 1 bit - lock for write operations. 20 bits - total number of references (read+write+misc). 20 bits - number of outstanding read waiters. 20 bits - number of outstanding write waiters.

const mutexRMask = *ast.BinaryExpr

mutexRWait const #

fdMutex.state is organized as follows: 1 bit - whether FD is closed, if set all subsequent lock operations will fail. 1 bit - lock for read operations. 1 bit - lock for write operations. 20 bits - total number of references (read+write+misc). 20 bits - number of outstanding read waiters. 20 bits - number of outstanding write waiters.

const mutexRWait = *ast.BinaryExpr

mutexRef const #

fdMutex.state is organized as follows: 1 bit - whether FD is closed, if set all subsequent lock operations will fail. 1 bit - lock for read operations. 1 bit - lock for write operations. 20 bits - total number of references (read+write+misc). 20 bits - number of outstanding read waiters. 20 bits - number of outstanding write waiters.

const mutexRef = *ast.BinaryExpr

mutexRefMask const #

fdMutex.state is organized as follows: 1 bit - whether FD is closed, if set all subsequent lock operations will fail. 1 bit - lock for read operations. 1 bit - lock for write operations. 20 bits - total number of references (read+write+misc). 20 bits - number of outstanding read waiters. 20 bits - number of outstanding write waiters.

const mutexRefMask = *ast.BinaryExpr

mutexWLock const #

fdMutex.state is organized as follows: 1 bit - whether FD is closed, if set all subsequent lock operations will fail. 1 bit - lock for read operations. 1 bit - lock for write operations. 20 bits - total number of references (read+write+misc). 20 bits - number of outstanding read waiters. 20 bits - number of outstanding write waiters.

const mutexWLock = *ast.BinaryExpr

mutexWMask const #

fdMutex.state is organized as follows: 1 bit - whether FD is closed, if set all subsequent lock operations will fail. 1 bit - lock for read operations. 1 bit - lock for write operations. 20 bits - total number of references (read+write+misc). 20 bits - number of outstanding read waiters. 20 bits - number of outstanding write waiters.

const mutexWMask = *ast.BinaryExpr

mutexWWait const #

fdMutex.state is organized as follows: 1 bit - whether FD is closed, if set all subsequent lock operations will fail. 1 bit - lock for read operations. 1 bit - lock for write operations. 20 bits - total number of references (read+write+misc). 20 bits - number of outstanding read waiters. 20 bits - number of outstanding write waiters.

const mutexWWait = *ast.BinaryExpr

overflowMsg const #

const overflowMsg = "too many concurrent operations on a single file or socket (max 1048575)"

pollErrClosing const #

Error values returned by runtime_pollReset and runtime_pollWait. These must match the values in runtime/netpoll.go.

const pollErrClosing = 1

pollErrNotPollable const #

Error values returned by runtime_pollReset and runtime_pollWait. These must match the values in runtime/netpoll.go.

const pollErrNotPollable = 3

pollErrTimeout const #

Error values returned by runtime_pollReset and runtime_pollWait. These must match the values in runtime/netpoll.go.

const pollErrTimeout = 2

pollNoError const #

Error values returned by runtime_pollReset and runtime_pollWait. These must match the values in runtime/netpoll.go.

const pollNoError = 0

serverInit var #

var serverInit sync.Once

sizeOfDirent const #

https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#-dirent-record

const sizeOfDirent = 24

spliceNonblock const #

spliceNonblock doesn't make the splice itself necessarily nonblocking (because the actual file descriptors that are spliced from/to may block unless they have the O_NONBLOCK flag set), but it makes the splice pipe operations nonblocking.

const spliceNonblock = 0x2

splicePipePool var #

splicePipePool caches pipes to avoid high-frequency construction and destruction of pipe buffers. The garbage collector will free all pipes in the sync.Pool periodically, thus we need to set up a finalizer for each pipe to close its file descriptors before the actual GC.

var splicePipePool = sync.Pool{...}

useSetFileCompletionNotificationModes var #

var useSetFileCompletionNotificationModes bool

Type Aliases

String type #

String is an internal string definition for methods/functions that is not intended for use outside the standard libraries. Other packages in std that import internal/poll and have some exported APIs (now we've got some in net.rawConn) which are only used internally and are not intended to be used outside the standard libraries, Therefore, we make those APIs use internal types like poll.FD or poll.String in their function signatures to disable the usability of these APIs from external codebase.

type String string

fileKind type #

fileKind describes the kind of file.

type fileKind byte

Structs

DeadlineExceededError struct #

DeadlineExceededError is returned for an expired deadline.

type DeadlineExceededError struct {

}

FD struct #

FD is a file descriptor. The net and os packages embed this type in a larger type representing a network connection or OS file.

type FD struct {
fdmu fdMutex
Sysfd syscall.Handle
rop operation
wop operation
pd pollDesc
l sync.Mutex
lastbits []byte
readuint16 []uint16
readbyte []byte
readbyteOffset int
csema uint32
skipSyncNotif bool
IsStream bool
ZeroReadIsEOF bool
isFile bool
kind fileKind
}

FD struct #

FD is a file descriptor. The net and os packages use this type as a field of a larger type representing a network connection or OS file.

type FD struct {
fdmu fdMutex
Sysfd int
SysFile
pd pollDesc
csema uint32
isBlocking uint32
IsStream bool
ZeroReadIsEOF bool
isFile bool
}

FD struct #

type FD struct {
fdmu fdMutex
Destroy func()
rmu sync.Mutex
wmu sync.Mutex
raio *asyncIO
waio *asyncIO
rtimer *time.Timer
wtimer *time.Timer
rtimedout bool
wtimedout bool
isFile bool
}

FDMutex struct #

FDMutex is an exported fdMutex, only for Plan 9.

type FDMutex struct {
fdmu fdMutex
}

SysFile struct #

type SysFile struct {
RefCountPtr *int32
RefCount int32
Filetype uint32
Dircookie uint64
Path string
}

SysFile struct #

type SysFile struct {
iovecs *[]syscall.Iovec
}

asyncIO struct #

asyncIO implements asynchronous cancelable I/O. An asyncIO represents a single asynchronous Read or Write operation. The result is returned on the result channel. The undergoing I/O system call can either complete or be interrupted by a note.

type asyncIO struct {
res chan result
mu sync.Mutex
pid int
}

errNetClosing struct #

errNetClosing is the type of the variable ErrNetClosing. This is used to implement the net.Error interface.

type errNetClosing struct {

}

fdMutex struct #

fdMutex is a specialized synchronization primitive that manages lifetime of an fd and serializes access to Read, Write and Close methods on FD.

type fdMutex struct {
state uint64
rsema uint32
wsema uint32
}

operation struct #

operation contains superset of data necessary to perform all async IO.

type operation struct {
o syscall.Overlapped
runtimeCtx uintptr
mode int32
fd *FD
buf syscall.WSABuf
msg windows.WSAMsg
sa syscall.Sockaddr
rsa *syscall.RawSockaddrAny
rsan int32
handle syscall.Handle
flags uint32
qty uint32
bufs []syscall.WSABuf
}

pollDesc struct #

type pollDesc struct {
fd *FD
closing bool
}

pollDesc struct #

type pollDesc struct {
runtimeCtx uintptr
}

result struct #

result is the return value of a Read or Write operation.

type result struct {
n int
err error
}

splicePipe struct #

type splicePipe struct {
splicePipeFields
_ [*ast.BinaryExpr]byte
}

splicePipeFields struct #

type splicePipeFields struct {
rfd int
wfd int
data int
}

Functions

Accept method #

Accept wraps the accept network call.

func (fd *FD) Accept() (int, syscall.Sockaddr, string, error)

Accept method #

Accept handles accepting a socket. The sysSocket parameter is used to allocate the net socket.

func (fd *FD) Accept(sysSocket func() (syscall.Handle, error)) (syscall.Handle, []syscall.RawSockaddrAny, uint32, string, error)

Cancel method #

Cancel interrupts the I/O operation, causing the Wait function to return.

func (aio *asyncIO) Cancel()

ClearBufs method #

ClearBufs clears all pointers to Buffers parameter captured by InitBufs, so it can be released by garbage collector.

func (o *operation) ClearBufs()

Close method #

Close closes the FD. The underlying file descriptor is closed by the destroy method when there are no remaining references.

func (fd *FD) Close() error

Close method #

Close closes the FD. The underlying file descriptor is closed by the destroy method when there are no remaining references.

func (fd *FD) Close() error

Close method #

Close handles the locking for closing an FD. The real operation is in the net package.

func (fd *FD) Close() error

ConnectEx method #

Call ConnectEx. This doesn't need any locking, since it is only called when the descriptor is first created. This is here rather than in the net package so that it can use fd.wop.

func (fd *FD) ConnectEx(ra syscall.Sockaddr) error

Copy method #

Copy creates a copy of the FD. The FD instance points to the same underlying file descriptor. The file descriptor isn't closed until all FD instances that refer to it have been closed/destroyed.

func (fd *FD) Copy() FD

CopyFileRange function #

CopyFileRange copies at most remain bytes of data from src to dst, using the copy_file_range system call. dst and src must refer to regular files.

func CopyFileRange(dst *FD, src *FD, remain int64) (written int64, handled bool, err error)

Decref method #

func (fdmu *FDMutex) Decref() bool

Dup method #

Dup duplicates the file descriptor.

func (fd *FD) Dup() (int, string, error)

DupCloseOnExec function #

func DupCloseOnExec(fd int) (int, string, error)

DupCloseOnExec function #

DupCloseOnExec dups fd and marks it close-on-exec.

func DupCloseOnExec(fd int) (int, string, error)

DupCloseOnExec function #

func DupCloseOnExec(fd int) (int, string, error)

Error method #

Error returns the error message for ErrNetClosing. Keep this string consistent because of issue #4373: since historically programs have not been able to detect this error, they look for the string.

func (e errNetClosing) Error() string

Error method #

Implement the net.Error interface. The string is "i/o timeout" because that is what was returned by earlier Go versions. Changing it may break programs that match on error strings.

func (e *DeadlineExceededError) Error() string

Fchdir method #

Fchdir wraps syscall.Fchdir.

func (fd *FD) Fchdir() error

Fchdir method #

Fchdir wraps syscall.Fchdir.

func (fd *FD) Fchdir() error

Fchdir method #

Fchdir wraps syscall.Fchdir.

func (fd *FD) Fchdir() error

Fchmod method #

Fchmod updates syscall.ByHandleFileInformation.Fileattributes when needed.

func (fd *FD) Fchmod(mode uint32) error

Fchmod method #

Fchmod wraps syscall.Fchmod.

func (fd *FD) Fchmod(mode uint32) error

Fchown method #

Fchown wraps syscall.Fchown.

func (fd *FD) Fchown(uid int, gid int) error

Fstat method #

Fstat wraps syscall.Fstat

func (fd *FD) Fstat(s *syscall.Stat_t) error

Fsync method #

Fsync wraps syscall.Fsync.

func (fd *FD) Fsync() error

Fsync method #

Fsync invokes SYS_FCNTL with SYS_FULLFSYNC because on OS X, SYS_FSYNC doesn't fully flush contents to disk. See Issue #26650 as well as the man page for fsync on OS X.

func (fd *FD) Fsync() error

Fsync method #

Fsync wraps syscall.Fsync.

func (fd *FD) Fsync() error

Ftruncate method #

Ftruncate wraps syscall.Ftruncate.

func (fd *FD) Ftruncate(size int64) error

GetFileInformationByHandle method #

GetFileInformationByHandle wraps GetFileInformationByHandle.

func (fd *FD) GetFileInformationByHandle(data *syscall.ByHandleFileInformation) error

GetFileType method #

GetFileType wraps syscall.GetFileType.

func (fd *FD) GetFileType() (uint32, error)

GetsockoptInt method #

GetsockoptInt wraps the getsockopt network call with an int argument.

func (fd *FD) GetsockoptInt(level int, name int) (int, error)

Incref method #

func (fdmu *FDMutex) Incref() bool

IncrefAndClose method #

func (fdmu *FDMutex) IncrefAndClose() bool

Init method #

Init initializes the FD. The Sysfd field should already be set. This can be called multiple times on a single FD. The net argument is a network name from the net package (e.g., "tcp"), or "file" or "console" or "dir". Set pollable to true if fd should be managed by runtime netpoll.

func (fd *FD) Init(net string, pollable bool) (string, error)

Init method #

Init initializes the FD. The Sysfd field should already be set. This can be called multiple times on a single FD. The net argument is a network name from the net package (e.g., "tcp"), or "file". Set pollable to true if fd should be managed by runtime netpoll.

func (fd *FD) Init(net string, pollable bool) error

InitBuf method #

func (o *operation) InitBuf(buf []byte)

InitBufs method #

func (o *operation) InitBufs(buf *[][]byte)

InitMsg method #

func (o *operation) InitMsg(p []byte, oob []byte)

IsPollDescriptor function #

IsPollDescriptor reports whether fd is the descriptor being used by the poller. This is only used for testing.

func IsPollDescriptor(fd uintptr) bool

IsPollDescriptor function #

IsPollDescriptor reports whether fd is the descriptor being used by the poller. This is only used for testing.

func IsPollDescriptor(fd uintptr) bool

IsPollDescriptor function #

IsPollDescriptor reports whether fd is the descriptor being used by the poller. This is only used for testing. IsPollDescriptor should be an internal detail, but widely used packages access it using linkname. Notable members of the hall of shame include: - github.com/opencontainers/runc Do not remove or change the type signature. See go.dev/issue/67401. go:linkname IsPollDescriptor

func IsPollDescriptor(fd uintptr) bool

OpenDir method #

OpenDir returns a pointer to a DIR structure suitable for ReadDir. In case of an error, the name of the failed syscall is returned along with a syscall.Errno.

func (fd *FD) OpenDir() (uintptr, string, error)

Pread method #

Pread emulates the Unix pread system call.

func (fd *FD) Pread(b []byte, off int64) (int, error)

Pread method #

Pread wraps the pread system call.

func (fd *FD) Pread(p []byte, off int64) (int, error)

Pwrite method #

Pwrite wraps the pwrite system call.

func (fd *FD) Pwrite(p []byte, off int64) (int, error)

Pwrite method #

Pwrite emulates the Unix pwrite system call.

func (fd *FD) Pwrite(buf []byte, off int64) (int, error)

RawControl method #

RawControl invokes the user-defined function f for a non-IO operation.

func (fd *FD) RawControl(f func(uintptr)) error

RawControl method #

RawControl invokes the user-defined function f for a non-IO operation.

func (fd *FD) RawControl(f func(uintptr)) error

RawRead method #

RawRead invokes the user-defined function f for a read operation.

func (fd *FD) RawRead(f func(uintptr) bool) error

RawRead method #

RawRead invokes the user-defined function f for a read operation.

func (fd *FD) RawRead(f func(uintptr) bool) error

RawRead method #

RawRead invokes the user-defined function f for a read operation.

func (fd *FD) RawRead(f func(uintptr) bool) error

RawWrite method #

RawWrite invokes the user-defined function f for a write operation.

func (fd *FD) RawWrite(f func(uintptr) bool) error

RawWrite method #

RawWrite invokes the user-defined function f for a write operation.

func (fd *FD) RawWrite(f func(uintptr) bool) error

RawWrite method #

RawWrite invokes the user-defined function f for a write operation.

func (fd *FD) RawWrite(f func(uintptr) bool) error

Read method #

Read implements io.Reader.

func (fd *FD) Read(p []byte) (int, error)

Read method #

Read implements io.Reader.

func (fd *FD) Read(fn func([]byte) (int, error), b []byte) (int, error)

Read method #

Read implements io.Reader.

func (fd *FD) Read(buf []byte) (int, error)

ReadDir method #

ReadDir wraps syscall.ReadDir. We treat this like an ordinary system call rather than a call that tries to fill the buffer.

func (fd *FD) ReadDir(buf []byte, cookie syscall.Dircookie) (int, error)

ReadDirent method #

ReadDirent wraps syscall.ReadDirent. We treat this like an ordinary system call rather than a call that tries to fill the buffer.

func (fd *FD) ReadDirent(buf []byte) (int, error)

ReadDirent method #

func (fd *FD) ReadDirent(buf []byte) (int, error)

ReadFrom method #

ReadFrom wraps the recvfrom network call.

func (fd *FD) ReadFrom(buf []byte) (int, syscall.Sockaddr, error)

ReadFrom method #

ReadFrom wraps the recvfrom network call.

func (fd *FD) ReadFrom(p []byte) (int, syscall.Sockaddr, error)

ReadFromInet4 method #

ReadFromInet4 wraps the recvfrom network call for IPv4.

func (fd *FD) ReadFromInet4(buf []byte, sa4 *syscall.SockaddrInet4) (int, error)

ReadFromInet4 method #

ReadFromInet4 wraps the recvfrom network call for IPv4.

func (fd *FD) ReadFromInet4(p []byte, from *syscall.SockaddrInet4) (int, error)

ReadFromInet6 method #

ReadFromInet6 wraps the recvfrom network call for IPv6.

func (fd *FD) ReadFromInet6(p []byte, from *syscall.SockaddrInet6) (int, error)

ReadFromInet6 method #

ReadFromInet6 wraps the recvfrom network call for IPv6.

func (fd *FD) ReadFromInet6(buf []byte, sa6 *syscall.SockaddrInet6) (int, error)

ReadLock method #

func (fdmu *FDMutex) ReadLock() bool

ReadLock method #

ReadLock wraps FD.readLock.

func (fd *FD) ReadLock() error

ReadMsg method #

ReadMsg wraps the WSARecvMsg network call.

func (fd *FD) ReadMsg(p []byte, oob []byte, flags int) (int, int, int, syscall.Sockaddr, error)

ReadMsg method #

ReadMsg wraps the recvmsg network call.

func (fd *FD) ReadMsg(p []byte, oob []byte, flags int) (int, int, int, syscall.Sockaddr, error)

ReadMsgInet4 method #

ReadMsgInet4 is ReadMsg, but specialized for syscall.SockaddrInet4.

func (fd *FD) ReadMsgInet4(p []byte, oob []byte, flags int, sa4 *syscall.SockaddrInet4) (int, int, int, error)

ReadMsgInet4 method #

ReadMsgInet4 is ReadMsg, but specialized to return a syscall.SockaddrInet4.

func (fd *FD) ReadMsgInet4(p []byte, oob []byte, flags int, sa4 *syscall.SockaddrInet4) (int, int, int, error)

ReadMsgInet6 method #

ReadMsgInet6 is ReadMsg, but specialized for syscall.SockaddrInet6.

func (fd *FD) ReadMsgInet6(p []byte, oob []byte, flags int, sa6 *syscall.SockaddrInet6) (int, int, int, error)

ReadMsgInet6 method #

ReadMsgInet6 is ReadMsg, but specialized to return a syscall.SockaddrInet6.

func (fd *FD) ReadMsgInet6(p []byte, oob []byte, flags int, sa6 *syscall.SockaddrInet6) (int, int, int, error)

ReadUnlock method #

ReadUnlock wraps FD.readUnlock.

func (fd *FD) ReadUnlock()

ReadUnlock method #

func (fdmu *FDMutex) ReadUnlock() bool

Seek method #

Seek wraps syscall.Seek.

func (fd *FD) Seek(offset int64, whence int) (int64, error)

Seek method #

Seek wraps syscall.Seek.

func (fd *FD) Seek(offset int64, whence int) (int64, error)

Seek method #

Seek wraps syscall.Seek.

func (fd *FD) Seek(offset int64, whence int) (int64, error)

SendFile function #

SendFile wraps the TransmitFile call.

func SendFile(fd *FD, src syscall.Handle, n int64) (written int64, err error)

SendFile function #

SendFile wraps the sendfile system call. It copies data from src (a file descriptor) to dstFD, starting at the current position of src. It updates the current position of src to after the copied data. If size is zero, it copies the rest of src. Otherwise, it copies up to size bytes. The handled return parameter indicates whether SendFile was able to handle some or all of the operation. If handled is false, sendfile was unable to perform the copy, has not modified the source or destination, and the caller should perform the copy using a fallback implementation.

func SendFile(dstFD *FD, src int, size int64) (n int64, err error, handled bool)

SetBlocking method #

SetBlocking puts the file into blocking mode.

func (fd *FD) SetBlocking() error

SetDeadline method #

SetDeadline sets the read and write deadlines associated with fd.

func (fd *FD) SetDeadline(t time.Time) error

SetDeadline method #

SetDeadline sets the read and write deadlines associated with fd.

func (fd *FD) SetDeadline(t time.Time) error

SetDeadline method #

SetDeadline sets the read and write deadlines associated with fd.

func (fd *FD) SetDeadline(t time.Time) error

SetReadDeadline method #

SetReadDeadline sets the read deadline associated with fd.

func (fd *FD) SetReadDeadline(t time.Time) error

SetReadDeadline method #

SetReadDeadline sets the read deadline associated with fd.

func (fd *FD) SetReadDeadline(t time.Time) error

SetReadDeadline method #

SetReadDeadline sets the read deadline associated with fd.

func (fd *FD) SetReadDeadline(t time.Time) error

SetWriteDeadline method #

SetWriteDeadline sets the write deadline associated with fd.

func (fd *FD) SetWriteDeadline(t time.Time) error

SetWriteDeadline method #

SetWriteDeadline sets the write deadline associated with fd.

func (fd *FD) SetWriteDeadline(t time.Time) error

SetWriteDeadline method #

SetWriteDeadline sets the write deadline associated with fd.

func (fd *FD) SetWriteDeadline(t time.Time) error

SetsockoptByte method #

SetsockoptByte wraps the setsockopt network call with a byte argument.

func (fd *FD) SetsockoptByte(level int, name int, arg byte) error

SetsockoptIPMreq method #

SetsockoptIPMreq wraps the setsockopt network call with an IPMreq argument.

func (fd *FD) SetsockoptIPMreq(level int, name int, mreq *syscall.IPMreq) error

SetsockoptIPMreqn method #

SetsockoptIPMreqn wraps the setsockopt network call with an IPMreqn argument.

func (fd *FD) SetsockoptIPMreqn(level int, name int, mreq *syscall.IPMreqn) error

SetsockoptIPv6Mreq method #

SetsockoptIPv6Mreq wraps the setsockopt network call with an IPv6Mreq argument.

func (fd *FD) SetsockoptIPv6Mreq(level int, name int, mreq *syscall.IPv6Mreq) error

SetsockoptInet4Addr method #

SetsockoptInet4Addr wraps the setsockopt network call with an IPv4 address.

func (fd *FD) SetsockoptInet4Addr(level int, name int, arg [4]byte) error

SetsockoptInt method #

SetsockoptInt wraps the setsockopt network call with an int argument.

func (fd *FD) SetsockoptInt(level int, name int, arg int) error

SetsockoptLinger method #

SetsockoptLinger wraps the setsockopt network call with a Linger argument.

func (fd *FD) SetsockoptLinger(level int, name int, l *syscall.Linger) error

Shutdown method #

Shutdown wraps syscall.Shutdown.

func (fd *FD) Shutdown(how int) error

Splice function #

Splice transfers at most remain bytes of data from src to dst, using the splice system call to minimize copies of data from and to userspace. Splice gets a pipe buffer from the pool or creates a new one if needed, to serve as a buffer for the data transfer. src and dst must both be stream-oriented sockets.

func Splice(dst *FD, src *FD, remain int64) (written int64, handled bool, err error)

Temporary method #

func (e *DeadlineExceededError) Temporary() bool

Temporary method #

func (e errNetClosing) Temporary() bool

Timeout method #

func (e *DeadlineExceededError) Timeout() bool

Timeout method #

func (e errNetClosing) Timeout() bool

WSAIoctl method #

WSAIoctl wraps the WSAIoctl network call.

func (fd *FD) WSAIoctl(iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *syscall.Overlapped, completionRoutine uintptr) error

Wait method #

Wait for the I/O operation to complete.

func (aio *asyncIO) Wait() (int, error)

WaitWrite method #

WaitWrite waits until data can be written to fd.

func (fd *FD) WaitWrite() error

Write method #

Write implements io.Writer.

func (fd *FD) Write(fn func([]byte) (int, error), b []byte) (int, error)

Write method #

Write implements io.Writer.

func (fd *FD) Write(p []byte) (int, error)

Write method #

Write implements io.Writer.

func (fd *FD) Write(buf []byte) (int, error)

WriteLock method #

func (fdmu *FDMutex) WriteLock() bool

WriteMsg method #

WriteMsg wraps the WSASendMsg network call.

func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, error)

WriteMsg method #

WriteMsg wraps the sendmsg network call.

func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, error)

WriteMsgInet4 method #

WriteMsgInet4 is WriteMsg specialized for syscall.SockaddrInet4.

func (fd *FD) WriteMsgInet4(p []byte, oob []byte, sa *syscall.SockaddrInet4) (int, int, error)

WriteMsgInet4 method #

WriteMsgInet4 is WriteMsg specialized for syscall.SockaddrInet4.

func (fd *FD) WriteMsgInet4(p []byte, oob []byte, sa *syscall.SockaddrInet4) (int, int, error)

WriteMsgInet6 method #

WriteMsgInet6 is WriteMsg specialized for syscall.SockaddrInet6.

func (fd *FD) WriteMsgInet6(p []byte, oob []byte, sa *syscall.SockaddrInet6) (int, int, error)

WriteMsgInet6 method #

WriteMsgInet6 is WriteMsg specialized for syscall.SockaddrInet6.

func (fd *FD) WriteMsgInet6(p []byte, oob []byte, sa *syscall.SockaddrInet6) (int, int, error)

WriteOnce method #

WriteOnce is for testing only. It makes a single write call.

func (fd *FD) WriteOnce(p []byte) (int, error)

WriteTo method #

WriteTo wraps the sendto network call.

func (fd *FD) WriteTo(buf []byte, sa syscall.Sockaddr) (int, error)

WriteTo method #

WriteTo wraps the sendto network call.

func (fd *FD) WriteTo(p []byte, sa syscall.Sockaddr) (int, error)

WriteToInet4 method #

WriteToInet4 is WriteTo, specialized for syscall.SockaddrInet4.

func (fd *FD) WriteToInet4(buf []byte, sa4 *syscall.SockaddrInet4) (int, error)

WriteToInet4 method #

WriteToInet4 wraps the sendto network call for IPv4 addresses.

func (fd *FD) WriteToInet4(p []byte, sa *syscall.SockaddrInet4) (int, error)

WriteToInet6 method #

WriteToInet6 is WriteTo, specialized for syscall.SockaddrInet6.

func (fd *FD) WriteToInet6(buf []byte, sa6 *syscall.SockaddrInet6) (int, error)

WriteToInet6 method #

WriteToInet6 wraps the sendto network call for IPv6 addresses.

func (fd *FD) WriteToInet6(p []byte, sa *syscall.SockaddrInet6) (int, error)

WriteUnlock method #

func (fdmu *FDMutex) WriteUnlock() bool

Writev method #

Writev emulates the Unix writev system call.

func (fd *FD) Writev(buf *[][]byte) (int64, error)

Writev method #

Writev wraps the writev system call.

func (fd *FD) Writev(v *[][]byte) (int64, error)

accept function #

Wrapper around the accept system call that marks the returned file descriptor as nonblocking and close-on-exec.

func accept(s int) (int, syscall.Sockaddr, string, error)

accept function #

Wrapper around the accept system call that marks the returned file descriptor as nonblocking and close-on-exec.

func accept(s int) (int, syscall.Sockaddr, string, error)

accept function #

Wrapper around the accept system call that marks the returned file descriptor as nonblocking and close-on-exec.

func accept(s int) (int, syscall.Sockaddr, string, error)

acceptOne method #

func (fd *FD) acceptOne(s syscall.Handle, rawsa []syscall.RawSockaddrAny, o *operation) (string, error)

checkSetFileCompletionNotificationModes function #

checkSetFileCompletionNotificationModes verifies that SetFileCompletionNotificationModes Windows API is present on the system and is safe to use. See https://support.microsoft.com/kb/2568167 for details.

func checkSetFileCompletionNotificationModes()

close method #

func (pd *pollDesc) close()

close method #

func (pd *pollDesc) close()

consume function #

consume removes data from a slice of byte slices, for writev.

func consume(v *[][]byte, n int64)

convertErr function #

func convertErr(res int, isFile bool) error

copyFileRange function #

copyFileRange performs one round of copy_file_range(2).

func copyFileRange(dst *FD, src *FD, max int) (written int64, err error)

decref method #

decref removes a reference from mu. It reports whether there is no remaining reference.

func (mu *fdMutex) decref() bool

decref method #

decref removes a reference from fd. It also closes fd when the state of fd is set to closed and there is no remaining reference.

func (fd *FD) decref() error

destroy method #

func (s *SysFile) destroy(fd int) error

destroy method #

func (fd *FD) destroy() error

destroy method #

func (s *SysFile) destroy(fd int) error

destroy method #

Destroy closes the file descriptor. This is called when there are no remaining references.

func (fd *FD) destroy() error

destroy method #

We need this to close out a file descriptor when it is unlocked, but the real implementation has to live in the net package because it uses os.File's.

func (fd *FD) destroy() error

destroyPipe function #

destroyPipe destroys a pipe.

func destroyPipe(p *splicePipe)

direntNamlen function #

func direntNamlen(buf []byte) (uint64, bool)

direntNext function #

func direntNext(buf []byte) (uint64, bool)

direntReclen function #

func direntReclen(buf []byte) (uint64, bool)

dupCloseOnExecOld function #

dupCloseOnExecOld is the traditional way to dup an fd and set its O_CLOEXEC bit, using two system calls.

func dupCloseOnExecOld(fd int) (int, string, error)

dupCloseOnExecOld function #

dupCloseOnExecOld always errors on wasip1 because there is no mechanism to duplicate file descriptors.

func dupCloseOnExecOld(fd int) (int, string, error)

eofError method #

eofError returns io.EOF when fd is available for reading end of file.

func (fd *FD) eofError(n int, err error) error

errClosing function #

Return the appropriate closing error based on isFile.

func errClosing(isFile bool) error

errnoErr function #

errnoErr returns common boxed Errno values, to prevent allocations at runtime.

func errnoErr(e syscall.Errno) error

errnoErr function #

errnoErr returns common boxed Errno values, to prevent allocations at runtime.

func errnoErr(e syscall.Errno) error

evict method #

func (pd *pollDesc) evict()

evict method #

Evict evicts fd from the pending list, unblocking any I/O running on fd.

func (pd *pollDesc) evict()

execIO function #

execIO executes a single IO operation o. It submits and cancels IO in the current thread for systems where Windows CancelIoEx API is available. Alternatively, it passes the request onto runtime netpoll and waits for completion or cancels request.

func execIO(o *operation, submit func(o *operation) error) (int, error)

fdopendir function #

Implemented in syscall/syscall_darwin.go. go:linkname fdopendir syscall.fdopendir

func fdopendir(fd int) (dir uintptr, err error)

getPipe function #

getPipe tries to acquire a pipe buffer from the pool or create a new one with newPipe() if it gets nil from the cache.

func getPipe() (*splicePipe, error)

handleCopyFileRangeErr function #

func handleCopyFileRangeErr(err error, copied int64, written int64) (bool, error)

handleCopyFileRangeErr function #

func handleCopyFileRangeErr(err error, copied int64, written int64) (bool, error)

ignoringEINTR function #

ignoringEINTR makes a function call and repeats it if it returns an EINTR error. This appears to be required even though we install all signal handlers with SA_RESTART: see #22838, #38033, #38836, #40846. Also #20400 and #36644 are issues in which a signal handler is installed without setting SA_RESTART. None of these are the common case, but there are enough of them that it seems that we can't avoid an EINTR loop.

func ignoringEINTR(fn func() error) error

ignoringEINTR2 function #

ignoringEINTR2 is ignoringEINTR, but returning an additional value.

func ignoringEINTR2(fn func() (T, error)) (T, error)

ignoringEINTRIO function #

ignoringEINTRIO is like ignoringEINTR, but just for IO calls.

func ignoringEINTRIO(fn func(fd int, p []byte) (int, error), fd int, p []byte) (int, error)

incref method #

incref adds a reference to mu. It reports whether mu is available for reading or writing.

func (mu *fdMutex) incref() bool

incref method #

incref adds a reference to fd. It returns an error when fd cannot be used.

func (fd *FD) incref() error

increfAndClose method #

increfAndClose sets the state of mu to closed. It returns false if the file was already closed.

func (mu *fdMutex) increfAndClose() bool

init method #

func (pd *pollDesc) init(fd *FD) error

init method #

func (pd *pollDesc) init(fd *FD) error

init method #

func (s *SysFile) init()

init method #

func (s *SysFile) init()

isHangup function #

func isHangup(err error) bool

isInterrupted function #

func isInterrupted(err error) bool

newAsyncIO function #

newAsyncIO returns a new asyncIO that performs an I/O operation by calling fn, which must do one and only one interruptible system call.

func newAsyncIO(fn func([]byte) (int, error), b []byte) *asyncIO

newIovecWithBase function #

func newIovecWithBase(base *byte) syscall.Iovec

newIovecWithBase function #

func newIovecWithBase(base *byte) syscall.Iovec

newPipe function #

newPipe sets up a pipe for a splice operation.

func newPipe() *splicePipe

newPoolPipe function #

func newPoolPipe() any

pollable method #

func (pd *pollDesc) pollable() bool

pollable method #

func (pd *pollDesc) pollable() bool

prepare method #

func (pd *pollDesc) prepare(mode int, isFile bool) error

prepare method #

func (pd *pollDesc) prepare(mode int, isFile bool) error

prepareRead method #

func (pd *pollDesc) prepareRead(isFile bool) error

prepareRead method #

func (pd *pollDesc) prepareRead(isFile bool) error

prepareWrite method #

func (pd *pollDesc) prepareWrite(isFile bool) error

prepareWrite method #

func (pd *pollDesc) prepareWrite(isFile bool) error

putPipe function #

func putPipe(p *splicePipe)

rawToSockaddrInet4 function #

func rawToSockaddrInet4(rsa *syscall.RawSockaddrAny, sa *syscall.SockaddrInet4)

rawToSockaddrInet6 function #

func rawToSockaddrInet6(rsa *syscall.RawSockaddrAny, sa *syscall.SockaddrInet6)

readConsole method #

readConsole reads utf16 characters from console File, encodes them into utf8 and stores them in buffer b. It returns the number of utf8 bytes read and an error, if any.

func (fd *FD) readConsole(b []byte) (int, error)

readInt function #

readInt returns the size-bytes unsigned integer in native byte order at offset off.

func readInt(b []byte, off uintptr, size uintptr) (u uint64, ok bool)

readIntLE function #

func readIntLE(b []byte, size uintptr) uint64

readLock method #

readLock adds a reference to fd and locks fd for reading. It returns an error when fd cannot be used for reading.

func (fd *FD) readLock() error

readUnlock method #

readUnlock removes a reference from fd and unlocks fd for reading. It also closes fd when the state of fd is set to closed and there is no remaining reference.

func (fd *FD) readUnlock()

ref method #

func (s *SysFile) ref() SysFile

runtimeNano function #

runtimeNano returns the current value of the runtime clock in nanoseconds. go:linkname runtimeNano runtime.nanotime

func runtimeNano() int64

runtime_Semacquire function #

Implemented in runtime package.

func runtime_Semacquire(sema *uint32)

runtime_Semrelease function #

func runtime_Semrelease(sema *uint32)

runtime_ignoreHangup function #

The following functions, provided by the runtime, are used to ignore and unignore the "hangup" signal received by the process.

func runtime_ignoreHangup()

runtime_isPollServerDescriptor function #

func runtime_isPollServerDescriptor(fd uintptr) bool

runtime_pollClose function #

func runtime_pollClose(ctx uintptr)

runtime_pollOpen function #

func runtime_pollOpen(fd uintptr) (uintptr, int)

runtime_pollReset function #

func runtime_pollReset(ctx uintptr, mode int) int

runtime_pollServerInit function #

func runtime_pollServerInit()

runtime_pollSetDeadline function #

func runtime_pollSetDeadline(ctx uintptr, d int64, mode int)

runtime_pollUnblock function #

func runtime_pollUnblock(ctx uintptr)

runtime_pollWait function #

func runtime_pollWait(ctx uintptr, mode int) int

runtime_pollWaitCanceled function #

func runtime_pollWaitCanceled(ctx uintptr, mode int)

runtime_unignoreHangup function #

func runtime_unignoreHangup()

rwlock method #

lock adds a reference to mu and locks mu. It reports whether mu is available for reading or writing.

func (mu *fdMutex) rwlock(read bool) bool

rwunlock method #

unlock removes a reference from mu and unlocks mu. It reports whether there is no remaining reference.

func (mu *fdMutex) rwunlock(read bool) bool

sendFile function #

sendFile wraps the sendfile system call.

func sendFile(dstFD *FD, src int, offset *int64, size int64) (written int64, err error, handled bool)

sendFileChunk function #

func sendFileChunk(dst int, src int, offset *int64, size int, written int64) (n int, err error)

setDeadlineImpl function #

func setDeadlineImpl(fd *FD, t time.Time, mode int) error

setDeadlineImpl function #

func setDeadlineImpl(fd *FD, t time.Time, mode int) error

setDeadlineImpl function #

func setDeadlineImpl(fd *FD, t time.Time, mode int) error

sockaddrInet4ToRaw function #

func sockaddrInet4ToRaw(rsa *syscall.RawSockaddrAny, sa *syscall.SockaddrInet4) int32

sockaddrInet6ToRaw function #

func sockaddrInet6ToRaw(rsa *syscall.RawSockaddrAny, sa *syscall.SockaddrInet6) int32

sockaddrToRaw function #

func sockaddrToRaw(rsa *syscall.RawSockaddrAny, sa syscall.Sockaddr) (int32, error)

splice function #

splice wraps the splice system call. Since the current implementation only uses splice on sockets and pipes, the offset arguments are unused. splice returns int instead of int64, because callers never ask it to move more data in a single call than can fit in an int32.

func splice(out int, in int, max int, flags int) (int, error)

spliceDrain function #

spliceDrain moves data from a socket to a pipe. Invariant: when entering spliceDrain, the pipe is empty. It is either in its initial state, or splicePump has emptied it previously. Given this, spliceDrain can reasonably assume that the pipe is ready for writing, so if splice returns EAGAIN, it must be because the socket is not ready for reading. If spliceDrain returns (0, nil), src is at EOF.

func spliceDrain(pipefd int, sock *FD, max int) (int, error)

splicePump function #

splicePump moves all the buffered data from a pipe to a socket. Invariant: when entering splicePump, there are exactly inPipe bytes of data in the pipe, from a previous call to spliceDrain. By analogy to the condition from spliceDrain, splicePump only needs to poll the socket for readiness, if splice returns EAGAIN. If splicePump cannot move all the data in a single call to splice(2), it loops over the buffered data until it has written all of it to the socket. This behavior is similar to the Write step of an io.Copy in userspace.

func splicePump(sock *FD, pipefd int, inPipe int) (int, error)

supportCopyFileRange function #

func supportCopyFileRange() bool

supportCopyFileRange function #

func supportCopyFileRange() bool

wait method #

func (pd *pollDesc) wait(mode int, isFile bool) error

wait method #

func (pd *pollDesc) wait(mode int, isFile bool) error

waitCanceled method #

func (pd *pollDesc) waitCanceled(mode int)

waitCanceled method #

func (pd *pollDesc) waitCanceled(mode int)

waitRead method #

func (pd *pollDesc) waitRead(isFile bool) error

waitRead method #

func (pd *pollDesc) waitRead(isFile bool) error

waitWrite method #

func (pd *pollDesc) waitWrite(isFile bool) error

waitWrite method #

func (pd *pollDesc) waitWrite(isFile bool) error

writeConsole method #

writeConsole writes len(b) bytes to the console File. It returns the number of bytes written and an error, if any.

func (fd *FD) writeConsole(b []byte) (int, error)

writeLock method #

writeLock adds a reference to fd and locks fd for writing. It returns an error when fd cannot be used for writing.

func (fd *FD) writeLock() error

writeUnlock method #

writeUnlock removes a reference from fd and unlocks fd for writing. It also closes fd when the state of fd is set to closed and there is no remaining reference.

func (fd *FD) writeUnlock()

writev function #

func writev(fd int, iovecs []syscall.Iovec) (uintptr, error)

writev function #

go:linkname writev syscall.writev

func writev(fd int, iovecs []syscall.Iovec) (uintptr, error)

Generated with Arrow