Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Mobile.AsyncTLSReactor.Poll

re-arm, close

Feature notes: TLS implementation notes (RFC map) · Async TLS socket server architecture

Classes, interfaces and records

recordtPollEvent

One multiplexer event in platform-neutral form. The backend's WaitEvents translates its native struct into this; Generation is the value the backend carried through the kernel with the registration (see tPollSlot).

Fd: TSocketHandle; Generation: Cardinal; Wake: Boolean;
the shutdown self-pipe, not a connection
CanRead: Boolean; CanWrite: Boolean; Failed: Boolean;
POLLERR/POLLHUP-class condition on the socket

recordtPollSlot

Fd: TSocketHandle; Generation: Cardinal; Conn: tReactorConnection;
nil when the slot is free or holds an endpoint
Endpoint: tReactorDatagramEndpoint;
nil unless the slot holds a datagram endpoint
Hold: IInterface;
pins Conn (or Endpoint) for as long as it is attached
ReadArmed: Boolean;
a PostReceive is outstanding (see header)
SendBuf: PByte;
buffer being written, nil when idle
SendLen: Integer; SendPos: Integer;
bytes of SendBuf already on the wire
NextBuf: PByte;
buffer parked by a PostSend nested in SendCompleted
NextLen: Integer; HasNext: Boolean; InDrain: Boolean;
DriveSend is running on this connection

classtPollWakeItem

(no public members)

classtPollReactor

(no public members)

classtPollWorker

inherits from TThread

constructor Create(aReactor: tPollReactor);

classtPollReactor

inherits from tAsyncReactor

constructor Create(aThreadCount: Integer); override; destructor Destroy; override; procedure Start; override; procedure Stop; override; procedure CloseSocketHandle(aHandle: TSocketHandle); override; procedure Attach(aConnection: tReactorConnection); override; procedure Detach(aConnection: tReactorConnection); override; function SupportsApplicationWork: Boolean; override;
Always returns True.
function PostReceive(aConnection: tReactorConnection): Boolean; override; function PostSend(aConnection: tReactorConnection; aData: Pointer; aLen: Integer): Boolean; override; function Nudge(aConnection: tReactorConnection): Boolean; override; function ConnectionCount: Integer; override; function SnapshotConnections(out aConns: TArray<tReactorConnection>; out aHold: TArray<IInterface>): Integer; override; function SupportsDatagrams: Boolean; override;
Always returns True.
procedure AttachDatagram(aEndpoint: tReactorDatagramEndpoint); override; procedure DetachDatagram(aEndpoint: tReactorDatagramEndpoint); override; function SendDatagram(aEndpoint: tReactorDatagramEndpoint; aData: Pointer; aLen: Integer; const aTo: tSocketAddress; out aError: Integer): Boolean; override; function SetDatagramEcnReception(aEndpoint: tReactorDatagramEndpoint; aEnabled: Boolean; out aError: Integer): Boolean; override; function SendDatagramEcn(aEndpoint: tReactorDatagramEndpoint; aData: Pointer; aLen: Integer; const aTo: tSocketAddress; aEcn: tDatagramEcn; out aError: Integer): Boolean; override; function DatagramEndpointCount: Integer; override; property DrainReceive: Boolean read fDrainReceive write fDrainReceive;
When True, a read event drains the socket to EAGAIN (several HandleReceived calls, still strictly in order) before re-arming, trading fairness between connections for fewer arm/wait round trips. When False (default, and the closest match to the IOCP backend) one slab is read per event and the connection goes back to the end of the queue.

Types (enumerations, sets, aliases)

arraytPollEvents

  tPollEvents = array of tPollEvent;

typePPollSlot

Per-fd state, indexed by the descriptor and recycled with it. Allocated once per fd and never moved, so the address is stable, but NOT freed on detach - a stale event naming this fd must still find a valid record to be rejected by. Generation is what rejects it: it is bumped on every attach AND detach, and the kernel hands it back with the event, so an event minted for an earlier owner of a reused descriptor cannot be delivered to the current one.

LOCKING: Conn/Hold/Generation are written under the reactor's fSlotLock. Everything below them belongs to the connection and is touched ONLY under that connection's gate (tReactorConnection.Enter).

  PPollSlot = ^tPollSlot;

Routines