Package-Level Type Names (total 8, in which 3 are exported)
/* sort exporteds by: | */
DeadlineExceededError is returned for an expired deadline. 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.(*DeadlineExceededError) Temporary() bool(*DeadlineExceededError) Timeout() bool
*DeadlineExceededError : error
*DeadlineExceededError : net.Error
*DeadlineExceededError : net.temporary
*DeadlineExceededError : net.timeout
*DeadlineExceededError : os.timeout
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. Whether this is a streaming descriptor, as opposed to a
packet-based descriptor like a UDP socket. Immutable. Platform dependent state of the file descriptor. System file descriptor. Immutable until Close. Whether a zero byte read indicates EOF. This is false for a
message based socket connection. Semaphore signaled when file is closed. Lock sysfd and serialize access to Read and Write methods. Non-zero if this file has been set to blocking mode. Whether this is a file rather than a network socket. I/O poller. Writev cache. Accept wraps the accept network call. Close closes the FD. The underlying file descriptor is closed by the
destroy method when there are no remaining references. Dup duplicates the file descriptor. Fchdir wraps syscall.Fchdir. Fchmod wraps syscall.Fchmod. Fchown wraps syscall.Fchown. Fstat wraps syscall.Fstat Fsync wraps syscall.Fsync. Ftruncate wraps syscall.Ftruncate. GetsockoptInt wraps the getsockopt network call with an int argument. 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. Pread wraps the pread system call. Pwrite wraps the pwrite system call. RawControl invokes the user-defined function f for a non-IO
operation. RawRead invokes the user-defined function f for a read operation. RawWrite invokes the user-defined function f for a write operation. Read implements io.Reader. ReadDirent wraps syscall.ReadDirent.
We treat this like an ordinary system call rather than a call
that tries to fill the buffer. ReadFrom wraps the recvfrom network call. ReadFromInet4 wraps the recvfrom network call for IPv4. ReadFromInet6 wraps the recvfrom network call for IPv6. ReadMsg wraps the recvmsg network call. ReadMsgInet4 is ReadMsg, but specialized for syscall.SockaddrInet4. ReadMsgInet6 is ReadMsg, but specialized for syscall.SockaddrInet6. Seek wraps syscall.Seek. SetBlocking puts the file into blocking mode. SetDeadline sets the read and write deadlines associated with fd. SetReadDeadline sets the read deadline associated with fd. SetWriteDeadline sets the write deadline associated with fd. SetsockoptByte wraps the setsockopt network call with a byte argument. SetsockoptIPMreq wraps the setsockopt network call with an IPMreq argument. SetsockoptIPMreqn wraps the setsockopt network call with an IPMreqn argument. SetsockoptIPv6Mreq wraps the setsockopt network call with an IPv6Mreq argument. SetsockoptInet4Addr wraps the setsockopt network call with an IPv4 address. SetsockoptInt wraps the setsockopt network call with an int argument. SetsockoptLinger wraps the setsockopt network call with a Linger argument. Shutdown wraps syscall.Shutdown. WaitWrite waits until data can be read from fd. Write implements io.Writer. WriteMsg wraps the sendmsg network call. WriteMsgInet4 is WriteMsg specialized for syscall.SockaddrInet4. WriteMsgInet6 is WriteMsg specialized for syscall.SockaddrInet6. WriteOnce is for testing only. It makes a single write call. WriteTo wraps the sendto network call. WriteToInet4 wraps the sendto network call for IPv4 addresses. WriteToInet6 wraps the sendto network call for IPv6 addresses. Writev wraps the writev system call. 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. Destroy closes the file descriptor. This is called when there are
no remaining references. eofError returns io.EOF when fd is available for reading end of
file. incref adds a reference to fd.
It returns an error when fd cannot be used.(*FD) init() readLock adds a reference to fd and locks fd for reading.
It returns an error when fd cannot be used for reading. 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. writeLock adds a reference to fd and locks fd for writing.
It returns an error when fd cannot be used for writing. 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.
*FD : internal/bisect.Writer
*FD : io.Closer
*FD : io.ReadCloser
*FD : io.Reader
*FD : io.ReadSeekCloser
*FD : io.ReadSeeker
*FD : io.ReadWriteCloser
*FD : io.ReadWriter
*FD : io.ReadWriteSeeker
*FD : io.Seeker
*FD : io.WriteCloser
*FD : io.Writer
*FD : io.WriteSeeker
*FD : crypto/tls.transcriptHash
func os.getPollFD(r io.Reader) *FD
func CopyFileRange(dst, src *FD, remain int64) (written int64, handled bool, err error)
func SendFile(dstFD *FD, src int, remain int64) (int64, error, bool)
func Splice(dst, src *FD, remain int64) (written int64, handled bool, sc string, err error)
func copyFileRange(dst, src *FD, max int) (written int64, err error)
func setDeadlineImpl(fd *FD, t time.Time, mode int) error
func spliceDrain(pipefd int, sock *FD, max int) (int, error)
func splicePump(sock *FD, pipefd int, inPipe int) (int, error)
errNetClosing is the type of the variable ErrNetClosing.
This is used to implement the net.Error interface. 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.( errNetClosing) Temporary() bool( errNetClosing) Timeout() bool
errNetClosing : error
errNetClosing : net.Error
errNetClosing : net.temporary
errNetClosing : net.timeout
errNetClosing : os.timeout
var ErrNetClosing
var net.errClosed
fdMutex is a specialized synchronization primitive that manages
lifetime of an fd and serializes access to Read, Write and Close
methods on FD.rsemauint32stateuint64wsemauint32 decref removes a reference from mu.
It reports whether there is no remaining reference. incref adds a reference to mu.
It reports whether mu is available for reading or writing. increfAndClose sets the state of mu to closed.
It returns false if the file was already closed. lock adds a reference to mu and locks mu.
It reports whether mu is available for reading or writing. unlock removes a reference from mu and unlocks mu.
It reports whether there is no remaining reference.
Package-Level Functions (total 37, in which 5 are exported)
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.
DupCloseOnExec dups fd and marks it close-on-exec.
IsPollDescriptor reports whether fd is the descriptor being used by the poller.
This is only used for testing.
SendFile wraps the sendfile system call.
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.
If err != nil, sc is the system call which caused the error.
Wrapper around the accept system call that marks the returned file
descriptor as nonblocking and close-on-exec.
consume removes data from a slice of byte slices, for writev.
copyFileRange performs one round of copy_file_range(2).
destroyPipe destroys a pipe.
dupCloseOnExecOld is the traditional way to dup an fd and
set its O_CLOEXEC bit, using two system calls.
Return the appropriate closing error based on isFile.
errnoErr returns common boxed Errno values, to prevent
allocations at runtime.
getPipe tries to acquire a pipe buffer from the pool or create a new one with newPipe() if it gets nil from the cache.
Note that it may fail to create a new pipe buffer by newPipe(), in which case getPipe() will return a generic error
and system call name splice in a string as the indication.
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.
ignoringEINTRIO is like ignoringEINTR, but just for IO calls.
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.
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.
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.
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.
Package-Level Constants (total 19, none are exported)
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.
maxSendfileSize is the largest chunk size we ask the kernel to copy
at a time.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
constoverflowMsg = "too many concurrent operations on a single file or socket (max 10485...
Error values returned by runtime_pollReset and runtime_pollWait.
These must match the values in runtime/netpoll.go.
Error values returned by runtime_pollReset and runtime_pollWait.
These must match the values in runtime/netpoll.go.
Error values returned by runtime_pollReset and runtime_pollWait.
These must match the values in runtime/netpoll.go.
Error values returned by runtime_pollReset and runtime_pollWait.
These must match the values in runtime/netpoll.go.
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.
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.