#include "squid.h"
#include "fde.h"
+#include "comm/Connection.h"
#include "CommCalls.h"
/* CommCommonCbParams */
#ifndef SQUID_COMMCALLS_H
#define SQUID_COMMCALLS_H
-#include "comm.h"
-#include "comm/Connection.h"
#include "base/AsyncCall.h"
#include "base/AsyncJobCalls.h"
+#include "comm/comm_err_t.h"
+#include "comm/forward.h"
/* CommCalls implement AsyncCall interface for comm_* callbacks.
* The classes cover two call dialer kinds:
* - I/O (IOCB).
*/
+typedef void IOACB(int fd, int nfd, Comm::ConnectionPointer details, comm_err_t flag, int xerrno, void *data);
+typedef void CNCB(Comm::ConnectionPointer conn, Comm::PathsPointer paths, comm_err_t status, int xerrno, void *data);
+typedef void IOCB(int fd, char *, size_t size, comm_err_t flag, int xerrno, void *data);
+
/*
* TODO: When there are no function-pointer-based callbacks left, all
* this complexity can be removed. Jobs that need comm services will just
void print(std::ostream &os) const;
public:
- Comm::Connection::Pointer details;
+ Comm::ConnectionPointer details;
int nfd; // TODO: rename to fdNew or somesuch
};
void print(std::ostream &os) const;
public:
- Comm::Connection::Pointer conn;
- Vector<Comm::Connection::Pointer> *paths;
+ Comm::ConnectionPointer conn;
+ Comm::PathsPointer paths;
};
// read/write (I/O) parameters
#include "Array.h"
#include "cbdata.h"
-#include "comm/Connection.h"
+#include "comm/forward.h"
+#include "hier_code.h"
#include "ip/Address.h"
#include "PingData.h"
class HttpRequest;
class StoreEntry;
-typedef void PSC(Vector<Comm::Connection::Pointer> *, void *);
+typedef void PSC(Comm::PathsPointer, void *);
-SQUIDCEXTERN void peerSelect(Vector<Comm::Connection::Pointer> *, HttpRequest *, StoreEntry *, PSC *, void *data);
+SQUIDCEXTERN void peerSelect(Comm::PathsPointer, HttpRequest *, StoreEntry *, PSC *, void *data);
SQUIDCEXTERN void peerSelectInit(void);
/**
PSC *callback;
void *callback_data;
- Vector<Comm::Connection::Pointer> *paths; ///< the callers paths array. to be filled with our final results.
- FwdServer *servers; ///< temporary linked list of peers we will pass back.
+ Comm::PathsPointer paths; ///< the callers paths array. to be filled with our final results.
+ FwdServer *servers; ///< temporary linked list of peers we will pass back.
/*
* Why are these Ip::Address instead of peer *? Because a
disableRetries(); // we only retry pconn failures
- Comm::Connection::Pointer conn = new Comm::Connection;
+ Comm::ConnectionPointer conn = new Comm::Connection;
// TODO: where do we get the DNS info for the ICAP server host ??
// Ip::Address will do a BLOCKING lookup if s.cfg().host is a hostname
/** Handle a new connection on HTTP socket. */
void
-httpAccept(int sock, int newfd, Comm::Connection::Pointer details,
+httpAccept(int sock, int newfd, Comm::ConnectionPointer details,
comm_err_t flag, int xerrno, void *data)
{
http_port_list *s = (http_port_list *)data;
/** Create SSL connection structure and update fd_table */
static SSL *
-httpsCreate(int newfd, Comm::Connection::Pointer details, SSL_CTX *sslContext)
+httpsCreate(int newfd, Comm::ConnectionPointer details, SSL_CTX *sslContext)
{
SSL *ssl = SSL_new(sslContext);
/** handle a new HTTPS connection */
static void
-httpsAccept(int sock, int newfd, Comm::Connection::Pointer details,
+httpsAccept(int sock, int newfd, Comm::ConnectionPointer details,
comm_err_t flag, int xerrno, void *data)
{
https_port_list *s = (https_port_list *)data;
* Close the socket fd in use by a connection.
*/
void
-_comm_close(Comm::Connection::Pointer conn, char const *file, int line)
+_comm_close(Comm::ConnectionPointer conn, char const *file, int line)
{
_comm_close(conn->fd, file, line);
conn->fd = -1;
#define __COMM_H__
#include "squid.h"
-#include "Array.h"
#include "AsyncEngine.h"
#include "base/AsyncCall.h"
+#include "CommCalls.h"
#include "comm/comm_err_t.h"
-#include "comm/Connection.h"
+#include "comm/forward.h"
#include "ip/Address.h"
#include "StoreIOBuffer.h"
#define COMMIO_FD_READCB(fd) (&commfd_table[(fd)].readcb)
#define COMMIO_FD_WRITECB(fd) (&commfd_table[(fd)].writecb)
-typedef void CNCB(Comm::Connection::Pointer conn, Vector<Comm::Connection::Pointer> *paths, comm_err_t status, int xerrno, void *data);
-typedef void IOCB(int fd, char *, size_t size, comm_err_t flag, int xerrno, void *data);
-
/* comm.c */
extern bool comm_iocallbackpending(void); /* inline candidate */
SQUIDCEXTERN void commSetCloseOnExec(int fd);
SQUIDCEXTERN void commSetTcpKeepalive(int fd, int idle, int interval, int timeout);
extern void _comm_close(int fd, char const *file, int line);
-extern void _comm_close(Comm::Connection::Pointer conn, char const *file, int line);
+extern void _comm_close(Comm::ConnectionPointer conn, char const *file, int line);
#define comm_close(x) (_comm_close((x), __FILE__, __LINE__))
SQUIDCEXTERN void comm_reset_close(int fd);
#if LINGERING_CLOSE
SQUIDCEXTERN comm_err_t comm_select(int);
SQUIDCEXTERN void comm_quick_poll_required(void);
-#include "comm/Connection.h"
-typedef void IOACB(int fd, int nfd, Comm::Connection::Pointer details, comm_err_t flag, int xerrno, void *data);
+//typedef void IOACB(int fd, int nfd, Comm::ConnectionPointer details, comm_err_t flag, int xerrno, void *data);
extern void comm_add_close_handler(int fd, PF *, void *);
extern void comm_add_close_handler(int fd, AsyncCall::Pointer &);
extern void comm_remove_close_handler(int fd, PF *, void *);
#include "config.h"
#include "comm/ConnectStateData.h"
+#include "comm/Connection.h"
#include "comm.h"
#include "CommCalls.h"
#include "fde.h"
CBDATA_CLASS_INIT(ConnectStateData);
-ConnectStateData::ConnectStateData(Vector<Comm::Connection::Pointer> *paths, AsyncCall::Pointer handler) :
+ConnectStateData::ConnectStateData(Comm::PathsPointer paths, AsyncCall::Pointer handler) :
host(NULL),
connect_timeout(Config.Timeout.connect),
paths(paths),
connstart(0)
{}
-ConnectStateData::ConnectStateData(Comm::Connection::Pointer c, AsyncCall::Pointer handler) :
+ConnectStateData::ConnectStateData(Comm::ConnectionPointer c, AsyncCall::Pointer handler) :
host(NULL),
connect_timeout(Config.Timeout.connect),
paths(NULL),
void
ConnectStateData::connect()
{
- Comm::Connection::Pointer active;
+ Comm::ConnectionPointer active;
/* handle connecting to one single path */
/* mainly used by components other than forwarding */
if (solo != NULL) {
active = solo;
} else if (paths) {
- Vector<Comm::Connection::Pointer>::iterator i = paths->begin();
+ Comm::Paths::iterator i = paths->begin();
if (connstart == 0) {
connstart = squid_curtime;
#ifndef _SQUID_SRC_COMM_CONNECTSTATEDATA_H
#define _SQUID_SRC_COMM_CONNECTSTATEDATA_H
-#include "Array.h"
#include "base/AsyncCall.h"
#include "cbdata.h"
#include "comm/comm_err_t.h"
-#include "comm/Connection.h"
+#include "comm/forward.h"
/**
* State engine handling the opening of a remote outbound connection
{
public:
/** open first working of a set of connections */
- ConnectStateData(Vector<Comm::Connection::Pointer> *paths, AsyncCall::Pointer handler);
+ ConnectStateData(Comm::PathsPointer paths, AsyncCall::Pointer handler);
/** attempt to open one connection. */
- ConnectStateData(Comm::Connection::Pointer, AsyncCall::Pointer handler);
+ ConnectStateData(Comm::ConnectionPointer, AsyncCall::Pointer handler);
~ConnectStateData();
time_t connect_timeout;
private:
- Vector<Comm::Connection::Pointer> *paths; ///< forwarding paths to be tried. front of the list is the current being opened.
- Comm::Connection::Pointer solo; ///< single connection currently being opened.
- AsyncCall::Pointer callback; ///< handler to be called on connection completion.
+ Comm::PathsPointer paths; ///< forwarding paths to be tried. front of the list is the current being opened.
+ Comm::ConnectionPointer solo; ///< single connection currently being opened.
+ AsyncCall::Pointer callback; ///< handler to be called on connection completion.
int total_tries; ///< total number of connection attempts over all destinations so far.
int fail_retries; ///< number of retries current destination has been tried.
/* ensure we have a cbdata reference to _peer not a straight ptr copy. */
_peer = cbdataReference(c._peer);
+
+ return *this;
}
Comm::Connection::~Connection()
* outside of the Comm layer code.
*
* These objects must not be passed around directly,
- * but a Comm::Connection::Pointer must be passed instead.
+ * but a Comm::ConnectionPointer must be passed instead.
*/
class Connection : public RefCountable
{
public:
- typedef RefCount<Comm::Connection> Pointer;
-
/** standard empty connection creation */
Connection();
}
void
-Comm::ListenStateData::notify(int newfd, comm_err_t errcode, int xerrno, Comm::Connection::Pointer connDetails)
+Comm::ListenStateData::notify(int newfd, comm_err_t errcode, int xerrno, Comm::ConnectionPointer connDetails)
{
// listener socket handlers just abandon the port with COMM_ERR_CLOSING
// it should only happen when this object is deleted...
#include "config.h"
#include "base/AsyncCall.h"
-#include "comm.h"
+#include "comm/comm_err_t.h"
+#include "comm/forward.h"
+
#if HAVE_MAP
#include <map>
#endif
void subscribe(AsyncCall::Pointer &call);
void acceptNext();
- void notify(int newfd, comm_err_t, int xerrno, Comm::Connection::Pointer);
+ void notify(int newfd, comm_err_t, int xerrno, Comm::ConnectionPointer);
int fd;
Connection.cc \
Connection.h \
comm_err_t.h \
- comm_internal.h
+ comm_internal.h \
+ forward.h
--- /dev/null
+#ifndef _SQUID_COMM_FORWARD_H
+#define _SQUID_COMM_FORWARD_H
+
+#include "Array.h"
+#include "RefCount.h"
+
+namespace Comm {
+
+class Connection;
+
+typedef RefCount<Comm::Connection> ConnectionPointer;
+
+typedef Vector<Comm::ConnectionPointer> Paths;
+typedef Vector<Comm::ConnectionPointer>* PathsPointer;
+
+}; // namespace Comm
+
+#endif /* _SQUID_COMM_FORWARD_H */
}
static void
-idnsInitVCConnected(Comm::Connection::Pointer conn, Vector<Comm::Connection::Pointer> *unused, comm_err_t status, int xerrno, void *data)
+idnsInitVCConnected(Comm::ConnectionPointer conn, Comm::PathsPointer unused, comm_err_t status, int xerrno, void *data)
{
nsvc * vc = (nsvc *)data;
vc->msg = new MemBuf;
vc->busy = 1;
- Comm::Connection::Pointer conn = new Comm::Connection;
+ Comm::ConnectionPointer conn = new Comm::Connection;
if (!Config.Addrs.udp_outgoing.IsNoAddr())
conn->local = Config.Addrs.udp_outgoing;
#include "acl/FilledChecklist.h"
#include "acl/Gadgets.h"
#include "CacheManager.h"
+#include "comm/Connection.h"
#include "comm/ConnectStateData.h"
#include "CommCalls.h"
#include "event.h"
/**** CALLBACK WRAPPERS ************************************************************/
static void
-fwdStartCompleteWrapper(Vector<Comm::Connection::Pointer> *unused, void *data)
+fwdStartCompleteWrapper(Comm::PathsPointer unused, void *data)
{
FwdState *fwd = (FwdState *) data;
fwd->startComplete();
#endif
void
-fwdConnectDoneWrapper(Comm::Connection::Pointer conn, Vector<Comm::Connection::Pointer> *paths, comm_err_t status, int xerrno, void *data)
+fwdConnectDoneWrapper(Comm::ConnectionPointer conn, Comm::PathsPointer paths, comm_err_t status, int xerrno, void *data)
{
FwdState *fwd = (FwdState *) data;
fwd->connectDone(conn, paths, status, xerrno);
#endif
void
-FwdState::connectDone(Comm::Connection::Pointer conn, Vector<Comm::Connection::Pointer> *result_paths, comm_err_t status, int xerrno)
+FwdState::connectDone(Comm::ConnectionPointer conn, Comm::PathsPointer result_paths, comm_err_t status, int xerrno)
{
assert(result_paths == &paths);
if (n_tries == 0) // first attempt
request->hier.first_conn_start = current_time;
- Comm::Connection::Pointer conn = paths[0];
+ Comm::ConnectionPointer conn = paths[0];
/* connection timeout */
int ctimeout;
* - address of the client for which we made the connection
*/
void
-FwdState::pconnPush(Comm::Connection::Pointer conn, const peer *_peer, const HttpRequest *req, const char *domain, Ip::Address &client_addr)
+FwdState::pconnPush(Comm::ConnectionPointer conn, const peer *_peer, const HttpRequest *req, const char *domain, Ip::Address &client_addr)
{
if (_peer) {
fwdPconnPool->push(conn->fd, _peer->name, _peer->http_port, domain, client_addr);
}
void
-getOutgoingAddress(HttpRequest * request, Comm::Connection::Pointer conn)
+getOutgoingAddress(HttpRequest * request, Comm::ConnectionPointer conn)
{
/* skip if an outgoing address is already set. */
if (!conn->local.IsAnyAddr()) return;
bool reforwardableStatus(http_status s);
void serverClosed(int fd);
void connectStart();
- void connectDone(Comm::Connection::Pointer conn, Vector<Comm::Connection::Pointer> *paths, comm_err_t status, int xerrno);
+ void connectDone(Comm::ConnectionPointer conn, Comm::PathsPointer paths, comm_err_t status, int xerrno);
void connectTimeout(int fd);
void initiateSSL();
void negotiateSSL(int fd);
bool checkRetry();
bool checkRetriable();
void dispatch();
- void pconnPush(Comm::Connection::Pointer conn, const peer *_peer, const HttpRequest *req, const char *domain, Ip::Address &client_addr);
+ void pconnPush(Comm::ConnectionPointer conn, const peer *_peer, const HttpRequest *req, const char *domain, Ip::Address &client_addr);
bool dontRetry() { return flags.dont_retry; }
void ftpPasvFailed(bool val) { flags.ftp_pasv_failed = val; }
- Comm::Connection::Pointer conn() const { return paths[0]; };
+ Comm::ConnectionPointer conn() const { return paths[0]; };
private:
// hidden for safer management of self; use static fwdStart
} flags;
/** possible paths which may be tried (in sequence stored) */
- Vector<Comm::Connection::Pointer> paths;
+ Comm::Paths paths;
// NP: keep this last. It plays with private/public
CBDATA_CLASS2(FwdState);
debugs(9, 3, HERE << "connecting to " << ftpState->data.host << ", port " << ftpState->data.port);
- Comm::Connection::Pointer conn = new Comm::Connection;
+ Comm::ConnectionPointer conn = new Comm::Connection;
conn->remote = fd_table[ftpState->ctrl.fd].ipaddr; // TODO: do we have a better info source than fd_table?
conn->remote.SetPort(port);
conn->fd = fd;
debugs(9, 3, HERE << "connecting to " << ftpState->data.host << ", port " << ftpState->data.port);
- Comm::Connection::Pointer conn = new Comm::Connection;
+ Comm::ConnectionPointer conn = new Comm::Connection;
conn->remote = ipaddr;
conn->remote.SetPort(port);
conn->fd = ftpState->data.fd;
}
void
-FtpStateData::ftpPasvCallback(Comm::Connection::Pointer conn, Vector<Comm::Connection::Pointer> *unused, comm_err_t status, int xerrno, void *data)
+FtpStateData::ftpPasvCallback(Comm::ConnectionPointer conn, Comm::PathsPointer unused, comm_err_t status, int xerrno, void *data)
{
FtpStateData *ftpState = (FtpStateData *)data;
debugs(9, 3, HERE);
*/
#include "squid.h"
-#include "Store.h"
-#include "comm.h"
-#include "ICP.h"
-#include "HttpRequest.h"
-#include "acl/FilledChecklist.h"
-#include "acl/Acl.h"
#include "AccessLogEntry.h"
-#include "wordlist.h"
-#include "SquidTime.h"
-#include "SwapDir.h"
+#include "acl/Acl.h"
+#include "acl/FilledChecklist.h"
+#include "comm/Connection.h"
+#include "HttpRequest.h"
#include "icmp/net_db.h"
+#include "ICP.h"
#include "ip/Address.h"
#include "rfc1738.h"
+#include "Store.h"
+#include "SquidTime.h"
+#include "SwapDir.h"
+#include "wordlist.h"
/// \ingroup ServerProtocolICPInternal2
static void icpLogIcp(const Ip::Address &, log_type, int, const char *, int);
#include "acl/RegexData.h"
#include "acl/UserData.h"
#include "client_side.h"
+#include "comm/Connection.h"
#include "ident/AclIdent.h"
#include "ident/Ident.h"
}
void
-Ident::ConnectDone(Comm::Connection::Pointer conn, Vector<Comm::Connection::Pointer> *unused, comm_err_t status, int xerrno, void *data)
+Ident::ConnectDone(Comm::ConnectionPointer conn, Comm::PathsPointer unused, comm_err_t status, int xerrno, void *data)
{
IdentStateData *state = (IdentStateData *)data;
* start a TCP connection to the peer host on port 113
*/
void
-Ident::Start(Comm::Connection::Pointer conn, IDCB * callback, void *data)
+Ident::Start(Comm::ConnectionPointer conn, IDCB * callback, void *data)
{
IdentStateData *state;
char key1[IDENT_KEY_SZ];
#if USE_IDENT
#include "cbdata.h"
-#include "comm/Connection.h"
+#include "comm/forward.h"
namespace Ident
{
* Self-registers with a global ident lookup manager,
* will call Ident::Init() itself if the manager has not been initialized already.
*/
-void Start(Comm::Connection::Pointer conn, IDCB * callback, void *cbdata);
+void Start(Comm::ConnectionPointer conn, IDCB * callback, void *cbdata);
/**
\ingroup IdentAPI
*/
#include "squid.h"
-#include "comm.h"
+#include "comm/Connection.h"
#include "fde.h"
#include "ip/Address.h"
#include "rfc1738.h"
#include "squid.h"
#include "comm.h"
+#include "comm/Connection.h"
#include "log/File.h"
#include "log/ModTcp.h"
#include "Parsing.h"
#include "squid.h"
#include "comm.h"
+#include "comm/Connection.h"
#include "log/File.h"
#include "log/ModUdp.h"
#include "Parsing.h"
return ret;/* don't probe to often */
/* for each IP address of this peer. find one that we can connect to and probe it. */
- Vector<Comm::Connection::Pointer> *paths = new Vector<Comm::Connection::Pointer>;
+ Comm::PathsPointer paths = new Comm::Paths;
for (int i = 0; i < p->n_addresses; i++) {
- Comm::Connection::Pointer conn = new Comm::Connection;
+ Comm::ConnectionPointer conn = new Comm::Connection;
conn->remote = p->addresses[i];
conn->remote.SetPort(p->http_port);
getOutgoingAddress(NULL, conn);
}
static void
-peerProbeConnectDone(Comm::Connection::Pointer conn, Vector<Comm::Connection::Pointer> *unused, comm_err_t status, int xerrno, void *data)
+peerProbeConnectDone(Comm::ConnectionPointer conn, Comm::PathsPointer unused, comm_err_t status, int xerrno, void *data)
{
peer *p = (peer*)data;
void
-peerSelect(Vector<Comm::Connection::Pointer> *paths,
+peerSelect(Comm::PathsPointer paths,
HttpRequest * request,
StoreEntry * entry,
PSC * callback,
assert(ia->cur < ia->count);
// loop over each result address, adding to the possible destinations.
- Comm::Connection::Pointer p;
+ Comm::ConnectionPointer p;
int ip = ia->cur;
for (int n = 0; n < ia->count; n++, ip++) {
if (ip >= ia->count) ip = 0; // looped back to zero.
SQUIDCEXTERN void peerDigestNotePeerGone(PeerDigest * pd);
SQUIDCEXTERN void peerDigestStatsReport(const PeerDigest * pd, StoreEntry * e);
-#include "comm/Connection.h"
-extern void getOutgoingAddress(HttpRequest * request, Comm::Connection::Pointer conn);
+#include "comm/forward.h"
+extern void getOutgoingAddress(HttpRequest * request, Comm::ConnectionPointer conn);
unsigned long getOutgoingTOS(HttpRequest * request);
SQUIDCEXTERN void urnStart(HttpRequest *, StoreEntry *);
#include "acl/FilledChecklist.h"
#include "cache_snmp.h"
#include "comm.h"
+#include "comm/Connection.h"
#include "compat/strsep.h"
#include "ip/Address.h"
char *host; /* either request->host or proxy host */
u_short port;
HttpRequest *request;
- Vector<Comm::Connection::Pointer> *paths;
+ Comm::PathsPointer paths;
class Connection
{
static void
-tunnelConnectDone(Comm::Connection::Pointer unused, Vector<Comm::Connection::Pointer> *paths, comm_err_t status, int xerrno, void *data)
+tunnelConnectDone(Comm::ConnectionPointer unused, Comm::PathsPointer paths, comm_err_t status, int xerrno, void *data)
{
TunnelStateData *tunnelState = (TunnelStateData *)data;
HttpRequest *request = tunnelState->request;
ErrorState *err = NULL;
- Comm::Connection::Pointer conn = (*paths)[0];
+ Comm::ConnectionPointer conn = (*paths)[0];
assert(tunnelState->paths == paths);
}
static void
-tunnelPeerSelectComplete(Vector<Comm::Connection::Pointer> *peer_paths, void *data)
+tunnelPeerSelectComplete(Comm::PathsPointer peer_paths, void *data)
{
TunnelStateData *tunnelState = (TunnelStateData *)data;
HttpRequest *request = tunnelState->request;
*
*/
#include "squid.h"
-#include "comm.h"
-#include "event.h"
#if USE_WCCP
+#include "comm.h"
+#include "comm/Connection.h"
+#include "event.h"
+
#define WCCP_PORT 2048
#define WCCP_REVISION 0
#define WCCP_ACTIVE_CACHES 32
#if USE_WCCPv2
#include "comm.h"
+#include "comm/Connection.h"
#include "compat/strsep.h"
#include "event.h"
#include "ip/Address.h"