#include <Connection.h>

Inheritance diagram for Comm::Connection:
Collaboration diagram for Comm::Connection:

Public Types

typedef RefCount< CodeContextPointer

Public Member Functions

 Connection ()
virtual ~Connection ()
ConnectionPointer cloneIdentDetails () const
ConnectionPointer cloneDestinationDetails () const
void enterOrphanage ()
 close the still-open connection when its last reference is gone More...
void leaveOrphanage ()
 resume relying on owner(s) to initiate an explicit connection closure More...
void close ()
void noteClosure ()
bool isOpen () const
void setAddrs (const Ip::Address &aLocal, const Ip::Address &aRemote)
CachePeergetPeer () const
void setPeer (CachePeer *p)
time_t startTime () const
time_t lifeTime () const
time_t timeLeft (const time_t idleTimeout) const
time_t connectTimeout (const time_t fwdStart) const
void noteStart ()
Security::NegotiationHistorytlsNegotiations ()
const Security::NegotiationHistoryhasTlsNegotiations () const
virtual ScopedId codeContextGist () const override
virtual std::ostream & detailCodeContext (std::ostream &os) const override
 appends human-friendly context description line(s) to a cache.log record More...

Static Public Member Functions

static const PointerCurrent ()
static void Reset ()
 forgets the current context, setting it to nil/unknown More...
static void Reset (const Pointer)
 changes the current context; nil argument sets it to nil/unknown More...

Public Attributes

Ip::Address local
Ip::Address remote
hier_code peerType
int fd
tos_t tos
nfmark_t nfmark
nfmark_t nfConnmark = 0
int flags
char rfc931 [USER_IDENT_SZ]
Eui::Eui48 remoteEui48
Eui::Eui64 remoteEui64
InstanceId< Connection, uint64_t > id

Private Member Functions

 MEMPROXY_CLASS (Comm::Connection)
 Connection (const Connection &c)
Connectionoperator= (const Connection &c)

Static Private Member Functions

static void ForgetCurrent ()
static void Entering (const Pointer &codeCtx)
static void Leaving ()

Private Attributes

time_t startTime_

Detailed Description

Store data about the physical and logical attributes of a connection.

Some link state can be inferred from the data, however this is not an object for state data. But a semantic equivalent for FD with easily accessible cached properties not requiring repeated complex lookups.

Connection properties may be changed until the connection is opened. Properties should be considered read-only outside of the Comm layer code once the connection is open.

These objects should not be passed around directly, but a Comm::ConnectionPointer should be passed instead.

Definition at line 70 of file Connection.h.

Member Typedef Documentation

◆ Pointer

Definition at line 23 of file CodeContext.h.

Constructor & Destructor Documentation

◆ Connection() [1/2]

Comm::Connection::Connection ( )

Definition at line 31 of file Connection.cc.

References rfc931.

◆ ~Connection()

Comm::Connection::~Connection ( )

Clear the connection properties and close any open socket.

Definition at line 44 of file Connection.cc.

References cbdataReferenceDone, COMM_ORPHANED, debugs, and CachePeer::flags.

◆ Connection() [2/2]

Comm::Connection::Connection ( const Connection c)

These objects may not be exactly duplicated. Use cloneIdentDetails() or cloneDestinationDetails() instead.

Member Function Documentation

◆ cloneDestinationDetails()

Comm::ConnectionPointer Comm::Connection::cloneDestinationDetails ( ) const

Create a new (closed) Connection object pointing to the same destination as this from-Squid connection.

Definition at line 63 of file Connection.cc.

References assert, cbdataReference, CachePeer::flags, flags, isOpen(), peer_, peerType, and setAddrs().

◆ cloneIdentDetails()

Comm::ConnectionPointer Comm::Connection::cloneIdentDetails ( ) const

Create a new (closed) IDENT Connection object based on our from-Squid connection properties.

Definition at line 75 of file Connection.cc.

◆ close()

void Comm::Connection::close ( )

Close any open socket.

Definition at line 86 of file Connection.cc.

References comm_close, and isOpen().

