]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Merge from trunk
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 3 Dec 2010 00:18:43 +0000 (13:18 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 3 Dec 2010 00:18:43 +0000 (13:18 +1300)
21 files changed:
1  2 
src/Makefile.am
src/base/AsyncCall.h
src/cache_cf.cc
src/cf.data.pre
src/client_side.cc
src/client_side_reply.cc
src/comm.cc
src/comm/IoCallback.cc
src/comm/IoCallback.h
src/comm/Write.cc
src/comm/Write.h
src/ftp.cc
src/gopher.cc
src/http.cc
src/main.cc
src/neighbors.cc
src/protos.h
src/stat.cc
src/store.cc
src/structs.h
src/tunnel.cc

diff --cc src/Makefile.am
Simple merge
Simple merge
diff --cc src/cache_cf.cc
Simple merge
diff --cc src/cf.data.pre
Simple merge
index 3fafbef0b991b34c19fb3f7c529497e985f147c5,58eb9e7bdde5845c2d5c00d3063cf06e0d9b1df5..4d78877906a19c513e7b6064170282cf629ed15a
@@@ -3158,9 -3163,9 +3158,9 @@@ httpAccept(int sock, const Comm::Connec
  
      connState->readSomeData();
  
 -    clientdbEstablished(details->peer, 1);
 +    clientdbEstablished(details->remote, 1);
  
- #if DELAY_POOLS
+ #if USE_DELAY_POOLS
      fd_table[newfd].clientInfo = NULL;
  
      if (Config.onoff.client_db) {
Simple merge
diff --cc src/comm.cc
index 0aaab34e77cae0e2d57d6e915564bd8fa087c42f,7fe3c108265a529500d0d068315d916a25e3a576..d71dc7af7770ae9f764080c7dc4a09992054ee1b
  
  static void commStopHalfClosedMonitor(int fd);
  static IOCB commHalfClosedReader;
 -static void comm_init_opened(int new_socket, Ip::Address &addr, tos_t tos, nfmark_t nfmark, const char *note, struct addrinfo *AI);
 +static void comm_init_opened(const Comm::ConnectionPointer &conn, tos_t tos, nfmark_t nfmark, const char *note, struct addrinfo *AI);
  static int comm_apply_flags(int new_socket, Ip::Address &addr, int flags, struct addrinfo *AI);
  
- #if DELAY_POOLS
+ #if USE_DELAY_POOLS
  CBDATA_CLASS_INIT(CommQuotaQueue);
  
  static void commHandleWriteHelper(void * data);
index 7d059b1b4b8ce17c970d891ce518d37d11b9fbe1,4e5b2bdf560b7f3a90d2cd84366f004dc8c394aa..2e9f9c927d18358d381b3ef874c6ab250370636a
@@@ -60,11 -54,11 +60,11 @@@ Comm::IoCallback::setCallback(Comm::ioc
  void
  Comm::IoCallback::selectOrQueueWrite()
  {
- #if DELAY_POOLS
+ #if USE_DELAY_POOLS
      // stand in line if there is one
 -    if (ClientInfo *clientInfo = fd_table[fd].clientInfo) {
 +    if (ClientInfo *clientInfo = fd_table[conn->fd].clientInfo) {
          if (clientInfo->writeLimitingActive) {
 -            quotaQueueReserv = clientInfo->quotaEnqueue(fd);
 +            quotaQueueReserv = clientInfo->quotaEnqueue(conn->fd);
              clientInfo->kickQuotaQueue();
              return;
          }
index 3a450687f43d8ac154dc83a3cd8efc93e9ffe3b8,9ce281a0ec431ace0cea377ce2264c7a88bb69c0..85d1b3f2adb608c32e2da8fe66131e665db1d790
@@@ -4,9 -4,9 +4,10 @@@
  #include "config.h"
  #include "base/AsyncCall.h"
  #include "comm_err_t.h"
 +#include "comm/forward.h"
  
- namespace Comm {
+ namespace Comm
+ {
  
  /// Type of IO callbacks the Comm layer deals with.
  typedef enum {
  } iocb_type;
  
  /// Details about a particular Comm IO callback event.
- class IoCallback {
+ class IoCallback
+ {
  public:
      iocb_type type;
 -    int fd;
 +    Comm::ConnectionPointer conn;
      AsyncCall::Pointer callback;
      char *buf;
      FREE *freefunc;
index f1ed25aeed5175e8170fbc0118d0fcb86ad997b4,822f503d74bd6dc07d0192edbcfbc362e1b0fe64..4d5cf46a69de5d1df00f013d1f0b5b069f792e03
@@@ -1,8 -1,7 +1,8 @@@
  #include "config.h"
- #if DELAY_POOLS
+ #if USE_DELAY_POOLS
  #include "ClientInfo.h"
  #endif
 +#include "comm/Connection.h"
  #include "comm/IoCallback.h"
  #include "comm/Write.h"
  #include "fde.h"
index 8b5ecc7fc53f6da0f5910134457bdcb9305b96a5,8300dc80ec421a1a5cb05fa98c5906142bb1b0a1..87aba9de2399c8fc9005d74f4506bd28f935234d
@@@ -2,9 -2,9 +2,10 @@@
  #define _SQUID_COMM_IOWRITE_H
  
  #include "base/AsyncCall.h"
 +#include "comm/forward.h"
  
- namespace Comm {
+ namespace Comm
+ {
  
  /**
   * Queue a write. callback is scheduled when the write
diff --cc src/ftp.cc
Simple merge
diff --cc src/gopher.cc
index 9082f5c78e2564442364a6a59f91c51868563e69,5b31f3a3956da0b9d8aaf6b627cfff4cad689f01..52620934c20bb419713cd98b46e9a3708b4644cf
@@@ -803,10 -801,8 +801,10 @@@ gopherReadReply(const Comm::ConnectionP
  
      /* leave one space for \0 in gopherToHTML */
  
 +    debugs(10, 5, HERE << conn << " read len=" << len);
 +
      if (flag == COMM_OK && len > 0) {
- #if DELAY_POOLS
+ #if USE_DELAY_POOLS
          delayId.bytesIn(len);
  #endif
  
diff --cc src/http.cc
index d0badb117573a8ff383791432d12e7cae0cc3bf4,c162f2d878ae7d2bf1dbfa1387e2033d623f8fbc..dad0dee729fc627637690ec886d857e2772c1bc8
@@@ -45,9 -45,8 +45,9 @@@
  #include "base/AsyncJobCalls.h"
  #include "base/TextException.h"
  #include "base64.h"
 +#include "comm/Connection.h"
  #include "comm/Write.h"
- #if DELAY_POOLS
+ #if USE_DELAY_POOLS
  #include "DelayPools.h"
  #endif
  #include "errorpage.h"
diff --cc src/main.cc
index 854c763365f29b1f0c2c312800bf2e3d2b741588,4ac574d01ad928ad87d16e323a24db33904b54fa..89a206d7f98ed40586f5e322b61d69afda7d4743
  #include "adaptation/icap/icap_log.h"
  #endif
  #include "auth/Gadgets.h"
 +#include "base/Subscription.h"
  #include "base/TextException.h"
+ #if USE_DELAY_POOLS
+ #include "ClientDelayConfig.h"
+ #endif
+ #include "ConfigParser.h"
+ #include "CpuAffinity.h"
+ #if USE_DELAY_POOLS
+ #include "DelayPools.h"
+ #endif
+ #include "errorpage.h"
+ #include "event.h"
+ #include "EventLoop.h"
+ #include "ExternalACL.h"
+ #include "Store.h"
+ #include "ICP.h"
+ #include "ident/Ident.h"
++#include "ip/tools.h"
++#include "ipc/Coordinator.h"
++#include "ipc/Kids.h"
++#include "ipc/Strand.h"
+ #include "HttpReply.h"
+ #include "pconn.h"
+ #include "Mem.h"
+ #include "acl/Asn.h"
+ #include "acl/Acl.h"
+ #include "htcp.h"
+ #include "StoreFileSystem.h"
+ #include "DiskIO/DiskIOModule.h"
  #include "comm.h"
 -#include "ipc/Kids.h"
 -#include "ipc/Coordinator.h"
 -#include "ipc/Strand.h"
 -#include "ip/tools.h"
  #if USE_EPOLL
  #include "comm_epoll.h"
  #endif
  #if defined(USE_SELECT) || defined(USE_SELECT_WIN32)
  #include "comm_select.h"
  #endif
 -#include "SquidTime.h"
 -#include "SwapDir.h"
 +#include "ConfigParser.h"
 +#include "CpuAffinity.h"
 +#include "DiskIO/DiskIOModule.h"
 +#include "errorpage.h"
 +#if USE_SQUID_ESI
 +#include "esi/Module.h"
 +#endif
 +#include "event.h"
 +#include "EventLoop.h"
 +#include "ExternalACL.h"
  #include "forward.h"
 -#include "MemPool.h"
 +#include "fs/Module.h"
 +#include "htcp.h"
 +#include "HttpReply.h"
  #include "icmp/IcmpSquid.h"
  #include "icmp/net_db.h"
- #include "ICP.h"
- #include "ident/Ident.h"
- #include "ip/tools.h"
- #include "ipc/Coordinator.h"
- #include "ipc/Kids.h"
- #include "ipc/Strand.h"
- #if DELAY_POOLS
- #include "ClientDelayConfig.h"
- #endif
 -
  #if USE_LOADABLE_MODULES
  #include "LoadableModules.h"
  #endif
Simple merge
diff --cc src/protos.h
Simple merge
diff --cc src/stat.cc
Simple merge
diff --cc src/store.cc
index 894b5028819e62e10475d7c6b50b888985cf022f,af732464eb7c999ebc8fcdfeefb2ca0130f5cba7..499efd6a60043706ab1c864962d456e7d0db1561
   */
  
  #include "squid.h"
 +#include "CacheManager.h"
 +#include "comm/Connection.h"
  #include "event.h"
- #if DELAY_POOLS
++#if USE_DELAY_POOLS
 +#include "DelayPools.h"
 +#endif
  #include "fde.h"
 -#include "Store.h"
 -#include "mgr/Registration.h"
 -#include "StoreClient.h"
 -#include "stmem.h"
  #include "HttpReply.h"
  #include "HttpRequest.h"
 -#include "MemObject.h"
  #include "mem_node.h"
 -#include "StoreMeta.h"
 -#include "SwapDir.h"
 -#if USE_DELAY_POOLS
 -#include "DelayPools.h"
 -#endif
 -#include "Stack.h"
 +#include "MemObject.h"
 +#include "mgr/Registration.h"
  #include "SquidTime.h"
 -#include "swap_log_op.h"
 +#include "Stack.h"
 +#include "stmem.h"
 +#include "Store.h"
 +#include "StoreClient.h"
  #include "mgr/StoreIoAction.h"
 +#include "StoreMeta.h"
 +#include "swap_log_op.h"
 +#include "SwapDir.h"
  
  static STMCB storeWriteComplete;
  
diff --cc src/structs.h
Simple merge
diff --cc src/tunnel.cc
index 3784a5b017e247a537f6b3d66634d2566fb915f3,269229b5d42ca13bf367390f3a33e9093efa2e0f..6404ab87fd72c8953d5af5cb0e9cb13ecf74bf3f
   */
  
  #include "squid.h"
 -#include "errorpage.h"
 -#include "HttpRequest.h"
 -#include "fde.h"
 +#include "acl/FilledChecklist.h"
 +#include "Array.h"
  #include "comm.h"
 +#include "comm/Connection.h"
 +#include "comm/ConnOpener.h"
  #include "comm/Write.h"
 +#include "client_side.h"
  #include "client_side_request.h"
- #if DELAY_POOLS
 -#include "acl/FilledChecklist.h"
+ #if USE_DELAY_POOLS
  #include "DelayId.h"
  #endif
 -#include "client_side.h"
 -#include "MemBuf.h"
 +#include "errorpage.h"
 +#include "fde.h"
 +#include "HttpRequest.h"
  #include "http.h"
 -#include "ip/tools.h"
 +#include "MemBuf.h"
 +#include "PeerSelectState.h"
  
  class TunnelStateData
  {
@@@ -77,13 -73,15 +77,13 @@@ public
      {
  
      public:
 -        Connection() : len (0),buf ((char *)xmalloc(SQUID_TCP_SO_RCVBUF)), size_ptr(NULL), fd_(-1) {}
 +        Connection() : len (0), buf ((char *)xmalloc(SQUID_TCP_SO_RCVBUF)), size_ptr(NULL) {}
  
          ~Connection();
 -        int const & fd() const { return fd_;}
  
 -        void fd(int const newFD);
          int bytesWanted(int lower=0, int upper = INT_MAX) const;
          void bytesIn(int const &);
- #if DELAY_POOLS
+ #if USE_DELAY_POOLS
  
          void setDelayId(DelayId const &);
  #endif
          char *buf;
          int64_t *size_ptr;            /* pointer to size in an ConnStateData for logging */
  
 +        Comm::ConnectionPointer conn;    ///< The currently connected connection.
 +
      private:
- #if DELAY_POOLS
 -        int fd_;
+ #if USE_DELAY_POOLS
 -
          DelayId delayId;
  #endif
  
@@@ -319,8 -324,8 +318,8 @@@ TunnelStateData::copy(size_t len, comm_
          }
      } else if (cbdataReferenceValid(this)) {
          AsyncCall::Pointer call = commCbCall(5,5, "SomeTunnelWriteHandler",
-                                          CommIoCbPtrFun(completion, this));
+                                              CommIoCbPtrFun(completion, this));
 -        Comm::Write(to.fd(), from.buf, len, call, NULL);
 +        Comm::Write(to.conn, from.buf, len, call, NULL);
      }
  
      cbdataInternalUnlock(this);       /* ??? */
@@@ -517,65 -565,46 +516,65 @@@ tunnelConnectDone(const Comm::Connectio
      HttpRequest *request = tunnelState->request;
      ErrorState *err = NULL;
  
- #if DELAY_POOLS
 -    request->recordLookup(dns);
++#if USE_DELAY_POOLS
 +    /* no point using the delayIsNoDelay stuff since tunnel is nice and simple */
 +    if (conn->getPeer() && conn->getPeer()->options.no_delay)
 +        tunnelState->server.setDelayId(DelayId());
 +#endif
  
 -    if (tunnelState->servers->_peer)
 -        hierarchyNote(&tunnelState->request->hier, tunnelState->servers->code,
 -                      tunnelState->servers->_peer->host);
 +    if (conn != NULL && conn->getPeer())
 +        hierarchyNote(&tunnelState->request->hier, conn->peerType, conn->getPeer()->host);
      else if (Config.onoff.log_ip_on_direct)
 -        hierarchyNote(&tunnelState->request->hier, tunnelState->servers->code,
 -                      fd_table[tunnelState->server.fd()].ipaddr);
 +        hierarchyNote(&tunnelState->request->hier, conn->peerType, fd_table[conn->fd].ipaddr);
      else
 -        hierarchyNote(&tunnelState->request->hier, tunnelState->servers->code,
 -                      tunnelState->host);
 -
 -    if (status == COMM_ERR_DNS) {
 -        debugs(26, 4, "tunnelConnect: Unknown host: " << tunnelState->host);
 -        err = errorCon(ERR_DNS_FAIL, HTTP_NOT_FOUND, request);
 -        *tunnelState->status_ptr = HTTP_NOT_FOUND;
 -        err->dnsError = dns.error;
 -        err->callback = tunnelErrorComplete;
 -        err->callback_data = tunnelState;
 -        errorSend(tunnelState->client.fd(), err);
 -    } else if (status != COMM_OK) {
 -        err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
 -        *tunnelState->status_ptr = HTTP_SERVICE_UNAVAILABLE;
 -        err->xerrno = xerrno;
 -        err->port = tunnelState->port;
 -        err->callback = tunnelErrorComplete;
 -        err->callback_data = tunnelState;
 -        errorSend(tunnelState->client.fd(), err);
 -    } else {
 -        if (tunnelState->servers->_peer)
 -            tunnelProxyConnected(tunnelState->server.fd(), tunnelState);
 -        else {
 -            tunnelConnected(tunnelState->server.fd(), tunnelState);
 +        hierarchyNote(&tunnelState->request->hier, conn->peerType, tunnelState->getHost());
 +
 +    // TODO: merge this into hierarchyNote with a conn parameter instead of peerType
 +    request->hier.peer_local_port = conn->local.GetPort(); // for %<lp logging
 +
 +    if (status != COMM_OK) {
 +        /* At this point only the TCP handshake has failed. no data has been passed.
 +         * we are allowed to re-try the TCP-level connection to alternate IPs for CONNECT.
 +         */
 +        tunnelState->serverDestinations.shift();
 +        if (status != COMM_TIMEOUT && tunnelState->serverDestinations.size() > 0) {
 +            /* Try another IP of this destination host */
 +            AsyncCall::Pointer call = commCbCall(26,3, "tunnelConnectDone", CommConnectCbPtrFun(tunnelConnectDone, tunnelState));
 +            Comm::ConnOpener *cs = new Comm::ConnOpener(tunnelState->serverDestinations[0], call, Config.Timeout.connect);
 +            cs->setHost(tunnelState->url);
 +            AsyncJob::Start(cs);
 +        } else {
 +            err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
 +            *tunnelState->status_ptr = HTTP_SERVICE_UNAVAILABLE;
 +            err->xerrno = xerrno;
 +            // on timeout is this still:    err->xerrno = ETIMEDOUT;
 +            err->port = conn->remote.GetPort();
 +            err->callback = tunnelErrorComplete;
 +            err->callback_data = tunnelState;
 +            errorSend(tunnelState->client.conn, err);
          }
 +        return;
 +    }
 +
 +    tunnelState->server.conn = conn;
 +    request->peer_host = conn->getPeer() ? conn->getPeer()->host : NULL;
 +    comm_add_close_handler(conn->fd, tunnelServerClosed, tunnelState);
 +
 +    if (conn->getPeer()) {
 +        tunnelState->request->peer_login = conn->getPeer()->login;
 +        tunnelState->request->flags.proxying = 1;
 +    } else {
 +        tunnelState->request->peer_login = NULL;
 +        tunnelState->request->flags.proxying = 0;
 +    }
  
 -        commSetTimeout(tunnelState->server.fd(),
 -                       Config.Timeout.read,
 -                       tunnelTimeout,
 -                       tunnelState);
 +    if (conn->getPeer())
 +        tunnelRelayConnectRequest(conn, tunnelState);
 +    else {
 +        tunnelConnected(conn, tunnelState);
      }
 +
 +    commSetTimeout(conn->fd, Config.Timeout.read, tunnelTimeout, tunnelState);
  }
  
  extern tos_t GetTosToServer(HttpRequest * request);
@@@ -618,11 -648,55 +617,11 @@@ tunnelStart(ClientHttpRequest * http, i
      debugs(26, 3, "tunnelStart: '" << RequestMethodStr(request->method) << " " << url << "'");
      statCounter.server.all.requests++;
      statCounter.server.other.requests++;
 -    /* Create socket. */
 -    Ip::Address temp = getOutgoingAddr(request,NULL);
 -
 -    // if IPv6 is disabled try to force IPv4-only outgoing.
 -    if (!Ip::EnableIpv6 && !temp.SetIPv4()) {
 -        debugs(50, 4, "tunnelStart: IPv6 is Disabled. Tunnel failed from " << temp);
 -        ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
 -        anErr->xerrno = EAFNOSUPPORT;
 -        errorSend(fd, anErr);
 -        return;
 -    }
 -
 -    // if IPv6 is split-stack, prefer IPv4
 -    if (Ip::EnableIpv6&IPV6_SPECIAL_SPLITSTACK) {
 -        // NP: This is not a great choice of default,
 -        // but with the current Internet being IPv4-majority has a higher success rate.
 -        // if setting to IPv4 fails we dont care, that just means to use IPv6 outgoing.
 -        temp.SetIPv4();
 -    }
 -
 -    int flags = COMM_NONBLOCKING;
 -    if (request->flags.spoof_client_ip) {
 -        flags |= COMM_TRANSPARENT;
 -    }
 -    sock = comm_openex(SOCK_STREAM,
 -                       IPPROTO_TCP,
 -                       temp,
 -                       flags,
 -                       GetTosToServer(request),
 -                       GetNfmarkToServer(request),
 -                       url);
 -
 -    if (sock == COMM_ERROR) {
 -        debugs(26, 4, "tunnelStart: Failed because we're out of sockets.");
 -        err = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);
 -        *status_ptr = HTTP_INTERNAL_SERVER_ERROR;
 -        err->xerrno = errno;
 -        errorSend(fd, err);
 -        return;
 -    }
 -
 -    request->hier.peer_local_port = comm_local_port(sock); // for %<lp logging
  
      tunnelState = new TunnelStateData;
- #if DELAY_POOLS
+ #if USE_DELAY_POOLS
 -
      tunnelState->server.setDelayId(DelayId::DelayClient(http));
  #endif
 -
      tunnelState->url = xstrdup(url);
      tunnelState->request = HTTPMSGLOCK(request);
      tunnelState->server.size_ptr = size_ptr;
@@@ -714,10 -827,16 +713,10 @@@ TunnelStateData::operator delete (void 
  bool
  TunnelStateData::noConnections() const
  {
 -    return fd_closed(server.fd()) && fd_closed(client.fd());
 +    return !Comm::IsConnOpen(server.conn) && !Comm::IsConnOpen(client.conn);
  }
  
- #if DELAY_POOLS
+ #if USE_DELAY_POOLS
  void
  TunnelStateData::Connection::setDelayId(DelayId const &newDelay)
  {