go2hx

manual

github

Module: stdgo.internal.poll

(view library index)

Overview

Package poll supports non-blocking I/O on file descriptors with polling. This supports I/O operations that block only a goroutine, not a thread. This is used by the net and os packages. It uses a poller built into the runtime, with support from the runtime scheduler.

Index

Constants

import stdgo.internal.poll.Poll
final _maxRW:stdgo.GoUInt64 = ((0 : stdgo.GoUInt64))

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.

final _mutexClosed:stdgo.GoUInt64 = ((0 : stdgo.GoUInt64))

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.

final _mutexRLock:stdgo.GoUInt64 = ((0 : stdgo.GoUInt64))

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.

final _mutexRMask:stdgo.GoUInt64 = ((0 : stdgo.GoUInt64))

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.

final _mutexRWait:stdgo.GoUInt64 = ((0 : stdgo.GoUInt64))

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.

final _mutexRef:stdgo.GoUInt64 = ((0 : stdgo.GoUInt64))

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.

final _mutexRefMask:stdgo.GoUInt64 = ((0 : stdgo.GoUInt64))

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.

final _mutexWLock:stdgo.GoUInt64 = ((0 : stdgo.GoUInt64))

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.

final _mutexWMask:stdgo.GoUInt64 = ((0 : stdgo.GoUInt64))

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.

final _mutexWWait:stdgo.GoUInt64 = ((0 : stdgo.GoUInt64))

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.

final _overflowMsg:stdgo.GoString = (("" : stdgo.GoString))

Variables

import stdgo.internal.poll.Poll
var _dupCloexecUnsupported:stdgo.sync.atomic_.Bool_

dupCloexecUnsupported indicates whether F_DUPFD_CLOEXEC is supported by the kernel.

var errDeadlineExceeded:stdgo.Error

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

var errFileClosing:stdgo.Error

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

var errNetClosing:stdgo.internal.poll.T_errNetClosing

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

var errNoDeadline:stdgo.Error

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

var errNotPollable:stdgo.Error

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

Functions

import stdgo.internal.poll.Poll

function _accept

function _accept(_s:stdgo.GoInt):{
	_3:stdgo.Error;
	_2:stdgo.GoString;
	_1:stdgo.syscall.Sockaddr;
	_0:stdgo.GoInt;
}

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

(view code)

function _consume

function _consume(_v:stdgo.Ref<stdgo.Slice<stdgo.Slice<stdgo.GoByte>>>, _n:stdgo.GoInt64):Void

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

(view code)

function _dupCloseOnExecOld

function _dupCloseOnExecOld(_fd:stdgo.GoInt):{
	_2:stdgo.Error;
	_1:stdgo.GoString;
	_0:stdgo.GoInt;
}

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

(view code)

function _errClosing

function _errClosing(_isFile:Bool):stdgo.Error

Return the appropriate closing error based on isFile.

(view code)

function _ignoringEINTR

function _ignoringEINTR(_fn:():stdgo.Error):stdgo.Error

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.

(view code)

function _ignoringEINTRIO

function _ignoringEINTRIO(_fn:(_fd:stdgo.GoInt, _p:stdgo.Slice<stdgo.GoByte>):{
	_1:stdgo.Error;
	_0:stdgo.GoInt;
}, _fd:stdgo.GoInt, _p:stdgo.Slice<stdgo.GoByte>):{
	_1:stdgo.Error;
	_0:stdgo.GoInt;
}

ignoringEINTRIO is like ignoringEINTR, but just for IO calls.

(view code)

function _runtime_Semacquire

function _runtime_Semacquire(_sema:stdgo.Pointer<stdgo.GoUInt32>):Void

Implemented in runtime package.

(view code)

function _runtime_Semrelease

function _runtime_Semrelease(_sema:stdgo.Pointer<stdgo.GoUInt32>):Void

(view code)

function _setDeadlineImpl

function _setDeadlineImpl(_fd:stdgo.Ref<stdgo.internal.poll.FD>, _t:stdgo.time.Time, _mode:stdgo.GoInt):stdgo.Error

(view code)

function acceptFunc

function acceptFunc()

AcceptFunc is used to hook the accept call.

