#include <Connection.h>

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

Public Types

typedef RefCount< CodeContextPointer
 

Public Member Functions

 Connection ()
 
 ~Connection () override
 
 Connection (const Connection &&)=delete
 
ConnectionPointer cloneProfile () const
 Create a new closed Connection with the same configuration as this one. More...
 
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
 
ScopedId codeContextGist () const override
 
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
 
Stopwatch busyTime
 time spent in this context (see also: busy_time) More...
 

Private Member Functions

 MEMPROXY_CLASS (Comm::Connection)
 

Static Private Member Functions

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

Private Attributes

CachePeerpeer_
 
time_t startTime_
 
Security::NegotiationHistorytlsHistory
 

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 72 of file Connection.h.

Member Typedef Documentation

◆ Pointer

Definition at line 55 of file CodeContext.h.

Constructor & Destructor Documentation

◆ Connection() [1/2]

Comm::Connection::Connection ( )

Definition at line 32 of file Connection.cc.

References rfc931.

◆ ~Connection()

Comm::Connection::~Connection ( )
override

Clear the connection properties and close any open socket.

Definition at line 45 of file Connection.cc.

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

◆ Connection() [2/2]

Comm::Connection::Connection ( const Connection &&  )
delete

To prevent accidental copying of Connection objects that we started to open or that are open, use cloneProfile() instead.

Member Function Documentation

◆ cloneProfile()

Comm::ConnectionPointer Comm::Connection::cloneProfile ( ) const

Definition at line 64 of file Connection.cc.

References assert, cbdataReference, debugs, and CachePeer::flags.

Referenced by HappyConnOpener::openFreshConnection().

◆ close()

void Comm::Connection::close ( )

Close any open socket.

Definition at line 105 of file Connection.cc.

References comm_close, and isOpen().

Referenced by Ftp::Server::acceptDataConnection(), Comm::TcpAcceptor::acceptOne(), ConnStateData::clientAfterReadingRequests(), TunnelStateData::clientClosed(), ConnStateData::clientPinnedConnectionClosed(), ConnStateData::clientPinnedConnectionRead(), TunnelStateData::closeConnections(), HttpStateData::closeServer(), FwdState::closeServerConnection(), FwdState::dispatch(), ConnStateData::endingShutdown(), Ftp::Gateway::ftpAcceptDataConnection(), ConnStateData::getSslContextDone(), PeerPoolMgr::handleOpenedConnection(), ConnStateData::handleRequestBodyData(), PeerPoolMgr::handleSecuredPeer(), ConnStateData::handleSslBumpHandshakeError(), Mgr::StoreToCommWriter::HandleStoreAbort(), httpsSslBumpAccessCheckDone(), httpsSslBumpStep2AccessCheckDone(), TunnelStateData::keepGoingAfterRead(), ConnStateData::kick(), ClientHttpRequest::noteBodyProducerAborted(), ConnStateData::parseRequests(), ConnStateData::parseTlsHandshake(), ConnStateData::requestTimeout(), TunnelStateData::retryOrBail(), ConnStateData::sendControlMsg(), snmpClosePorts(), 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
overridevirtual
Returns
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 184 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.

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

Definition at line 164 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
overridevirtual

Implements CodeContext.

Definition at line 189 of file Connection.cc.

References Debug::Extra().

◆ Entering()

void CodeContext::Entering ( const Pointer codeCtx)
staticprivateinherited

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

Definition at line 55 of file CodeContext.cc.

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

Referenced by CodeContext::Reset().

◆ enterOrphanage()

void Comm::Connection::enterOrphanage ( )
inline

◆ ForgetCurrent()

void CodeContext::ForgetCurrent ( )
staticprivateinherited

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, and Instance().

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

◆ getPeer()

◆ hasTlsNegotiations()

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

Definition at line 138 of file Connection.h.

References tlsHistory.

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

◆ isOpen()

bool Comm::Connection::isOpen ( ) const
inline

◆ leaveOrphanage()

void Comm::Connection::leaveOrphanage ( )
inline

◆ Leaving()

void CodeContext::Leaving ( )
staticprivateinherited

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

Definition at line 68 of file CodeContext.cc.

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

Referenced by CodeContext::Reset().

◆ lifeTime()

time_t Comm::Connection::lifeTime ( ) const
inline

The connection lifetime

Definition at line 123 of file Connection.h.

References squid_curtime, and startTime_.

◆ MEMPROXY_CLASS()

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

◆ noteClosure()

void Comm::Connection::noteClosure ( )

◆ noteStart()

void Comm::Connection::noteStart ( )
inline