Referenced by Ftp::Server::acceptDataConnection(), ConnStateData::afterClientRead(), ConnStateData::clientAfterReadingRequests(), TunnelStateData::clientClosed(), ConnStateData::clientPinnedConnectionClosed(), ConnStateData::clientPinnedConnectionRead(), TunnelStateData::closeConnections(), HelperServerBase::closePipesSafely(), HttpStateData::closeServer(), FwdState::closeServerConnection(), HelperServerBase::closeWritePipeSafely(), HappyConnOpener::connectDone(), Ftp::Server::connectedForData(), FwdState::dispatch(), ConnStateData::endingShutdown(), Ftp::Gateway::ftpAcceptDataConnection(), ConnStateData::getSslContextDone(), gopherReadReply(), gopherSendComplete(), gopherTimeout(), PeerPoolMgr::handleOpenedConnection(), ConnStateData::handleRequestBodyData(), Adaptation::Icap::Xaction::handleSecuredPeer(), PeerPoolMgr::handleSecuredPeer(), ConnStateData::handleSslBumpHandshakeError(), Mgr::StoreToCommWriter::HandleStoreAbort(), helperReturnBuffer(), httpsSslBumpAccessCheckDone(), httpsSslBumpStep2AccessCheckDone(), TunnelStateData::keepGoingAfterRead(), ConnStateData::kick(), ClientHttpRequest::noteBodyProducerAborted(), ConnStateData::parseTlsHandshake(), ConnStateData::requestTimeout(), TunnelStateData::retryOrBail(), ConnStateData::sendControlMsg(), ClientRequestContext::sslBumpAccessCheckDone(), ClientHttpRequest::sslBumpEstablish(), ConnStateData::stopReceiving(), ConnStateData::stopSending(), Server::swanSong(), ConnStateData::terminateAll(), tunnelErrorComplete(), whoisTimeout(), TunnelStateData::writeClientDone(), TunnelStateData::writeServerDone(), HttpControlMsgSink::wroteControlMsg(), Ftp::Server::wroteEarlyReply(), and Ftp::Server::wroteReply().

◆ codeContextGist()

ScopedId Comm::Connection::codeContextGist ( ) const
a small, permanent ID of the current context gists persist forever and are suitable for passing to other SMP workers

Implements CodeContext.

Definition at line 165 of file Connection.cc.

◆ connectTimeout()

time_t Comm::Connection::connectTimeout ( const time_t  fwdStart) const

Connection establishment timeout for callers that have already decided to connect(2), either for the first time or after checking EnoughTimeToReForward() during any re-forwarding attempts.

the time left for this connection to become connected
fwdStartThe start time of the peer selection/connection process.

Definition at line 145 of file Connection.cc.

References Config, SquidConfig::connect, CachePeer::connectTimeout(), FwdState::ForwardTimeout(), min(), and SquidConfig::Timeout.

Referenced by HappyConnOpener::openFreshConnection().

◆ Current()

◆ detailCodeContext()

std::ostream & Comm::Connection::detailCodeContext ( std::ostream &  os) const

Implements CodeContext.

Definition at line 170 of file Connection.cc.

References Debug::Extra().

◆ Entering()

void CodeContext::Entering ( const Pointer codeCtx)

Switches the current context to the given known context. Improves debugging output by replacing omni-directional "Reset" with directional "Entering".

Definition at line 54 of file CodeContext.cc.

References CodeContext::codeContextGist(), debugs, CodeContext::ForgetCurrent(), and Instance().

Referenced by CodeContext::Reset().

◆ enterOrphanage()

void Comm::Connection::enterOrphanage ( )

◆ ForgetCurrent()

void CodeContext::ForgetCurrent ( )

Forgets the current known context, possibly triggering its destruction. Preserves the gist of the being-forgotten context during its destruction. Knows nothing about the next context – the caller must set it.

Definition at line 42 of file CodeContext.cc.

References assert, FadingCodeContext::gist, and Instance().

Referenced by CodeContext::Entering(), and CodeContext::Leaving().

◆ getPeer()

◆ hasTlsNegotiations()

const Security::NegotiationHistory* Comm::Connection::hasTlsNegotiations ( ) const

Definition at line 137 of file Connection.h.

References tlsHistory.

Referenced by Format::Format::assemble().

◆ isOpen()

bool Comm::Connection::isOpen ( ) const

determine whether this object describes an active connection or not.

Definition at line 100 of file Connection.h.

References fd.

Referenced by ClientHttpRequest::ClientHttpRequest(), cloneDestinationDetails(), ClientHttpRequest::noteAdaptationAclCheckDone(), and HappyConnOpener::status().