(view code)

function closeFunc

function closeFunc()

CloseFunc is used to hook the close call.

(view code)

function dupCloseOnExec

function dupCloseOnExec(_fd:stdgo.GoInt):{
	_2:stdgo.Error;
	_1:stdgo.GoString;
	_0:stdgo.GoInt;
}

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

(view code)

function isPollDescriptor

function isPollDescriptor(_fd:stdgo.GoUIntptr):Bool

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

(view code)

function testHookDidWritev

function testHookDidWritev()

TestHookDidWritev is a hook for testing writev.

(view code)

Classes

import stdgo.internal.poll.*

class DeadlineExceededError

DeadlineExceededError is returned for an expired deadline.

DeadlineExceededError function new

function new():Void

(view code)

DeadlineExceededError function error

function error():stdgo.GoString

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.

(view code)

DeadlineExceededError function temporary

function temporary():Bool

(view code)

DeadlineExceededError function timeout

function timeout():Bool

(view code)

class FD

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.

var _csema:stdgo.GoUInt32

Semaphore signaled when file is closed.

var _fdmu:stdgo.internal.poll.T_fdMutex

Lock sysfd and serialize access to Read and Write methods.

var _isBlocking:stdgo.GoUInt32

Non-zero if this file has been set to blocking mode.

var _isFile:Bool

Whether this is a file rather than a network socket.

var _pd:stdgo.internal.poll.T_pollDesc

I/O poller.

var isStream:Bool

Whether this is a streaming descriptor, as opposed to a packet-based descriptor like a UDP socket. Immutable.

var sysFile:stdgo.internal.poll.SysFile

Platform dependent state of the file descriptor.

var sysfd:stdgo.GoInt

System file descriptor. Immutable until Close.

var zeroReadIsEOF:Bool

Whether a zero byte read indicates EOF. This is false for a message based socket connection.

FD function _init

function _init():Void

(view code)

FD function new

function new(?_fdmu:stdgo.internal.poll.T_fdMutex, ?sysfd:stdgo.GoInt, ?sysFile:stdgo.internal.poll.SysFile, ?_pd:stdgo.internal.poll.T_pollDesc, ?_csema:stdgo.GoUInt32, ?_isBlocking:stdgo.GoUInt32, ?isStream:Bool, ?zeroReadIsEOF:Bool, ?_isFile:Bool):Void

(view code)

FD function _decref

function _decref():stdgo.Error

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.

(view code)

FD function _destroy

function _destroy():stdgo.Error

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

(view code)

FD function _eofError

function _eofError( _n:stdgo.GoInt, _err:stdgo.Error):stdgo.Error

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

(view code)

FD function _incref

function _incref():stdgo.Error

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

(view code)

FD function _init

function _init():Void

(view code)

FD function _readLock

function _readLock():stdgo.Error

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

(view code)

FD function _readUnlock

function _readUnlock():Void

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.

(view code)

FD function _writeLock

function _writeLock():stdgo.Error

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

(view code)

FD function _writeUnlock

function _writeUnlock():Void

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.

(view code)

FD function accept

function accept():{
	_3:stdgo.Error;
	_2:stdgo.GoString;
	_1:stdgo.syscall.Sockaddr;
	_0:stdgo.GoInt;
}

Accept wraps the accept network call.

(view code)

FD function close

function close():stdgo.Error

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

(view code)

FD function dup

function dup():{
	_2:stdgo.Error;
	_1:stdgo.GoString;
	_0:stdgo.GoInt;
}

Dup duplicates the file descriptor.

(view code)

FD function fchdir

function fchdir():stdgo.Error

Fchdir wraps syscall.Fchdir.

(view code)

FD function fchmod

function fchmod( _mode:stdgo.GoUInt32):stdgo.Error

Fchmod wraps syscall.Fchmod.

(view code)

FD function fchown

function fchown( _uid:stdgo.GoInt, _gid:stdgo.GoInt):stdgo.Error

Fchown wraps syscall.Fchown.

(view code)

FD function fstat

function fstat( _s:stdgo.Ref<stdgo.syscall.Stat_t>):stdgo.Error

Fstat wraps syscall.Fstat

(view code)

FD function fsync

