From: Amos Jeffries Date: Tue, 13 Jul 2010 08:38:07 +0000 (+1200) Subject: Merge from trunk X-Git-Tag: take08~55^2~124^2~123 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8fd5b41017abec136911e399b11d2282bd55bd94;p=thirdparty%2Fsquid.git Merge from trunk --- 8fd5b41017abec136911e399b11d2282bd55bd94 diff --cc doc/release-notes/release-3.2.sgml index 9dc15ffda5,f5256caeb7..21f5905900 --- a/doc/release-notes/release-3.2.sgml +++ b/doc/release-notes/release-3.2.sgml @@@ -171,10 -223,12 +223,16 @@@ This section gives a thorough account o

Access control based on altered HTTP request following adaptation alterations (ICAP, eCAP, URL rewriter). An upgraded drop-in replacement for http_access2 found in Squid-2. + connect_retries +

Replacement for maximum_single_addr_tries, but instead of only applying to hosts with single addresses. + This directive applies to all hosts, extending the number of connection attempts to each IP address. + + else +

Part of conditional SMP support syyntax. see if + + endif +

Part of conditional SMP support syyntax. see if + eui_lookup

Whether to lookup the EUI or MAC address of a connected client. diff --cc src/client_side.cc index 70c2f7ed88,ba03e748f0..b01e699ba4 --- a/src/client_side.cc +++ b/src/client_side.cc @@@ -85,6 -85,6 +85,7 @@@ #include "acl/FilledChecklist.h" #include "auth/UserRequest.h" ++#include "base/TextException.h" #include "ChunkedCodingParser.h" #include "client_side.h" #include "client_side_reply.h" diff --cc src/comm.cc index d7bf01d583,6330270bbd..f3fde6ab78 --- a/src/comm.cc +++ b/src/comm.cc @@@ -791,8 -856,151 +824,46 @@@ comm_apply_flags(int new_socket return new_socket; } + void + comm_import_opened(int fd, + Ip::Address &addr, + int flags, + const char *note, + struct addrinfo *AI) + { + debugs(5, 2, HERE << " FD " << fd << " at " << addr); + assert(fd >= 0); + assert(AI); + + comm_init_opened(fd, addr, 0, note, AI); + + if (!(flags & COMM_NOCLOEXEC)) + fd_table[fd].flags.close_on_exec = 1; + + if (addr.GetPort() > (u_short) 0) { + #ifdef _SQUID_MSWIN_ + if (sock_type != SOCK_DGRAM) + #endif + fd_table[fd].flags.nolinger = 1; + } + + if ((flags & COMM_TRANSPARENT)) + fd_table[fd].flags.transparent = 1; + + if (flags & COMM_NONBLOCKING) + fd_table[fd].flags.nonblocking = 1; + + #ifdef TCP_NODELAY + if (AI->ai_socktype == SOCK_STREAM) + fd_table[fd].flags.nodelay = 1; + #endif + + /* no fd_table[fd].flags. updates needed for these conditions: + * if ((flags & COMM_REUSEADDR)) ... + * if ((flags & COMM_DOBIND) ...) ... + */ + } + - -CBDATA_CLASS_INIT(ConnectStateData); - -void * -ConnectStateData::operator new (size_t size) -{ - CBDATA_INIT_TYPE(ConnectStateData); - return cbdataAlloc(ConnectStateData); -} - -void -ConnectStateData::operator delete (void *address) -{ - cbdataFree(address); -} - - - -void -commConnectStart(int fd, const char *host, u_short port, AsyncCall::Pointer &cb) -{ - debugs(cb->debugSection, cb->debugLevel, "commConnectStart: FD " << fd << - ", cb " << cb << ", " << host << ":" << port); // TODO: just print *cb - - ConnectStateData *cs; - cs = new ConnectStateData; - cs->fd = fd; - cs->host = xstrdup(host); - cs->default_port = port; - cs->callback = cb; - - comm_add_close_handler(fd, commConnectFree, cs); - ipcache_nbgethostbyname(host, commConnectDnsHandle, cs); -} - -// TODO: Remove this and similar callback registration functions by replacing -// (callback,data) parameters with an AsyncCall so that we do not have to use -// a generic call name and debug level when creating an AsyncCall. This will -// also cut the number of callback registration routines in half. -void -commConnectStart(int fd, const char *host, u_short port, CNCB * callback, void *data) -{ - debugs(5, 5, "commConnectStart: FD " << fd << ", data " << data << ", " << host << ":" << port); - AsyncCall::Pointer call = commCbCall(5,3, - "SomeCommConnectHandler", CommConnectCbPtrFun(callback, data)); - commConnectStart(fd, host, port, call); -} - -static void -commConnectDnsHandle(const ipcache_addrs *ia, const DnsLookupDetails &details, void *data) -{ - ConnectStateData *cs = (ConnectStateData *)data; - cs->dns = details; - - if (ia == NULL) { - debugs(5, 3, "commConnectDnsHandle: Unknown host: " << cs->host); - cs->callCallback(COMM_ERR_DNS, 0); - return; - } - - assert(ia->cur < ia->count); - - cs->default_addr = ia->in_addrs[ia->cur]; - - if (Config.onoff.balance_on_multiple_ip) - ipcacheCycleAddr(cs->host, NULL); - - cs->addrcount = ia->count; - - cs->connstart = squid_curtime; - - cs->connect(); -} - -void -ConnectStateData::callCallback(comm_err_t status, int xerrno) -{ - debugs(5, 3, "commConnectCallback: FD " << fd); - - comm_remove_close_handler(fd, commConnectFree, this); - commSetTimeout(fd, -1, NULL, NULL); - - typedef CommConnectCbParams Params; - Params ¶ms = GetCommParams(callback); - params.fd = fd; - params.dns = dns; - params.flag = status; - params.xerrno = xerrno; - ScheduleCallHere(callback); - callback = NULL; - - commConnectFree(fd, this); -} - -static void -commConnectFree(int fd, void *data) -{ - ConnectStateData *cs = (ConnectStateData *)data; - debugs(5, 3, "commConnectFree: FD " << fd); -// delete cs->callback; - cs->callback = NULL; - safe_free(cs->host); - delete cs; -} - static void copyFDFlags(int to, fde *F) { diff --cc src/comm/ListenStateData.cc index 50a1eedb2d,4e5a304831..ce3faef694 --- a/src/comm/ListenStateData.cc +++ b/src/comm/ListenStateData.cc @@@ -171,10 -172,9 +172,9 @@@ Comm::ListenStateData::acceptOne( } debugs(5, 5, HERE << "accepted: FD " << fd << - " newfd: " << newfd << " from: " << connDetails.peer << + " newfd: " << newfd << " from: " << connDetails->remote << - " handler: " << *theCallback); + " handler: " << theCallback); notify(newfd, COMM_OK, 0, connDetails); - return true; } void diff --cc src/comm/ListenStateData.h index 6372d2f661,66ed358786..4b1dda706e --- a/src/comm/ListenStateData.h +++ b/src/comm/ListenStateData.h @@@ -43,8 -41,8 +43,8 @@@ private /// Method callback for whenever an FD is ready to accept a client connection. static void doAccept(int fd, void *data); - bool acceptOne(); + void acceptOne(); - int oldAccept(ConnectionDetail &details); + int oldAccept(Comm::Connection &details); AsyncCall::Pointer theCallback; bool mayAcceptMore; diff --cc src/icp_v2.cc index c53738cd43,cb1e4cde5c..b321bc409a --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@@ -36,20 -36,45 +36,45 @@@ */ #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 "ipc/StartListening.h" #include "rfc1738.h" +#include "Store.h" +#include "SquidTime.h" +#include "SwapDir.h" +#include "wordlist.h" + /// dials icpIncomingConnectionOpened call + class IcpListeningStartedDialer: public CallDialer, + public Ipc::StartListeningCb + { + public: + typedef void (*Handler)(int fd, int errNo, Ip::Address& addr); + IcpListeningStartedDialer(Handler aHandler, Ip::Address& anAddr): + handler(aHandler), addr(anAddr) {} + + virtual void print(std::ostream &os) const { + startPrint(os) << + ", address=" << addr << ')'; + } + + virtual bool canDial(AsyncCall &) const { return true; } + virtual void dial(AsyncCall &) { (handler)(fd, errNo, addr); } + + public: + Handler handler; + Ip::Address addr; + }; + + static void icpIncomingConnectionOpened(int fd, int errNo, Ip::Address& addr); + /// \ingroup ServerProtocolICPInternal2 static void icpLogIcp(const Ip::Address &, log_type, int, const char *, int); diff --cc src/snmp_core.cc index 7330f5d997,74dce91e7e..1781eedb07 --- a/src/snmp_core.cc +++ b/src/snmp_core.cc @@@ -33,7 -33,7 +33,8 @@@ #include "acl/FilledChecklist.h" #include "cache_snmp.h" #include "comm.h" +#include "comm/Connection.h" + #include "ipc/StartListening.h" #include "compat/strsep.h" #include "ip/Address.h"