◆ leaveOrphanage()

void Comm::Connection::leaveOrphanage ( )

◆ Leaving()

void CodeContext::Leaving ( )

Forgets the current known context. Improves debugging output by replacing omni-directional "Reset" with directional "Leaving".

Definition at line 66 of file CodeContext.cc.

References debugs, CodeContext::ForgetCurrent(), and Instance().

Referenced by CodeContext::Reset().

◆ lifeTime()

time_t Comm::Connection::lifeTime ( ) const

The connection lifetime

Definition at line 122 of file Connection.h.

References squid_curtime, and startTime_.


Comm::Connection::MEMPROXY_CLASS ( Comm::Connection  )

◆ noteClosure()

void Comm::Connection::noteClosure ( )

Synchronize with Comm: Somebody closed our connection.

Definition at line 95 of file Connection.cc.

References isOpen(), and peerConnClosed().

◆ noteStart()

void Comm::Connection::noteStart ( )

Definition at line 134 of file Connection.h.

References squid_curtime, and startTime_.

◆ operator=()

Connection& Comm::Connection::operator= ( const Connection c)

These objects may not be exactly duplicated. Use cloneIdentDetails() or cloneDestinationDetails() instead.

◆ Reset() [1/2]

◆ Reset() [2/2]

void CodeContext::Reset ( const Pointer  codeCtx)

◆ setAddrs()

