section 04 Error Generation
section 05 Comm
section 05 Listener Socket Handler
+section 05 Socket Connection Opener
section 05 Socket Functions
section 06 Disk I/O Routines
section 07 Multicast
http_port_list::http_port_list(const char *aProtocol)
#if USE_SSL
- : http(*this),
+ :
+ http(*this),
dynamicCertMemCacheSize(std::numeric_limits<size_t>::max())
#endif
{
if (context) {
debugs(33, 5, HERE << clientConnection << ": parsed a request");
AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "clientLifetimeTimeout",
- CommTimeoutCbPtrFun(clientLifetimeTimeout, context->http));
+ CommTimeoutCbPtrFun(clientLifetimeTimeout, context->http));
commSetConnTimeout(clientConnection, Config.Timeout.lifetime, timeoutCall);
clientProcessRequest(this, &parser_, context, method, http_ver);
#include "ipcache.h"
#include "SquidTime.h"
-namespace Comm {
- CBDATA_CLASS_INIT(ConnOpener);
+namespace Comm
+{
+CBDATA_CLASS_INIT(ConnOpener);
};
Comm::ConnOpener::ConnOpener(Comm::ConnectionPointer &c, AsyncCall::Pointer &handler, time_t ctimeout) :
failRetries_++;
// check for timeout FIRST.
- if(squid_curtime - connectStart_ > connectTimeout_) {
+ if (squid_curtime - connectStart_ > connectTimeout_) {
debugs(5, 5, HERE << conn_ << ": * - ERR took too long to receive response.");
calls_.earlyAbort_->cancel("Comm::ConnOpener::connect timed out");
calls_.earlyAbort_ = NULL;
#include "comm_err_t.h"
#include "comm/forward.h"
-namespace Comm {
+namespace Comm
+{
/**
* Async-opener of a Comm connection.
struct peer;
-namespace Comm {
+namespace Comm
+{
/* TODO: make these a struct of boolean flags members in the connection instead of a bitmap.
* we can't do that until all non-comm code uses Commm::Connection objects to create FD
fds[nfds++] = icpIncomingConn->fd;
if (icpIncomingConn != icpOutgoingConn && Comm::IsConnOpen(icpOutgoingConn))
- fds[nfds++] = icpOutgoingConn->fd;
+ fds[nfds++] = icpOutgoingConn->fd;
if (nfds == 0)
return;
#include "Array.h"
#include "RefCount.h"
-namespace Comm {
+namespace Comm
+{
class Connection;
/// \ingroup ErrorPageInternal
/// manages an error page template
-class ErrorPageFile: public TemplateFile {
+class ErrorPageFile: public TemplateFile
+{
public:
ErrorPageFile(const char *name): TemplateFile(name) { textBuf.init();}
bool strHdrAcptLangGetItem(const String &hdr, char *lang, int langLen, size_t &pos)
{
- while(pos < hdr.size()) {
+ while (pos < hdr.size()) {
char *dt = lang;
if (!pos) {
/* skip any initial whitespace. */
while (pos < hdr.size() && xisspace(hdr[pos])) pos++;
- }
- else {
+ } else {
// IFF we terminated the tag on whitespace or ';' we need to skip to the next ',' or end of header.
while (pos < hdr.size() && hdr[pos] != ',') pos++;
if (hdr[pos] == ',') pos++;
* loads text templates used for error pages and details;
* supports translation of templates
*/
-class TemplateFile {
+class TemplateFile
+{
public:
TemplateFile(const char *name);
- virtual ~TemplateFile(){}
+ virtual ~TemplateFile() {}
/// return true if the data loaded from disk without any problem
bool loaded() const {return wasLoaded;}
gopherState->serverConn = fwd->serverConnection();
gopherSendRequest(fwd->serverConnection()->fd, gopherState);
AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "gopherTimeout",
- CommTimeoutCbPtrFun(gopherTimeout, gopherState));
+ CommTimeoutCbPtrFun(gopherTimeout, gopherState));
commSetConnTimeout(fwd->serverConnection(), Config.Timeout.read, timeoutCall);
}
writePipe->close();
#ifdef _SQUID_MSWIN_
- if (hIpc) {
- if (WaitForSingleObject(hIpc, 5000) != WAIT_OBJECT_0) {
- getCurrentTime();
- debugs(84, DBG_IMPORTANT, "WARNING: " << hlp->id_name <<
- " #" << no << " (" << hlp->cmdline->key << "," <<
- (long int)pid << ") didn't exit in 5 seconds");
- }
- CloseHandle(hIpc);
+ if (hIpc) {
+ if (WaitForSingleObject(hIpc, 5000) != WAIT_OBJECT_0) {
+ getCurrentTime();
+ debugs(84, DBG_IMPORTANT, "WARNING: " << hlp->id_name <<
+ " #" << no << " (" << hlp->cmdline->key << "," <<
+ (long int)pid << ") didn't exit in 5 seconds");
}
+ CloseHandle(hIpc);
+ }
#endif
}
writePipe->close();
#ifdef _SQUID_MSWIN_
- if (hIpc) {
- if (WaitForSingleObject(hIpc, 5000) != WAIT_OBJECT_0) {
- getCurrentTime();
- debugs(84, DBG_IMPORTANT, "WARNING: " << hlp->id_name <<
- " #" << no << " (" << hlp->cmdline->key << "," <<
- (long int)pid << ") didn't exit in 5 seconds");
- }
- CloseHandle(hIpc);
+ if (hIpc) {
+ if (WaitForSingleObject(hIpc, 5000) != WAIT_OBJECT_0) {
+ getCurrentTime();
+ debugs(84, DBG_IMPORTANT, "WARNING: " << hlp->id_name <<
+ " #" << no << " (" << hlp->cmdline->key << "," <<
+ (long int)pid << ") didn't exit in 5 seconds");
}
+ CloseHandle(hIpc);
+ }
#endif
}
(void) 0;
} else
switch (persistentConnStatus()) {
- case INCOMPLETE_MSG:
- {
+ case INCOMPLETE_MSG: {
debugs(11, 5, "processReplyBody: INCOMPLETE_MSG from " << serverConnection);
/* Wait for more data or EOF condition */
AsyncCall::Pointer nil;
}
flags.do_next_read = 1;
- }
- break;
+ }
+ break;
case COMPLETE_PERSISTENT_MSG:
debugs(11, 5, "processReplyBody: COMPLETE_PERSISTENT_MSG from " << serverConnection);
AsyncCall::Pointer nil;
Comm::Write(conn, &mb, nil);
AsyncCall::Pointer readCall = commCbCall(5,4, "Ident::ReadReply",
- CommIoCbPtrFun(Ident::ReadReply, state));
+ CommIoCbPtrFun(Ident::ReadReply, state));
comm_read(conn, state->buf, IDENT_BUFSIZE, readCall);
AsyncCall::Pointer timeoutCall = commCbCall(5,4, "Ident::Timeout",
- CommTimeoutCbPtrFun(Ident::Timeout, state));
+ CommTimeoutCbPtrFun(Ident::Timeout, state));
commSetConnTimeout(conn, Ident::TheConfig.timeout, timeoutCall);
}
namespace Qos
{
- /**
- * Function to retrieve the TOS value of the inbound packet.
- * Called by FwdState::dispatch if QOS options are enabled.
- * Bug 2537: This part of ZPH only applies to patched Linux kernels
- * @param server Server side descriptor of connection to get TOS for
- * @param clientFde Pointer to client side fde instance to set tosFromServer in
- */
- void getTosFromServer(const Comm::ConnectionPointer &server, fde *clientFde);
+/**
+* Function to retrieve the TOS value of the inbound packet.
+* Called by FwdState::dispatch if QOS options are enabled.
+* Bug 2537: This part of ZPH only applies to patched Linux kernels
+* @param server Server side descriptor of connection to get TOS for
+* @param clientFde Pointer to client side fde instance to set tosFromServer in
+*/
+void getTosFromServer(const Comm::ConnectionPointer &server, fde *clientFde);
- /**
- * Function to retrieve the netfilter mark value of the connection
- * to the upstream server. Called by FwdState::dispatch if QOS
- * options are enabled.
- * @param server Server side descriptor of connection to get mark for
- * @param clientFde Pointer to client side fde instance to set nfmarkFromServer in
- */
- void getNfmarkFromServer(const Comm::ConnectionPointer &server, const fde *clientFde);
+/**
+* Function to retrieve the netfilter mark value of the connection
+* to the upstream server. Called by FwdState::dispatch if QOS
+* options are enabled.
+* @param server Server side descriptor of connection to get mark for
+* @param clientFde Pointer to client side fde instance to set nfmarkFromServer in
+*/
+void getNfmarkFromServer(const Comm::ConnectionPointer &server, const fde *clientFde);
#if USE_LIBNETFILTERCONNTRACK
- /**
- * Callback function to mark connection once it's been found.
- * This function is called by the libnetfilter_conntrack
- * libraries, during nfct_query in Ip::Qos::getNfmarkFromServer.
- * nfct_callback_register is used to register this function.
- * @param nf_conntrack_msg_type Type of conntrack message
- * @param nf_conntrack Pointer to the conntrack structure
- * @param clientFde Pointer to client side fde instance to set nfmarkFromServer in
- */
- int getNfMarkCallback(enum nf_conntrack_msg_type type, struct nf_conntrack *ct, void *clientFde);
+/**
+* Callback function to mark connection once it's been found.
+* This function is called by the libnetfilter_conntrack
+* libraries, during nfct_query in Ip::Qos::getNfmarkFromServer.
+* nfct_callback_register is used to register this function.
+* @param nf_conntrack_msg_type Type of conntrack message
+* @param nf_conntrack Pointer to the conntrack structure
+* @param clientFde Pointer to client side fde instance to set nfmarkFromServer in
+*/
+int getNfMarkCallback(enum nf_conntrack_msg_type type, struct nf_conntrack *ct, void *clientFde);
#endif
- /**
- * Function to work out and then apply to the socket the appropriate
- * TOS value to set on packets when items have not been retrieved from
- * local cache. Called by clientReplyContext::sendMoreData if QOS is
- * enabled for TOS.
- * @param conn Descriptor of socket to set the TOS for
- * @param hierCode Hier code of request
- */
- int doTosLocalMiss(const Comm::ConnectionPointer &conn, const hier_code hierCode);
+/**
+* Function to work out and then apply to the socket the appropriate
+* TOS value to set on packets when items have not been retrieved from
+* local cache. Called by clientReplyContext::sendMoreData if QOS is
+* enabled for TOS.
+* @param conn Descriptor of socket to set the TOS for
+* @param hierCode Hier code of request
+*/
+int doTosLocalMiss(const Comm::ConnectionPointer &conn, const hier_code hierCode);
- /**
- * Function to work out and then apply to the socket the appropriate
- * netfilter mark value to set on packets when items have not been
- * retrieved from local cache. Called by clientReplyContext::sendMoreData
- * if QOS is enabled for TOS.
- * @param conn Descriptor of socket to set the mark for
- * @param hierCode Hier code of request
- */
- int doNfmarkLocalMiss(const Comm::ConnectionPointer &conn, const hier_code hierCode);
+/**
+* Function to work out and then apply to the socket the appropriate
+* netfilter mark value to set on packets when items have not been
+* retrieved from local cache. Called by clientReplyContext::sendMoreData
+* if QOS is enabled for TOS.
+* @param conn Descriptor of socket to set the mark for
+* @param hierCode Hier code of request
+*/
+int doNfmarkLocalMiss(const Comm::ConnectionPointer &conn, const hier_code hierCode);
- /**
- * Function to work out and then apply to the socket the appropriate
- * TOS value to set on packets when items *have* been retrieved from
- * local cache. Called by clientReplyContext::doGetMoreData if QOS is
- * enabled for TOS.
- * @param conn Descriptor of socket to set the TOS for
- */
- int doTosLocalHit(const Comm::ConnectionPointer &conn);
+/**
+* Function to work out and then apply to the socket the appropriate
+* TOS value to set on packets when items *have* been retrieved from
+* local cache. Called by clientReplyContext::doGetMoreData if QOS is
+* enabled for TOS.
+* @param conn Descriptor of socket to set the TOS for
+*/
+int doTosLocalHit(const Comm::ConnectionPointer &conn);
- /**
- * Function to work out and then apply to the socket the appropriate
- * netfilter mark value to set on packets when items *have* been
- * retrieved from local cache. Called by clientReplyContext::doGetMoreData
- * if QOS is enabled for TOS.
- * @param conn Descriptor of socket to set the mark for
- */
- int doNfmarkLocalHit(const Comm::ConnectionPointer &conn);
+/**
+* Function to work out and then apply to the socket the appropriate
+* netfilter mark value to set on packets when items *have* been
+* retrieved from local cache. Called by clientReplyContext::doGetMoreData
+* if QOS is enabled for TOS.
+* @param conn Descriptor of socket to set the mark for
+*/
+int doNfmarkLocalHit(const Comm::ConnectionPointer &conn);
- /**
- * Function to set the TOS value of packets. Sets the value on the socket
- * which then gets copied to the packets.
- * @param conn Descriptor of socket to set the TOS for
- */
- _SQUID_INLINE_ int setSockTos(const Comm::ConnectionPointer &conn, tos_t tos);
+/**
+* Function to set the TOS value of packets. Sets the value on the socket
+* which then gets copied to the packets.
+* @param conn Descriptor of socket to set the TOS for
+*/
+_SQUID_INLINE_ int setSockTos(const Comm::ConnectionPointer &conn, tos_t tos);
- /**
- * Function to set the netfilter mark value of packets. Sets the value on the
- * socket which then gets copied to the packets. Called from Ip::Qos::doNfmarkLocalMiss
- * @param conn Descriptor of socket to set the mark for
- */
- _SQUID_INLINE_ int setSockNfmark(const Comm::ConnectionPointer &conn, nfmark_t mark);
+/**
+* Function to set the netfilter mark value of packets. Sets the value on the
+* socket which then gets copied to the packets. Called from Ip::Qos::doNfmarkLocalMiss
+* @param conn Descriptor of socket to set the mark for
+*/
+_SQUID_INLINE_ int setSockNfmark(const Comm::ConnectionPointer &conn, nfmark_t mark);
/**
* QOS configuration class. Contains all the parameters for QOS functions as well
Listeners::const_iterator i = listeners.find(request.params);
int errNo = 0;
const Comm::ConnectionPointer c = (i != listeners.end()) ?
- i->second : openListenSocket(request, errNo);
+ i->second : openListenSocket(request, errNo);
debugs(54, 3, HERE << "sending shared listen " << c << " for " <<
request.params.addr << " to kid" << request.requestorId <<
#ifndef _SQUID_IPCACHE_H
#define _SQUID_IPCACHE_H
-namespace Ip {
+namespace Ip
+{
class Address;
}
parent_->noteConnectionRemoved();
}
// shuffle the list N down.
- for (;index < (size_t)size_; index++) {
+ for (; index < (size_t)size_; index++) {
theList_[index - n] = theList_[index];
}
// ensure the last N entries are unset
theList_[size_++] = conn;
AsyncCall::Pointer readCall = commCbCall(5,4, "IdleConnList::Read",
- CommIoCbPtrFun(IdleConnList::Read, this));
+ CommIoCbPtrFun(IdleConnList::Read, this));
comm_read(conn, fakeReadBuf_, sizeof(fakeReadBuf_), readCall);
AsyncCall::Pointer timeoutCall = commCbCall(5,4, "IdleConnList::Read",
- CommTimeoutCbPtrFun(IdleConnList::Timeout, this));
+ CommTimeoutCbPtrFun(IdleConnList::Timeout, this));
commSetConnTimeout(conn, Config.Timeout.pconn, timeoutCall);
}
// for TPROXY we must skip unusable addresses.
if (psstate->request->flags.spoof_client_ip && !(fs->_peer && fs->_peer->options.no_tproxy) ) {
- if(ia->in_addrs[n].IsIPv4() != psstate->request->client_addr.IsIPv4()) {
+ if (ia->in_addrs[n].IsIPv4() != psstate->request->client_addr.IsIPv4()) {
// we CAN'T spoof the address on this link. find another.
continue;
}
#include <map>
#endif
-struct SslErrorEntry{
+struct SslErrorEntry {
Ssl::ssl_error_t value;
const char *name;
};
{
/// manages error detail templates
-class ErrorDetailFile : public TemplateFile{
+class ErrorDetailFile : public TemplateFile
+{
public:
explicit ErrorDetailFile(ErrorDetailsList::Pointer const details): TemplateFile("error-details.txt") {
- buf.init(); theDetails = details;
+ buf.init();
+ theDetails = details;
}
private:
Cache::iterator it;
it = cache.find(lang);
if (it != cache.end()) {
- debugs(83, 8, HERE << "Found template details in cache for language: " << lang);
- return it->second;
+ debugs(83, 8, HERE << "Found template details in cache for language: " << lang);
+ return it->second;
}
return NULL;
debugs(83, 8, HERE << "Creating new ErrDetailList to read from disk");
errDetails = new ErrorDetailsList();
ErrorDetailFile detailTmpl(errDetails);
- if(detailTmpl.loadFor(request)) {
+ if (detailTmpl.loadFor(request)) {
if (detailTmpl.language()) {
debugs(83, 8, HERE << "Found details on disk for language " << detailTmpl.language());
errDetails->errLanguage = detailTmpl.language();
}
// Use HttpHeaders parser to parse error-details.txt files
-class DetailEntryParser: public HttpHeader {
+class DetailEntryParser: public HttpHeader
+{
public:
DetailEntryParser():HttpHeader(hoErrorDetail) {}
};
//ignore spaces, new lines and comment lines (starting with #) at the beggining
const char *s;
for (s = buf.content(); (*s == '\n' || *s == ' ' || *s == '\t' || *s == '#') && s < e; s++) {
- if(*s == '#')
- while(s<e && *s != '\n') s++; // skip untill the end of line
+ if (*s == '#')
+ while (s<e && *s != '\n') s++; // skip untill the end of line
}
if ( s != e) {
namespace Ssl
{
-class ErrorDetailEntry {
+class ErrorDetailEntry
+{
public:
Ssl::ssl_error_t error_no; ///< The SSL error code
String name; ///< a name for the error
* It is used to load, manage and query multiple ErrorDetailLists
* objects.
*/
-class ErrorDetailsManager {
+class ErrorDetailsManager
+{
public:
ErrorDetailsManager();
/* Bump the source connection read timeout on any activity */
if (Comm::IsConnOpen(from.conn)) {
AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "tunnelTimeout",
- CommTimeoutCbPtrFun(tunnelTimeout, this));
+ CommTimeoutCbPtrFun(tunnelTimeout, this));
commSetConnTimeout(from.conn, Config.Timeout.read, timeoutCall);
}
}
AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "tunnelTimeout",
- CommTimeoutCbPtrFun(tunnelTimeout, tunnelState));
+ CommTimeoutCbPtrFun(tunnelTimeout, tunnelState));
commSetConnTimeout(conn, Config.Timeout.read, timeoutCall);
}
tunnelState);
AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "tunnelTimeout",
- CommTimeoutCbPtrFun(tunnelTimeout, tunnelState));
+ CommTimeoutCbPtrFun(tunnelTimeout, tunnelState));
commSetConnTimeout(tunnelState->client.conn, Config.Timeout.lifetime, timeoutCall);
peerSelect(&(tunnelState->serverDestinations), request,
mb.append("\r\n", 2);
AsyncCall::Pointer writeCall = commCbCall(5,5, "tunnelConnectedWriteDone",
- CommIoCbPtrFun(tunnelConnectedWriteDone, tunnelState));
+ CommIoCbPtrFun(tunnelConnectedWriteDone, tunnelState));
Comm::Write(srv, &mb, writeCall);
AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "tunnelTimeout",
- CommTimeoutCbPtrFun(tunnelTimeout, tunnelState));
+ CommTimeoutCbPtrFun(tunnelTimeout, tunnelState));
commSetConnTimeout(srv, Config.Timeout.read, timeoutCall);
}
snprintf(buf, l, SQUIDSTRINGPH"\r\n", SQUIDSTRINGPRINT(str_print));
AsyncCall::Pointer writeCall = commCbCall(5,5, "whoisWriteComplete",
- CommIoCbPtrFun(whoisWriteComplete, p));
+ CommIoCbPtrFun(whoisWriteComplete, p));
Comm::Write(fwd->serverConnection(), buf, strlen(buf), writeCall, NULL);
AsyncCall::Pointer readCall = commCbCall(5,4, "whoisReadReply",
- CommIoCbPtrFun(whoisReadReply, p));
+ CommIoCbPtrFun(whoisReadReply, p));
comm_read(fwd->serverConnection(), p->buf, BUFSIZ, readCall);
AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "whoisTimeout",
- CommTimeoutCbPtrFun(whoisTimeout, p));
+ CommTimeoutCbPtrFun(whoisTimeout, p));
commSetConnTimeout(fwd->serverConnection(), Config.Timeout.read, timeoutCall);
}