Definition at line 135 of file Connection.h.

References squid_curtime, and startTime_.

◆ Reset() [1/2]

◆ Reset() [2/2]

void CodeContext::Reset ( const Pointer  codeCtx)
staticinherited

◆ setAddrs()

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

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

Definition at line 106 of file Connection.h.

References local, and remote.

◆ setPeer()

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

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

Definition at line 133 of file Connection.cc.

References cbdataReference, and cbdataReferenceDone.

Referenced by PeerSelector::handlePath().

◆ startTime()

time_t Comm::Connection::startTime ( ) const
inline

The time the connection started

Definition at line 120 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 146 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 156 of file Connection.cc.

Referenced by ConnStateData::parseTlsHandshake().

Member Data Documentation

◆ busyTime

Stopwatch CodeContext::busyTime
inherited

Definition at line 76 of file CodeContext.h.

Referenced by Format::Format::assemble(), and CodeContext::Entering().

◆ fd

int Comm::Connection::fd

Socket used by this connection. Negative if not open.

Definition at line 155 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(), Comm::TcpAcceptor::acceptInto(), ConnStateData::acceptTls(), ConnStateData::afterClientRead(), ClientInfo::applyQuota(), ConnStateData::clientAfterReadingRequests(), ClientRequestContext::clientRedirectDone(), Server::clientWriteDone(), HttpStateData::closeServer(), FwdState::closeServerConnection(), comm_poll_udp_incoming(), comm_select_udp_incoming(), commHalfClosedCheck(), Ftp::Server::connectedForData(), FwdState::connectedToPeer(), FwdState::dispatch(), Server::doClientRead(), ConnStateData::doPeekAndSpliceStep(), fdIsUdpListen(), fdIsUdpListener(), IdleConnList::findIndexOf(), ftpOpenListenSocket(), ConnStateData::getSslContextDone(), ConnStateData::getSslContextStart(), Ipc::Coordinator::handleCacheMgrRequest(), Adaptation::Icap::Xaction::handleSecuredPeer(), PeerPoolMgr::handleSecuredPeer(), Ipc::Coordinator::handleSharedListenRequest(), helperStatefulHandleRead(), htcpOpenPorts(), htcpSend(), htcpSocketShutdown(), httpAccept(), httpsAccept(), httpsEstablish(), icpConnectionShutdown(), icpOpenPorts(), idnsDoSendQueryVC(), ConnStateData::isOpen(), isOpen(), HttpStateData::maybeReadVirginBody(), mcastJoinGroups(), neighborsUdpPing(), Ip::Intercept::NetfilterInterception(), Snmp::Inquirer::noteCommClosed(), FwdState::noteConnection(), TunnelStateData::noteConnection(), TunnelStateData::noteSecurityPeerConnectorAnswer(), statefulhelper::openSessions(), ConnStateData::parseRequests(), ConnStateData::parseTlsHandshake(), peerCountMcastPeersCreateAndSend(), ConnStateData::pinConnection(), HttpStateData::proceedAfter1xx(), HttpStateData::processReplyBody(), ConnStateData::readNextRequest(), Comm::ReadNow(), HttpStateData::readReply(), Ftp::Server::readUploadData(), Mgr::Action::respond(), ClientInfo::scheduleWrite(), MessageBucket::scheduleWrite(), FwdState::serverClosed(), snmpPortOpened(), ConnStateData::splice(), ConnStateData::sslCrtdHandleReply(), ConnStateData::start(), ConnStateData::startPeekAndSplice(), Server::stopReading(), ConnStateData::storeTlsContextToCache(), switchToTunnel(), CommConnectCbParams::syncWithComm(), 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 183 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 171 of file Connection.h.

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

◆ 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 163 of file Connection.h.

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

◆ peer_

CachePeer* Comm::Connection::peer_
private

cache_peer data object (if any)

Definition at line 187 of file Connection.h.

◆ peerType

hier_code Comm::Connection::peerType

Hierarchy code for this connection link

Definition at line 152 of file Connection.h.

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

◆ remote

◆ remoteEui48

Eui::Eui48 Comm::Connection::remoteEui48

Definition at line 179 of file Connection.h.

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

◆ remoteEui64

Eui::Eui64 Comm::Connection::remoteEui64

Definition at line 180 of file Connection.h.

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

◆ rfc931

◆ startTime_

time_t Comm::Connection::startTime_
private

The time the connection object was created

Definition at line 190 of file Connection.h.

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

◆ tlsHistory

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

TLS connection details

Definition at line 193 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 158 of file Connection.h.

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


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors