Comm Namespace Reference

Abstraction layer for TCP, UDP, TLS, UDS and filedescriptor sockets.

Classes

class  AcceptLimiter
 
class  Connection
 
class  ConnOpener
 
class  IoCallback
 Details about a particular Comm IO callback event. More...
 
class  CbEntry
 
class  TcpAcceptor
 
class  UdpOpenDialer
 dials a UDP port-opened call More...
 

Typedefs

typedef RefCount
< Comm::Connection
ConnectionPointer
 
typedef std::vector
< Comm::ConnectionPointer
ConnectionList
 

Enumerations

enum  Flag {
  OK = 0,
  COMM_ERROR = -1,
  NOMESSAGE = -3,
  TIMEOUT = -4,
  SHUTDOWN = -5,
  IDLE = -6,
  INPROGRESS = -7,
  ERR_CONNECT = -8,
  ERR_DNS = -9,
  ERR_CLOSING = -10,
  ERR_PROTOCOL = -11,
  ENDFILE = -12,
  ERR__END__ = -999999
}
 
enum  iocb_type {
  IOCB_NONE,
  IOCB_READ,
  IOCB_WRITE
}
 Type of IO callbacks the Comm layer deals with. More...
 

Functions

bool IsConnOpen (const Comm::ConnectionPointer &conn)
 
void SetSelect (int, unsigned int, PF *, void *, time_t)
 Mark an FD to be watched for its IO status. More...
 
void CallbackTableInit ()
 
void CallbackTableDestruct ()
 
void SelectLoopInit (void)
 Initialize the module on Squid startup. More...
 
void ResetSelect (int)
 reset/undo/unregister the watch for an FD which was set by Comm::SetSelect() More...
 
Comm::Flag DoSelect (int)
 Do poll and trigger callback functions as appropriate. More...
 
void QuickPollRequired (void)
 
void Read (const Comm::ConnectionPointer &conn, AsyncCall::Pointer &callback)
 
bool MonitorsRead (int fd)
 whether the FD socket is being monitored for read More...
 
Comm::Flag ReadNow (CommIoCbParams &params, SBuf &buf)
 
void ReadCancel (int fd, AsyncCall::Pointer &callback)
 Cancel the read pending on FD. No action if none pending. More...
 
void Write (const Comm::ConnectionPointer &conn, const char *buf, int size, AsyncCall::Pointer &callback, FREE *free_func)
 
void Write (const Comm::ConnectionPointer &conn, MemBuf *mb, AsyncCall::Pointer &callback)
 
void WriteCancel (const Comm::ConnectionPointer &conn, const char *reason)
 Cancel the write pending on FD. No action if none pending. More...
 

Variables

PF HandleWrite
 
CbEntryiocb_table
 
PF HandleRead
 callback handler to process an FD which is available for reading More...
 

Typedef Documentation

Definition at line 25 of file forward.h.

Enumeration Type Documentation

enum Comm::Flag
Enumerator
OK 
COMM_ERROR 
NOMESSAGE 
TIMEOUT 
SHUTDOWN 
IDLE 
INPROGRESS 
ERR_CONNECT 
ERR_DNS 
ERR_CLOSING 
ERR_PROTOCOL 
ENDFILE 

read(2) returned success, but with 0 bytes

ERR__END__ 

Definition at line 15 of file Flag.h.

Enumerator
IOCB_NONE 
IOCB_READ 
IOCB_WRITE 

Definition at line 22 of file IoCallback.h.

Function Documentation

void Comm::CallbackTableDestruct ( )
void Comm::CallbackTableInit ( )
Comm::Flag Comm::DoSelect ( int  msec)

Perform a select() or equivalent call. This is used by the main select loop engine to check for FD with IO available.

Check all connections for new connections and input data that is to be processed. Also check for connections with data queued and whether we can write it out.

Called to do the new-style IO, courtesy of of squid (like most of this new IO code). This routine handles the stuff we've hidden in comm_setselect and fd_table[] and calls callbacks for IO ready events.

Parameters
msecmilliseconds to poll for (limited by max_poll_time)

Check all connections for new connections and input data that is to be processed. Also check for connections with data queued and whether we can write it out.

Called to do the new-style IO, courtesy of of squid (like most of this new IO code). This routine handles the stuff we've hidden in comm_setselect and fd_table[] and calls callbacks for IO ready events.

Definition at line 324 of file ModDevPoll.cc.

