Go to the source code of this file.
Classes | |
class | CommSelectEngine |
Namespaces | |
namespace | Ip |
Macros | |
#define | comm_close(x) (_comm_close((x), __FILE__, __LINE__)) |
Functions | |
bool | comm_iocallbackpending (void) |
int | commSetNonBlocking (int fd) |
int | commUnsetNonBlocking (int fd) |
void | commSetCloseOnExec (int fd) |
void | _comm_close (int fd, char const *file, int line) |
void | old_comm_reset_close (int fd) |
void | comm_reset_close (const Comm::ConnectionPointer &conn) |
int | comm_connect_addr (int sock, const Ip::Address &addr) |
void | comm_init (void) |
void | comm_exit (void) |
int | comm_open (int, int, Ip::Address &, int, const char *note) |
int | comm_open_uds (int sock_type, int proto, struct sockaddr_un *addr, int flags) |
Create a unix-domain socket (UDS) that only supports FD_MSGHDR I/O. More... | |
void | comm_import_opened (const Comm::ConnectionPointer &, const char *note, struct addrinfo *AI) |
update Comm state after getting a comm_open() FD from another process More... | |
int | comm_open_listener (int sock_type, int proto, Ip::Address &addr, int flags, const char *note) |
void | comm_open_listener (int sock_type, int proto, Comm::ConnectionPointer &conn, const char *note) |
unsigned short | comm_local_port (int fd) |
int | comm_udp_sendto (int sock, const Ip::Address &to, const void *buf, int buflen) |
void | commCallCloseHandlers (int fd) |
void | commUnsetFdTimeout (int fd) |
clear a timeout handler by FD number More... | |
int | commSetConnTimeout (const Comm::ConnectionPointer &conn, time_t seconds, AsyncCall::Pointer &callback) |
int | commUnsetConnTimeout (const Comm::ConnectionPointer &conn) |
int | ignoreErrno (int) |
void | commCloseAllSockets (void) |
void | checkTimeouts (void) |
AsyncCall::Pointer | comm_add_close_handler (int fd, CLCB *, void *) |
void | comm_add_close_handler (int fd, AsyncCall::Pointer &) |
void | comm_remove_close_handler (int fd, CLCB *, void *) |
void | comm_remove_close_handler (int fd, AsyncCall::Pointer &) |
int | comm_udp_recvfrom (int fd, void *buf, size_t len, int flags, Ip::Address &from) |
int | comm_udp_recv (int fd, void *buf, size_t len, int flags) |
ssize_t | comm_udp_send (int s, const void *buf, size_t len, int flags) |
bool | comm_has_incomplete_write (int) |
void | commStartHalfClosedMonitor (int fd) |
Start waiting for a possibly half-closed connection to close. More... | |
bool | commHasHalfClosedMonitor (int fd) |
checks whether we are waiting for possibly half-closed connection to close More... | |
void | commMarkHalfClosed (int fd) |
bool | commIsHalfClosed (int fd) |
Macro Definition Documentation
◆ comm_close
#define comm_close | ( | x | ) | (_comm_close((x), __FILE__, __LINE__)) |
Function Documentation
◆ _comm_close()
Definition at line 846 of file comm.cc.
References assert, asyncCall(), callDialer(), comm_close_complete(), comm_empty_os_read_buffers(), COMM_SELECT_READ, COMM_SELECT_WRITE, commCallCloseHandlers(), commHasHalfClosedMonitor(), COMMIO_FD_READCB, COMMIO_FD_WRITECB, commStartTlsClose(), commStopHalfClosedMonitor(), commUnsetFdTimeout(), DBG_IMPORTANT, debugs, Comm::ERR_CLOSING, F(), FD_FILE, fd_table, isOpen(), reconfiguring, ScheduleCallHere, BandwidthBucket::SelectBucket(), Comm::SetSelect(), shutting_down, and Squid_MaxFD.
◆ checkTimeouts()
void checkTimeouts | ( | void | ) |
Definition at line 1527 of file comm.cc.
References AlreadyTimedOut(), Biggest_FD, comm_close, Comm::COMM_ERROR, COMM_SELECT_WRITE, COMMIO_FD_WRITECB, conn, debugs, F(), fd_table, Comm::HandleWrite, CodeContext::Reset(), ScheduleCallHere, Comm::SetSelect(), and writeTimedOut().
Referenced by CommSelectEngine::checkEvents().
◆ comm_add_close_handler() [1/2]
void comm_add_close_handler | ( | int | fd, |
AsyncCall::Pointer & | call | ||
) |
Definition at line 961 of file comm.cc.
References debugs, fd_table, and AsyncCall::setNext().
◆ comm_add_close_handler() [2/2]
AsyncCall::Pointer comm_add_close_handler | ( | int | fd, |
CLCB * | handler, | ||
void * | data | ||
) |
Definition at line 949 of file comm.cc.
References comm_add_close_handler(), commCbCall(), debugs, and handler().
Referenced by Mgr::Forwarder::Forwarder(), Snmp::Forwarder::Forwarder(), HttpStateData::HttpStateData(), Mgr::Inquirer::Inquirer(), Snmp::Inquirer::Inquirer(), Security::PeerConnector::PeerConnector(), Mgr::StoreToCommWriter::StoreToCommWriter(), comm_add_close_handler(), Log::TcpLogger::connectDone(), Comm::ConnOpener::createFd(), idnsInitVCConnected(), TunnelStateData::Connection::initConnection(), Ftp::Channel::opened(), Helper::Client::openSessions(), statefulhelper::openSessions(), ConnStateData::pinConnection(), Comm::TcpAcceptor::setListen(), ConnStateData::start(), FwdState::syncWithServerConn(), Adaptation::Icap::Xaction::useIcapConnection(), Http::Tunneler::watchForClosures(), and whoisStart().
◆ comm_connect_addr()
int comm_connect_addr | ( | int | sock, |
const Ip::Address & | address | ||
) |
Connect socket FD to given remote address. If return value is an error flag (COMM_ERROR, ERR_CONNECT, ERR_PROTOCOL, etc.), then error code will also be returned in errno.
Definition at line 634 of file comm.cc.
References assert, Comm::COMM_ERROR, StatCounters::connects, DBG_DATA, debugs, Comm::ERR_PROTOCOL, F(), fd_table, Ip::Address::FreeAddr(), Ip::Address::getAddrInfo(), ignoreErrno(), Comm::INPROGRESS, Ip::Address::isIPv4(), MAX_IPSTRLEN, Comm::OK, Ip::Address::port(), StatCounters::sock, statCounter, StatCounters::syscalls, Ip::Address::toStr(), and xstrerr().
Referenced by Comm::ConnOpener::doConnect(), ipc_thread_1(), ipcCreate(), and logfile_mod_udp_open().
◆ comm_exit()
void comm_exit | ( | void | ) |
Definition at line 1189 of file comm.cc.
References Comm::CallbackTableDestruct(), and TheHalfClosed.
Referenced by SquidShutdown().
◆ comm_has_incomplete_write()
bool comm_has_incomplete_write | ( | int | fd | ) |
Definition at line 151 of file comm.cc.
References assert, COMMIO_FD_WRITECB, and isOpen().
Referenced by PconnPool::push().
◆ comm_import_opened()
void comm_import_opened | ( | const Comm::ConnectionPointer & | conn, |
const char * | note, | ||
struct addrinfo * | AI | ||
) |
Definition at line 542 of file comm.cc.
References assert, comm_init_opened(), COMM_NOCLOEXEC, COMM_NONBLOCKING, COMM_TRANSPARENT, conn, debugs, fd_table, and Comm::IsConnOpen().
Referenced by Ipc::ImportFdIntoComm(), and Ipc::SharedListenJoined().
◆ comm_init()
void comm_init | ( | void | ) |
Definition at line 1166 of file comm.cc.
References assert, Comm::CallbackTableInit(), fd_table, Comm::AcceptLimiter::Instance(), min(), RESERVED_FD, Comm::SelectLoopInit(), Squid_MaxFD, and TheHalfClosed.
Referenced by TestUfs::commonInit(), and SquidMain().
◆ comm_iocallbackpending()
bool comm_iocallbackpending | ( | void | ) |
◆ comm_local_port()
unsigned short comm_local_port | ( | int | fd | ) |
Queue a write. handler/handler_data are called when the write fully completes, on error, or on file descriptor close.
Definition at line 164 of file comm.cc.
References DBG_IMPORTANT, debugs, F(), fd_table, Ip::Address::FreeAddr(), Ip::Address::InitAddr(), MYNAME, Ip::Address::port(), Ip::Address::setIPv4(), and xstrerr().
Referenced by comm_udp_sendto(), Dns::Init(), Ftp::Server::listenForDataConnection(), and Ftp::Client::sendEprt().
◆ comm_open()
int comm_open | ( | int | sock_type, |
int | proto, | ||
Ip::Address & | addr, | ||
int | flags, | ||
const char * | note | ||
) |
Create a socket. Default is blocking, stream (TCP) socket. IO_TYPE is OR of flags specified in comm.h. Defaults TOS
Definition at line 242 of file comm.cc.
References COMM_DOBIND, COMM_DOBIND_PORT_LATER, comm_openex(), Ip::Address::isAnyAddr(), and Ip::Address::port().
Referenced by Comm::ConnOpener::createFd(), ipc_thread_1(), ipcCreate(), and logfile_mod_udp_open().
◆ comm_open_listener() [1/2]
void comm_open_listener | ( | int | sock_type, |
int | proto, | ||
Comm::ConnectionPointer & | conn, | ||
const char * | note | ||
) |
Definition at line 256 of file comm.cc.
References COMM_DOBIND, comm_openex(), and conn.
Referenced by htcpOpenPorts(), icpOpenPorts(), Dns::Init(), ipcCreate(), Ftp::Gateway::listenForDataChannel(), Ftp::Server::listenForDataConnection(), Ipc::Coordinator::openListenSocket(), Ipc::StartListening(), wccp2ConnectionOpen(), and wccpConnectionOpen().
◆ comm_open_listener() [2/2]
int comm_open_listener | ( | int | sock_type, |
int | proto, | ||
Ip::Address & | addr, | ||
int | flags, | ||
const char * | note | ||
) |
Open a port specially bound for listening or sending through a specific port. Please use for all listening sockets and bind() outbound sockets.
It will open a socket bound for:
- IPv4 if IPv6 is disabled or address is IPv4-native.
- IPv6 if address is IPv6-native
- IPv6 dual-stack mode if able to open [::]
When an open performs failover it update the given address to feedback the new IPv4-only status of the socket. Further displays of the IP (in debugs or cachemgr) will occur in Native IPv4 format. A reconfigure is needed to reset the stored IP in most cases and attempt a port re-open.
Definition at line 269 of file comm.cc.
References COMM_DOBIND, and comm_openex().
◆ comm_open_uds()
int comm_open_uds | ( | int | sock_type, |
int | proto, | ||
struct sockaddr_un * | addr, | ||
int | flags | ||
) |
Definition at line 1710 of file comm.cc.
References assert, comm_close, COMM_DOBIND, COMM_NOCLOEXEC, COMM_NONBLOCKING, COMM_REUSEADDR, commBind(), commSetCloseOnExec(), commSetNonBlocking(), commSetReuseAddr(), commSetTcpRcvbuf(), Config, DBG_CRITICAL, DBG_IMPORTANT, debugs, FD_MSGHDR, fd_open(), fd_table, fdAdjustReserved(), isOpen(), limitError(), MYNAME, Comm::OK, StatCounters::sock, StatCounters::sockets, statCounter, SUN_LEN, sockaddr_un::sun_path, StatCounters::syscalls, SquidConfig::tcpRcvBufsz, and xstrerr().
Referenced by Ipc::UdsOp::conn().
◆ comm_remove_close_handler() [1/2]
void comm_remove_close_handler | ( | int | fd, |
AsyncCall::Pointer & | call | ||
) |
Definition at line 1007 of file comm.cc.
References assert, AsyncCall::cancel(), debugs, AsyncCall::dequeue(), fd_table, isOpen(), and AsyncCall::Next().
◆ comm_remove_close_handler() [2/2]
Definition at line 978 of file comm.cc.
References assert, AsyncCall::cancel(), debugs, AsyncCall::dequeue(), fd_table, RefCount< C >::getRaw(), handler(), isOpen(), and AsyncCall::Next().
Referenced by Ident::IdentStateData::~IdentStateData(), Comm::ConnOpener::cleanFd(), Snmp::Inquirer::cleanup(), Ftp::Channel::close(), Mgr::StoreToCommWriter::close(), Adaptation::Icap::Xaction::closeConnection(), HttpStateData::closeServer(), FwdState::closeServerConnection(), Http::Tunneler::disconnect(), Log::TcpLogger::disconnect(), Security::PeerConnector::disconnect(), Ftp::Channel::forget(), HttpStateData::proceedAfter1xx(), HttpStateData::processReplyBody(), Mgr::Inquirer::removeCloseHandler(), Comm::TcpAcceptor::swanSong(), Mgr::Forwarder::swanSong(), Snmp::Forwarder::swanSong(), ConnStateData::unpinConnection(), and FwdState::unregister().
◆ comm_reset_close()
void comm_reset_close | ( | const Comm::ConnectionPointer & | conn | ) |
enable linger with time of 0 so that when the socket is closed, TCP generates a RESET
Definition at line 785 of file comm.cc.
References conn, DBG_CRITICAL, debugs, and xstrerr().
Referenced by ConnStateData::abortChunkedRequestBody(), clientProcessRequestFinished(), Adaptation::Icap::ServiceRep::putConnection(), and ConnStateData::setAuth().
◆ comm_udp_recv()
Definition at line 138 of file comm.cc.
References comm_udp_recvfrom().
Referenced by ipcCreate(), and IcmpSquid::Recv().
◆ comm_udp_recvfrom()
int comm_udp_recvfrom | ( | int | fd, |
void * | buf, | ||
size_t | len, | ||
int | flags, | ||
Ip::Address & | from | ||
) |
synchronous wrapper around udp socket functions
Definition at line 125 of file comm.cc.
References debugs, Ip::Address::FreeAddr(), Ip::Address::InitAddr(), StatCounters::recvfroms, StatCounters::sock, statCounter, and StatCounters::syscalls.
Referenced by comm_udp_recv(), htcpRecv(), icpHandleUdp(), idnsRead(), snmpHandleUdp(), wccp2HandleUdp(), and wccpHandleUdp().
◆ comm_udp_send()
Definition at line 145 of file comm.cc.
Referenced by ipcCreate(), IcmpSquid::SendEcho(), wccpAssignBuckets(), and wccpHereIam().
◆ comm_udp_sendto()
int comm_udp_sendto | ( | int | sock, |
const Ip::Address & | to, | ||
const void * | buf, | ||
int | buflen | ||
) |
Definition at line 918 of file comm.cc.
References Comm::COMM_ERROR, comm_local_port(), DBG_IMPORTANT, debugs, fd_table, Ip::Address::FreeAddr(), Ip::Address::getAddrInfo(), MYNAME, StatCounters::sendtos, StatCounters::sock, statCounter, StatCounters::syscalls, and xstrerr().
Referenced by htcpSend(), icpUdpSend(), idnsSendQuery(), Snmp::Forwarder::sendError(), Snmp::Inquirer::sendResponse(), snmpConstructReponse(), wccp2AssignBuckets(), and wccp2HereIam().
◆ commCallCloseHandlers()
void commCallCloseHandlers | ( | int | fd | ) |
Definition at line 759 of file comm.cc.
References AsyncCall::canceled(), debugs, F(), fd_table, AsyncCall::Next(), ScheduleCallHere, and AsyncCall::setNext().
Referenced by _comm_close(), and examine_select().
◆ commCloseAllSockets()
void commCloseAllSockets | ( | void | ) |
Definition at line 1470 of file comm.cc.
References Biggest_FD, debugs, F(), FD_SOCKET, fd_table, old_comm_reset_close(), and ScheduleCallHere.
Referenced by SquidShutdown().
◆ commHasHalfClosedMonitor()
bool commHasHalfClosedMonitor | ( | int | fd | ) |
Definition at line 1630 of file comm.cc.
References DescriptorSet::has(), and TheHalfClosed.
Referenced by _comm_close(), commHalfClosedReader(), commIsHalfClosed(), and commStartHalfClosedMonitor().
◆ commIsHalfClosed()
|
inline |
Definition at line 95 of file comm.h.
References commHasHalfClosedMonitor().
Referenced by ConnStateData::clientAfterReadingRequests(), and ConnStateData::parseRequests().
◆ commMarkHalfClosed()
|
inline |
Definition at line 94 of file comm.h.
References commStartHalfClosedMonitor().
Referenced by Server::doClientRead().
◆ commSetCloseOnExec()
void commSetCloseOnExec | ( | int | fd | ) |
Definition at line 1127 of file comm.cc.
References DBG_CRITICAL, debugs, dummy, fd_table, MYNAME, and xstrerr().
Referenced by Comm::TcpAcceptor::acceptInto(), comm_apply_flags(), comm_open_uds(), file_open(), ipcCreate(), and DiskThreadsDiskFile::openDone().
◆ commSetConnTimeout()
int commSetConnTimeout | ( | const Comm::ConnectionPointer & | conn, |
time_t | seconds, | ||
AsyncCall::Pointer & | callback | ||
) |
Set or clear the timeout for some action on an active connection. API to replace commSetTimeout() when a Comm::ConnectionPointer is available.
Definition at line 595 of file comm.cc.
References assert, conn, debugs, F(), fd_table, Comm::IsConnOpen(), squid_curtime, and Squid_MaxFD.
Referenced by TunnelStateData::TunnelStateData(), commUnsetConnTimeout(), ConnStateData::extendLifetime(), idnsDoSendQueryVC(), TunnelStateData::keepGoingAfterRead(), Ftp::Client::maybeReadVirginBody(), Security::PeerConnector::noteWantRead(), Helper::Client::openSessions(), HttpStateData::processReplyBody(), IdleConnList::push(), Http::Tunneler::readMore(), Helper::Session::requestTimeout(), ConnStateData::resetReadTimeout(), Ftp::Client::scheduleReadControlReply(), HttpStateData::sendComplete(), HttpStateData::sendRequest(), Ipc::UdsOp::setTimeout(), Http::One::Server::start(), Ftp::Client::switchTimeoutToDataChannel(), tunnelStartShoveling(), Adaptation::Icap::Xaction::updateTimeout(), and whoisStart().
◆ commSetNonBlocking()
Definition at line 1066 of file comm.cc.
References Comm::COMM_ERROR, DBG_CRITICAL, debugs, dummy, fd_table, MYNAME, SQUID_NONBLOCK, TRUE, and xstrerr().
Referenced by Comm::TcpAcceptor::acceptInto(), comm_apply_flags(), comm_open_uds(), DiskdIOStrategy::init(), CommIO::Initialize(), ipcCreate(), logfile_mod_daemon_flush(), Helper::Client::openSessions(), and statefulhelper::openSessions().
◆ commStartHalfClosedMonitor()
void commStartHalfClosedMonitor | ( | int | fd | ) |
The read channel has closed and the caller does not expect more data but needs to detect connection aborts. The current detection method uses 0-length reads: We read until the error occurs or the writer closes the connection. If there is a read error, we close the connection.
Definition at line 1580 of file comm.cc.
References DescriptorSet::add(), assert, commHasHalfClosedMonitor(), commPlanHalfClosedCheck(), CodeContext::Current(), debugs, fd_table, isOpen(), and TheHalfClosed.
Referenced by commMarkHalfClosed().
◆ commUnsetConnTimeout()
int commUnsetConnTimeout | ( | const Comm::ConnectionPointer & | conn | ) |
Definition at line 621 of file comm.cc.
References commSetConnTimeout(), conn, debugs, and Store::nil.
Referenced by IdleConnList::clearHandlers(), Ipc::UdsOp::clearTimeout(), Adaptation::Icap::Xaction::closeConnection(), Http::Tunneler::disconnect(), Security::PeerConnector::disconnect(), Ftp::Channel::forget(), HttpStateData::processReplyBody(), Ftp::Client::readControlReply(), Ftp::Client::scheduleReadControlReply(), Ftp::Client::switchTimeoutToDataChannel(), and Adaptation::Icap::Xaction::updateTimeout().
◆ commUnsetFdTimeout()
void commUnsetFdTimeout | ( | int | fd | ) |
Definition at line 582 of file comm.cc.
References assert, debugs, F(), fd_table, and Squid_MaxFD.
Referenced by _comm_close(), DiskdIOStrategy::init(), ipcCreate(), IcmpSquid::Open(), and unlinkdInit().
◆ commUnsetNonBlocking()
Definition at line 1099 of file comm.cc.
References Comm::COMM_ERROR, DBG_CRITICAL, debugs, dummy, FALSE, fd_table, MYNAME, SQUID_NONBLOCK, and xstrerr().
Referenced by ipc_thread_1(), logfile_mod_daemon_flush(), and unlinkdInit().
◆ ignoreErrno()
Definition at line 1440 of file comm.cc.
Referenced by Comm::TcpAcceptor::acceptInto(), comm_connect_addr(), Ftp::Client::dataRead(), TunnelStateData::Connection::debugLevelForError(), diskHandleRead(), diskHandleWrite(), Comm::DoSelect(), TunnelStateData::Connection::error(), icpHandleUdp(), idnsRead(), logfileHandleWrite(), Ssl::Bio::read(), Ftp::Client::readControlReply(), Comm::ReadNow(), WhoisState::readReply(), and Ssl::Bio::write().
◆ old_comm_reset_close()
void old_comm_reset_close | ( | int | fd | ) |
Definition at line 800 of file comm.cc.
References comm_close, DBG_CRITICAL, debugs, and xstrerr().
Referenced by commCloseAllSockets().