function fsync():stdgo.Error

Fsync wraps syscall.Fsync.

(view code)

FD function ftruncate

function ftruncate( _size:stdgo.GoInt64):stdgo.Error

Ftruncate wraps syscall.Ftruncate.

(view code)

FD function init

function init( _net:stdgo.GoString, _pollable:Bool):stdgo.Error

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.

(view code)

FD function pread

function pread( _p:stdgo.Slice<stdgo.GoByte>, _off:stdgo.GoInt64):{
	_1:stdgo.Error;
	_0:stdgo.GoInt;
}

Pread wraps the pread system call.

(view code)

FD function pwrite

function pwrite( _p:stdgo.Slice<stdgo.GoByte>, _off:stdgo.GoInt64):{
	_1:stdgo.Error;
	_0:stdgo.GoInt;
}

Pwrite wraps the pwrite system call.

(view code)

FD function rawControl

function rawControl( _f:()):stdgo.Error

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

(view code)

FD function rawRead

function rawRead( _f:()):stdgo.Error

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

(view code)

FD function rawWrite

function rawWrite( _f:()):stdgo.Error

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

(view code)

FD function read

function read( _p:stdgo.Slice<stdgo.GoByte>):{
	_1:stdgo.Error;
	_0:stdgo.GoInt;
}

Read implements io.Reader.

(view code)

FD function readDirent

function readDirent( _buf:stdgo.Slice<stdgo.GoByte>):{
	_1:stdgo.Error;
	_0:stdgo.GoInt;
}

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

(view code)

FD function readFrom

function readFrom( _p:stdgo.Slice<stdgo.GoByte>):{
	_2:stdgo.Error;
	_1:stdgo.syscall.Sockaddr;
	_0:stdgo.GoInt;
}

ReadFrom wraps the recvfrom network call.

(view code)

FD function readFromInet4

function readFromInet4( _p:stdgo.Slice<stdgo.GoByte>, _from:stdgo.Ref<stdgo.syscall.SockaddrInet4>):{
	_1:stdgo.Error;
	_0:stdgo.GoInt;
}

ReadFromInet4 wraps the recvfrom network call for IPv4.

(view code)

FD function readFromInet6

function readFromInet6( _p:stdgo.Slice<stdgo.GoByte>, _from:stdgo.Ref<stdgo.syscall.SockaddrInet6>):{
	_1:stdgo.Error;
	_0:stdgo.GoInt;
}

ReadFromInet6 wraps the recvfrom network call for IPv6.

(view code)

FD function readMsg

function readMsg( _p:stdgo.Slice<stdgo.GoByte>, _oob:stdgo.Slice<stdgo.GoByte>, _flags:stdgo.GoInt):{
	_4:stdgo.Error;
	_3:stdgo.syscall.Sockaddr;
	_2:stdgo.GoInt;
	_1:stdgo.GoInt;
	_0:stdgo.GoInt;
}

ReadMsg wraps the recvmsg network call.

(view code)

FD function readMsgInet4

function readMsgInet4( _p:stdgo.Slice<stdgo.GoByte>, _oob:stdgo.Slice<stdgo.GoByte>, _flags:stdgo.GoInt, _sa4:stdgo.Ref<stdgo.syscall.SockaddrInet4>):{
	_3:stdgo.Error;
	_2:stdgo.GoInt;
	_1:stdgo.GoInt;
	_0:stdgo.GoInt;
}

ReadMsgInet4 is ReadMsg, but specialized for syscall.SockaddrInet4.

(view code)

FD function readMsgInet6

function readMsgInet6( _p:stdgo.Slice<stdgo.GoByte>, _oob:stdgo.Slice<stdgo.GoByte>, _flags:stdgo.GoInt, _sa6:stdgo.Ref<stdgo.syscall.SockaddrInet6>):{
	_3:stdgo.Error;
	_2:stdgo.GoInt;
	_1:stdgo.GoInt;
	_0:stdgo.GoInt;
}

ReadMsgInet6 is ReadMsg, but specialized for syscall.SockaddrInet6.

(view code)

FD function seek

function seek( _offset:stdgo.GoInt64, _whence:stdgo.GoInt):{
	_1:stdgo.Error;
	_0:stdgo.GoInt64;
}