References COMM_ERROR, comm_flush_updates(), COMM_SELECT_READ, COMM_SELECT_WRITE, StatHist::count(), DEBUG_DEVPOLL, debugs, devpoll_fd, do_poll, dpoll_nfds, F(), fd_table, fde::flags, getCurrentTime(), HERE(), i, ignoreErrno(), int, max_poll_time, NULL, OK, PROF_start, PROF_stop, fde::read_data, fde::read_handler, fde::_fde_flags::read_pending, StatCounters::select_fds, StatCounters::select_fds_hist, StatCounters::select_loops, SetSelect(), statCounter, _devpoll_state::state, TIMEOUT, fde::write_data, and fde::write_handler.

Referenced by CommSelectEngine::checkEvents().

bool Comm::IsConnOpen ( const Comm::ConnectionPointer conn)

Definition at line 24 of file Connection.cc.

References NULL.

Referenced by Mgr::StoreToCommWriter::Abort(), Ftp::Relay::abort(), FwdState::abort(), Ftp::Relay::abortOnData(), Comm::TcpAcceptor::acceptNext(), Format::Format::assemble(), clientReplyContext::buildReplyHeader(), Ftp::Server::callException(), ClientHttpRequest::callException(), Ftp::Server::checkDataConnPost(), Ftp::Server::checkDataConnPre(), IdentLookup::checkForAsync(), Snmp::Inquirer::cleanup(), Mgr::Inquirer::cleanup(), Mgr::Forwarder::cleanup(), clientCheckPinning(), clientLifetimeTimeout(), clientListenerConnectionOpened(), Ftp::Server::clientPinnedConnectionClosed(), clientProcessRequestFinished(), ClientRequestContext::clientRedirectDone(), clientSocketRecipient(), Server::clientWriteDone(), Ftp::Channel::close(), Mgr::StoreToCommWriter::close(), Ftp::Server::closeDataConnection(), TunnelStateData::Connection::closeIfOpen(), HttpStateData::closeServer(), Ftp::Client::closeServer(), comm_import_opened(), comm_init_opened(), comm_poll_udp_incoming(), comm_read_base(), comm_select_tcp_incoming(), comm_select_udp_incoming(), commSetConnTimeout(), FwdState::complete(), Ipc::UdsOp::conn(), Ftp::Client::connectDataChannel(), Ftp::Server::connectedForData(), FwdState::connectStart(), FwdState::connectTimeout(), CreateSession(), FwdState::dispatch(), ClientHttpRequest::doCallouts(), Server::doClientRead(), Server::doneAll(), Comm::TcpAcceptor::doneAll(), HttpStateData::doneWithServer(), Ftp::Client::doneWithServer(), ConnStateData::endingShutdown(), errorSend(), HttpStateData::finishingBrokenPost(), Ftp::Channel::forget(), Mgr::Forwarder::Forwarder(), Ftp::Gateway::ftpAcceptDataConnection(), ftpOpenListenSocket(), ftpReadList(), ftpReadRetr(), ftpSendPORT(), Adaptation::Icap::ServiceRep::getConnection(), gopherTimeout(), Ftp::Server::handleDataReply(), Ftp::Client::handleEpsvReply(), Mgr::Forwarder::handleException(), HttpStateData::handleMoreRequestBodyAvailable(), Ftp::Client::handlePasvReply(), FwdState::handleUnregisteredServerEnd(), Ftp::Gateway::haveControlChannel(), helperHandleRead(), helperServerFree(), helperStatefulHandleRead(), helperStatefulServerFree(), htcpClear(), htcpIncomingConnectionOpened(), htcpOpenPorts(), htcpQuery(), htcpSocketShutdown(), ConnStateData::httpsPeeked(), icpConnectionShutdown(), icpIncomingConnectionOpened(), icpOpenPorts(), idnsReadVC(), idnsReadVCHeader(), idnsSentQueryVC(), idnsShutdownAndFreeState(), IdleConnList::isAvailable(), ConnStateData::isOpen(), TunnelStateData::keepGoingAfterRead(), ConnStateData::kick(), DeferredReadManager::kickARead(), Ftp::Gateway::listenForDataChannel(), Ftp::Server::listenForDataConnection(), ACLIdent::match(), HttpStateData::maybeReadVirginBody(), Ftp::Client::maybeReadVirginBody(), Ftp::Relay::mayReadVirginReplyBody(), Security::PeerConnector::negotiate(), neighbors_init(), neighborsRegisterWithCacheManager(), neighborsUdpPing(), TunnelStateData::noConnections(), ClientHttpRequest::noteBodyProducerAborted(), Snmp::Inquirer::noteCommClosed(), Mgr::Inquirer::noteCommClosed(), Mgr::StoreToCommWriter::noteCommClosed(), Adaptation::Icap::ServiceRep::noteConnectionUse(), Adaptation::Icap::Xaction::openConnection(), Ftp::Channel::opened(), OpenedHttpSocket(), Ipc::Coordinator::openListenSocket(), FwdState::pconnPop(), peerSelectPinned(), HttpStateData::persistentConnStatus(), ConnStateData::pinConnection(), PconnPool::pop(), DeferredReadManager::popHead(), Security::PeerConnector::prepareSocket(), PeerPoolMgr::pushNewConnection(), Adaptation::Icap::ServiceRep::putConnection(), Ftp::Client::readControlReply(), HttpStateData::readReply(), Ftp::Gateway::readStor(), Ftp::Server::readUploadData(), ConnStateData::requestTimeout(), Mgr::FunAction::respond(), Mgr::InfoAction::respond(), Mgr::StoreToCommWriter::scheduleCommWrite(), Ftp::Client::scheduleReadControlReply(), send_announce(), Ftp::Client::sendEprt(), Client::sendMoreRequestBody(), HttpStateData::sendRequest(), Ftp::Relay::serverComplete(), Ipc::SharedListenJoined(), Ftp::Server::shovelUploadData(), snmpClosePorts(), snmpPortOpened(), ClientRequestContext::sslBumpAccessCheckDone(), Security::PeerConnector::sslCrtvdHandleReply(), Snmp::Inquirer::start(), Mgr::Inquirer::start(), Mgr::StoreToCommWriter::start(), Comm::TcpAcceptor::start(), start_announce(), TunnelStateData::startConnecting(), Ftp::Relay::startDataDownload(), Ftp::Relay::startDataUpload(), Ipc::StartListening(), statClientRequests(), Server::swanSong(), Comm::TcpAcceptor::swanSong(), Ident::IdentStateData::swanSong(), tunnelErrorComplete(), ConnStateData::unpinConnection(), FwdState::unregister(), ConnStateData::validatePinnedConnection(), TunnelStateData::writeClientDone(), Ftp::Client::writeCommand(), Ftp::Server::writeForwardedReplyAndCall(), TunnelStateData::writeServerDone(), FwdState::~FwdState(), Ftp::Gateway::~Gateway(), AnyP::PortCfg::~PortCfg(), and Ipc::UdsOp::~UdsOp().

