IFiberConnectionHandlerBase

Fiber connection handler base class -- creates a socket and a fiber internally, but does not contain reader / writer instances.

Constructors

this
this(EpollSelectDispatcher epoll, size_t stack_size, ISocket socket, FinalizeDg finalize_dg, ErrorDg error_dg)

Constructor

this
this(EpollSelectDispatcher epoll, ISocket socket, FinalizeDg finalize_dg, ErrorDg error_dg)

Constructor, uses the default fiber stack size.

Members

Aliases

KilledException
alias KilledException = SelectFiber.KilledException

Exception type alias. If handle() catches exceptions, it must rethrow these.

Functions

formatInfo
void formatInfo(char[] buf)

Formats information about the connection into the provided buffer. This method is called from the SelectListener in order to log information about the state of all connections in the pool.

handle
void handle()

Connection handler method. If it catches exceptions, it must rethrow those of type KilledException.

handleConnection
void handleConnection()

Called by the select listener right after the client connection has been assigned.

unregisterSocket
void unregisterSocket()

Called by finalize to unregister the connection socket from epoll before closing it. This is done because closing a socket does not always mean that it is unregistered from epoll -- in situations where the process has forked, the fork's reference to the underlying kernel file description will prevent it from being unregistered until the fork exits. Therefore, to be certain that the socket will not fire again in epoll, we need to explicitly unregister it.

Static variables

default_stack_size
size_t default_stack_size;

Default fiber stack size (16K in 64-bit builds, 8K in 32-bit builds).

Variables

fiber
SelectFiber fiber;

Fiber to handle an single connection.

Inherited Members

From IConnectionHandler

object_pool_index
size_t object_pool_index;

Object pool index.

EpollSelectDispatcher
alias EpollSelectDispatcher = .EpollSelectDispatcher

Local aliases to avoid public imports.

Event
alias Event = IAdvancedSelectClient.Event
Undocumented in source.
socket
ISocket socket;

Client connection socket, exposed to subclasses downcast to Conduit.

socket_error
SocketError socket_error;

SocketError instance to throw on error and query the current socket error status.

FinalizeDg
alias FinalizeDg = void delegate(typeof(this) instance)

Alias for a finalizer delegate, which can be specified externally and is called when the connection is shut down.

ErrorDg
alias ErrorDg = void delegate(Exception exception, Event event, IConnectionHandlerInfo)

Alias for an error delegate, which can be specified externally and is called when a connection error occurs.

connection_id
uint connection_id;

Instance id number in debug builds.

finalize_dg
FinalizeDg finalize_dg(FinalizeDg finalize_dg_)

Sets the finalizer callback delegate which is called when the connection is shut down. Setting to null disables the finalizer.

error_dg
ErrorDg error_dg(ErrorDg error_dg_)

Sets the error handler callback delegate which is called when a connection error occurs. Setting to null disables the error handler.

connected
bool connected()
fileHandle
ISelectable.Handle fileHandle()
assign
void assign(ISelectable listening_socket)

Accepts a pending connection from listening_socket and assigns it to the socket of this instance.

handleConnection
void handleConnection()

Called by the select listener right after the client connection has been assigned. If this method throws an exception, error() and finalize() will be called by the select listener.

finalize
void finalize()

Must be called by the subclass when finished handling the connection. Will be automatically called by the select listener if assign() or handleConnection() throws an exception.

error
void error(Exception exception, Event event)

IAdvancedSelectClient.IErrorReporter interface method. Called when a connection error occurs.

formatInfo
void formatInfo(char[] buf)

Formats information about the connection into the provided buffer. This method is called from the SelectListener in order to log information about the state of all connections in the pool.

unregisterSocket
void unregisterSocket()

Called by finalize to unregister the connection socket from epoll before closing it. This is done because closing a socket does not always mean that it is unregistered from epoll -- in situations where the process has forked, the fork's reference to the underlying kernel file description will prevent it from being unregistered until the fork exits. Therefore, to be certain that the socket will not fire again in epoll, we need to explicitly unregister it.

io_error
bool io_error()

Tells whether an I/O error has been reported for the socket since the last assign() call.

Meta