Seek wraps syscall.Seek.

(view code)

FD function setBlocking

function setBlocking():stdgo.Error

SetBlocking puts the file into blocking mode.

(view code)

FD function setDeadline

function setDeadline( _t:stdgo.time.Time):stdgo.Error

SetDeadline sets the read and write deadlines associated with fd.

(view code)

FD function setReadDeadline

function setReadDeadline( _t:stdgo.time.Time):stdgo.Error

SetReadDeadline sets the read deadline associated with fd.

(view code)

FD function setWriteDeadline

function setWriteDeadline( _t:stdgo.time.Time):stdgo.Error

SetWriteDeadline sets the write deadline associated with fd.

(view code)

FD function shutdown

function shutdown( _how:stdgo.GoInt):stdgo.Error

Shutdown wraps syscall.Shutdown.

(view code)

FD function waitWrite

function waitWrite():stdgo.Error

WaitWrite waits until data can be read from fd.

(view code)

FD function write

function write( _p:stdgo.Slice<stdgo.GoByte>):{
	_1:stdgo.Error;
	_0:stdgo.GoInt;
}

Write implements io.Writer.

(view code)

FD function writeMsg

function writeMsg( _p:stdgo.Slice<stdgo.GoByte>, _oob:stdgo.Slice<stdgo.GoByte>, _sa:stdgo.syscall.Sockaddr):{
	_2:stdgo.Error;
	_1:stdgo.GoInt;
	_0:stdgo.GoInt;
}

WriteMsg wraps the sendmsg network call.

(view code)

FD function writeMsgInet4

function writeMsgInet4( _p:stdgo.Slice<stdgo.GoByte>, _oob:stdgo.Slice<stdgo.GoByte>, _sa:stdgo.Ref<stdgo.syscall.SockaddrInet4>):{
	_2:stdgo.Error;
	_1:stdgo.GoInt;
	_0:stdgo.GoInt;
}

WriteMsgInet4 is WriteMsg specialized for syscall.SockaddrInet4.

(view code)

FD function writeMsgInet6

function writeMsgInet6( _p:stdgo.Slice<stdgo.GoByte>, _oob:stdgo.Slice<stdgo.GoByte>, _sa:stdgo.Ref<stdgo.syscall.SockaddrInet6>):{
	_2:stdgo.Error;
	_1:stdgo.GoInt;
	_0:stdgo.GoInt;
}

WriteMsgInet6 is WriteMsg specialized for syscall.SockaddrInet6.

(view code)

FD function writeOnce

function writeOnce( _p:stdgo.Slice<stdgo.GoByte>):{
	_1:stdgo.Error;
	_0:stdgo.GoInt;
}

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

(view code)

FD function writeTo

function writeTo( _p:stdgo.Slice<stdgo.GoByte>, _sa:stdgo.syscall.Sockaddr):{
	_1:stdgo.Error;
	_0:stdgo.GoInt;
}

WriteTo wraps the sendto network call.

(view code)

FD function writeToInet4

function writeToInet4( _p:stdgo.Slice<stdgo.GoByte>, _sa:stdgo.Ref<stdgo.syscall.SockaddrInet4>):{
	_1:stdgo.Error;
	_0:stdgo.GoInt;
}

WriteToInet4 wraps the sendto network call for IPv4 addresses.

(view code)

FD function writeToInet6

function writeToInet6( _p:stdgo.Slice<stdgo.GoByte>, _sa:stdgo.Ref<stdgo.syscall.SockaddrInet6>):{
	_1:stdgo.Error;
	_0:stdgo.GoInt;
}

WriteToInet6 wraps the sendto network call for IPv6 addresses.

(view code)

class SysFile

var _iovecs:stdgo.Ref<stdgo.Slice<stdgo.syscall.Iovec>>

Writev cache.

SysFile function new

function new(?_iovecs:stdgo.Ref<stdgo.Slice<stdgo.syscall.Iovec>>):Void

(view code)

SysFile function _destroy

function _destroy( _fd:stdgo.GoInt):stdgo.Error

(view code)

SysFile function _init

function _init():Void

(view code)