bool Comm::MonitorsRead ( int  fd)

Definition at line 28 of file Read.cc.

References assert, COMMIO_FD_READCB, isOpen(), and NULL.

Referenced by HttpStateData::maybeReadVirginBody(), and fde::readPending().

void Comm::QuickPollRequired ( void  )

Definition at line 444 of file ModDevPoll.cc.

References max_poll_time.

Referenced by DiskdIOStrategy::init().

void Comm::Read ( const Comm::ConnectionPointer conn,
AsyncCall::Pointer callback 
)

Start monitoring for read.

callback is scheduled when the read is possible, or on file descriptor close.

Definition at line 39 of file Read.cc.

References comm_read_base(), and NULL.

Referenced by commHalfClosedCheck(), HttpStateData::maybeReadVirginBody(), Server::readSomeData(), Adaptation::Icap::Xaction::scheduleRead(), and ConnStateData::startPinnedConnectionMonitoring().

Comm::Flag Comm::ReadNow ( CommIoCbParams params,
SBuf buf 
)

Perform a read(2) on a connection immediately.

If params.size is non-zero will limit size of the read to either the buffer free space or params.size, whichever is smallest.

The returned flag is also placed in params.flag.

Return values
Comm::OKdata has been read and placed in buf, amount in params.size
Comm::COMM_ERRORan error occured, the code is placed in params.xerrno
Comm::INPROGRESSunable to read at this time, or a minor error occured
Comm::ENDFILE0-byte read has occured. Usually indicates the remote end has disconnected.

Definition at line 80 of file Read.cc.

References COMM_ERROR, CommCommonCbParams::conn, debugs, ENDFILE, Comm::Connection::fd, fd_bytes(), FD_READ, FD_READ_METHOD, CommCommonCbParams::flag, ignoreErrno(), INPROGRESS, OK, SBuf::rawAppendFinish(), SBuf::rawAppendStart(), CommIoCbParams::size, StatCounters::sock, SBuf::spaceSize(), statCounter, StatCounters::syscalls, CommCommonCbParams::xerrno, and xstrerr().

Referenced by Server::doClientRead(), Adaptation::Icap::Xaction::noteCommRead(), and HttpStateData::readReply().

void Comm::ResetSelect ( int  fd)

Clear polling of file handle (both read and write)

Parameters
fdfile descriptor to clear polling on

Definition at line 304 of file ModDevPoll.cc.

References COMM_SELECT_READ, COMM_SELECT_WRITE, NULL, and SetSelect().