void Comm::Connection::setAddrs ( const Ip::Address aLocal,
const Ip::Address aRemote 

Alter the stored IP address pair. WARNING: Does not ensure matching IPv4/IPv6 are supplied.

Definition at line 105 of file Connection.h.

References local, and remote.

Referenced by cloneDestinationDetails().

◆ setPeer()

void Comm::Connection::setPeer ( CachePeer p)

alter the stored CachePeer pointer. Perform appropriate CBDATA operations for locking the CachePeer pointer

Definition at line 114 of file Connection.cc.

References cbdataReference, and cbdataReferenceDone.

Referenced by PeerSelector::handlePath().

◆ startTime()

time_t Comm::Connection::startTime ( ) const

The time the connection started

Definition at line 119 of file Connection.h.

References startTime_.

Referenced by PeerPoolMgr::handleOpenedConnection().

◆ timeLeft()

time_t Comm::Connection::timeLeft ( const time_t  idleTimeout) const

The time left for this connection

Definition at line 127 of file Connection.cc.

References Config, min(), SquidConfig::pconnLifetime, and SquidConfig::Timeout.

Referenced by ConnStateData::readNextRequest().

◆ tlsNegotiations()

Security::NegotiationHistory * Comm::Connection::tlsNegotiations ( )

Definition at line 137 of file Connection.cc.

Referenced by ConnStateData::parseTlsHandshake().

Member Data Documentation

◆ fd

int Comm::Connection::fd

Socket used by this connection. Negative if not open.

Definition at line 165 of file Connection.h.

Referenced by ClientHttpRequest::ClientHttpRequest(), Mgr::Forwarder::Forwarder(), HttpStateData::HttpStateData(), Mgr::Inquirer::Inquirer(), Snmp::Inquirer::Inquirer(), Security::PeerConnector::PeerConnector(), Mgr::StoreToCommWriter::StoreToCommWriter(), Ftp::Server::AcceptCtrlConnection(), Ftp::Server::acceptDataConnection(), ConnStateData::acceptTls(), ConnStateData::afterClientRead(), ClientInfo::applyQuota(), ConnStateData::clientAfterReadingRequests(), ClientRequestContext::clientRedirectDone(), Server::clientWriteDone(), HelperServerBase::closePipesSafely(), HttpStateData::closeServer(), FwdState::closeServerConnection(), HelperServerBase::closeWritePipeSafely(), Ftp::Server::connectedForData(), FwdState::connectedToPeer(), DeferredReadManager::delayRead(), FwdState::dispatch(), Server::doClientRead(), ConnStateData::doPeekAndSpliceStep(), ftpOpenListenSocket(), ConnStateData::getSslContextDone(), ConnStateData::getSslContextStart(), gopherStart(), PeerPoolMgr::handleOpenedConnection(), Adaptation::Icap::Xaction::handleSecuredPeer(), PeerPoolMgr::handleSecuredPeer(), Ipc::Coordinator::handleSharedListenRequest(), helperHandleRead(), helperOpenServers(), helperStatefulHandleRead(), helperStatefulOpenServers(), httpAccept(), httpsAccept(), idnsDoSendQueryVC(), ConnStateData::isOpen(), isOpen(), ConnStateData::kick(), DeferredReadManager::kickARead(), ACLServerCertificateStrategy::match(), HttpStateData::maybeReadVirginBody(), Ip::Intercept::NetfilterInterception(), ClientHttpRequest::noteAdaptationAclCheckDone(), Snmp::Inquirer::noteCommClosed(), Adaptation::Icap::Xaction::noteCommConnected(), FwdState::noteConnection(), TunnelStateData::noteConnection(), TunnelStateData::noteSecurityPeerConnectorAnswer(), Comm::TcpAcceptor::oldAccept(), helper::packStatsInto(), ConnStateData::parseTlsHandshake(), ConnStateData::pinConnection(), DeferredReadManager::popHead(), HttpStateData::proceedAfter1xx(), HttpStateData::processReplyBody(), ConnStateData::readNextRequest(), Comm::ReadNow(), HttpStateData::readReply(), Ftp::Server::readUploadData(), ClientInfo::scheduleWrite(), MessageBucket::scheduleWrite(), Ipc::SharedListenJoined(), ConnStateData::splice(), ConnStateData::sslCrtdHandleReply(), ConnStateData::start(), ConnStateData::startPeekAndSplice(), HappyConnOpener::status(), Server::stopReading(), ConnStateData::storeTlsContextToCache(), CommIoCbParams::syncWithComm(), FwdState::syncWithServerConn(), FwdState::tunnelEstablishmentDone(), TunnelStateData::tunnelEstablishmentDone(), ConnStateData::tunnelOnError(), ConnStateData::whenClientIpKnown(), and whoisStart().

◆ flags

◆ id

InstanceId<Connection, uint64_t> Comm::Connection::id

Definition at line 193 of file Connection.h.

Referenced by Format::Format::assemble().

◆ local

◆ nfConnmark

nfmark_t Comm::Connection::nfConnmark = 0

Netfilter CONNMARK value previously retrieved from this connection In case of FTP, the CONNMARK will NOT be applied to data connections, for one main reason: the CONNMARK could be set by a third party like iptables and overwriting it in squid may cause side effects and break CONNMARK-based policy. In other words, data connection is related to control connection, but it's not the same.

Definition at line 181 of file Connection.h.

Referenced by Comm::TcpAcceptor::oldAccept().

◆ nfmark

nfmark_t Comm::Connection::nfmark

Netfilter MARK values currently sent on this connection In case of FTP, the MARK will be sent on data connections as well.

Definition at line 173 of file Connection.h.

Referenced by Format::Format::assemble().

◆ peer_

CachePeer* Comm::Connection::peer_

cache_peer data object (if any)

Definition at line 197 of file Connection.h.

Referenced by cloneDestinationDetails().

◆ peerType

hier_code Comm::Connection::peerType

Hierarchy code for this connection link

Definition at line 162 of file Connection.h.

Referenced by cloneDestinationDetails(), PeerSelector::handlePath(), and HierarchyLogEntry::resetPeerNotes().

◆ remote

◆ remoteEui48

Eui::Eui48 Comm::Connection::remoteEui48

Definition at line 189 of file Connection.h.

Referenced by Format::Format::assemble(), and Comm::TcpAcceptor::oldAccept().

◆ remoteEui64

Eui::Eui64 Comm::Connection::remoteEui64

Definition at line 190 of file Connection.h.

Referenced by Format::Format::assemble(), and Comm::TcpAcceptor::oldAccept().

◆ rfc931

◆ startTime_

time_t Comm::Connection::startTime_

The time the connection object was created

Definition at line 200 of file Connection.h.

Referenced by lifeTime(), noteStart(), and startTime().

◆ tlsHistory

Security::NegotiationHistory* Comm::Connection::tlsHistory

TLS connection details

Definition at line 203 of file Connection.h.

Referenced by hasTlsNegotiations().

◆ tos

tos_t Comm::Connection::tos

Quality of Service TOS values currently sent on this connection

Definition at line 168 of file Connection.h.

Referenced by Format::Format::assemble().

The documentation for this class was generated from the following files:






Web Site Translations