void Comm::SelectLoopInit ( void  )

Initialise /dev/poll support.

Allocates memory, opens /dev/poll device handle.

Definition at line 178 of file ModDevPoll.cc.

References commDevPollRegisterWithCacheManager(), devpoll_fd, DEVPOLL_QUERYSIZE, devpoll_update, DEVPOLL_UPDATESIZE, do_poll, dpoll_nfds, fatalf(), fd_open(), FD_UNKNOWN, xcalloc, and xstrerr().

Referenced by comm_init().

void Comm::SetSelect ( int  fd,
unsigned int  type,
PF handler,
void *  client_data,
time_t  timeout 
)

Set polling state of file descriptor and callback functions.

Sets requested polling state for given file handle along with desired callback function in the event the request event triggers.

Note that setting a polling state with a NULL callback function will clear the polling for that event on that file descriptor.

Parameters
fdfile descriptor to change
typemay be COMM_SELECT_READ (input) or COMM_SELECT_WRITE (output)
handlercallback function, or NULL to stop type of polling
client_datapointer to be provided to call back function
timeoutif non-zero then timeout relative to now

This is a needed exported function which will be called to register and deregister interest in a pending IO state for a given FD.

Definition at line 225 of file ModDevPoll.cc.

References assert, COMM_SELECT_READ, COMM_SELECT_WRITE, comm_update_fd(), debugs, F(), fd_table, fde::flags, handler(), HERE(), NULL, fde::_fde_flags::open, fde::read_data, fde::read_handler, fde::_fde_flags::read_pending, squid_curtime, _devpoll_state::state, fde::timeout, fde::write_data, and fde::write_handler.

Referenced by _comm_close(), Comm::TcpAcceptor::acceptOne(), checkTimeouts(), Comm::ConnOpener::cleanFd(), clientTunnelOnError(), comm_read_base(), comm_read_cancel(), commHandleWriteHelper(), diskHandleRead(), diskHandleWrite(), Comm::TcpAcceptor::doAccept(), Comm::ConnOpener::doConnect(), ConnStateData::doPeekAndSpliceStep(), DoSelect(), fd_close(), htcpIncomingConnectionOpened(), htcpOpenPorts(), htcpRecv(), htcpSocketShutdown(), httpsEstablish(), icpConnectionShutdown(), icpHandleUdp(), icpIncomingConnectionOpened(), icpOpenPorts(), icpUdpSend(), idnsRead(), Dns::Init(), CommIO::Initialize(), logfileHandleWrite(), logfileQueueWrite(), Security::PeerConnector::noteWantRead(), Security::PeerConnector::noteWantWrite(), CommIO::NULLFDHandler(), IcmpSquid::Open(), ConnStateData::parseTlsHandshake(), ReadCancel(), IcmpSquid::Recv(), ResetSelect(), MessageBucket::scheduleWrite(), Comm::IoCallback::selectOrQueueWrite(), snmpHandleUdp(), snmpPortOpened(), Squid_SSL_accept(), Comm::TcpAcceptor::start(), wccp2ConnectionOpen(), wccp2HandleUdp(), wccpConnectionOpen(), and wccpHandleUdp().

void Comm::Write ( const Comm::ConnectionPointer conn,
MemBuf mb,
AsyncCall::Pointer callback 
)

Queue a write. callback is scheduled when the write completes, on error, or on file descriptor close.

Definition at line 29 of file Write.cc.

References MemBuf::buf, MemBuf::freeFunc(), MemBuf::size, and Write().

void Comm::WriteCancel ( const Comm::ConnectionPointer conn,
const char *  reason 
)

Variable Documentation

void Comm::HandleRead

Handle an FD which is ready for read(2).

If there is no provided buffer to fill call the callback.

Otherwise attempt a read into the provided buffer. If the read attempt succeeds or fails, call the callback. Else, wait for another IO notification.

Definition at line 125 of file Read.cc.

Referenced by comm_read_base().

void Comm::HandleWrite

Write to FD. This function is used by the lowest level of IO loop which only has access to FD numbers. We have to use the comm iocb_table to map FD numbers to waiting data and Comm::Connections. Once the write has been concluded we schedule the waiting call with success/fail results.

Definition at line 34 of file forward.h.

Referenced by checkTimeouts(), commHandleWriteHelper(), MessageBucket::scheduleWrite(), and Comm::IoCallback::selectOrQueueWrite().

Comm::CbEntry * Comm::iocb_table

Table of scheduled IO events which have yet to be processed ?? Callbacks which might be scheduled in future are stored in fd_table.

Definition at line 19 of file IoCallback.cc.

Referenced by CallbackTableDestruct(), and CallbackTableInit().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors