]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Merge form trunk
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 4 Nov 2010 10:09:05 +0000 (23:09 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 4 Nov 2010 10:09:05 +0000 (23:09 +1300)
48 files changed:
1  2 
doc/release-notes/release-3.2.sgml
src/CacheManager.h
src/HttpRequest.cc
src/Makefile.am
src/Server.cc
src/acl/Asn.cc
src/adaptation/icap/ModXact.cc
src/adaptation/icap/Xaction.cc
src/adaptation/icap/Xaction.h
src/cache_cf.cc
src/cache_manager.cc
src/cf.data.pre
src/client_side.cc
src/client_side_reply.cc
src/client_side_request.cc
src/client_side_request.h
src/comm.cc
src/defines.h
src/dns_internal.cc
src/errorpage.cc
src/errorpage.h
src/external_acl.cc
src/forward.cc
src/fqdncache.cc
src/ftp.cc
src/globals.h
src/gopher.cc
src/http.cc
src/icmp/net_db.cc
src/icp_v2.cc
src/ip/Qos.cci
src/ip/QosConfig.cc
src/ip/QosConfig.h
src/ipc/Coordinator.cc
src/ipc/Coordinator.h
src/ipc/SharedListen.cc
src/ipc/Strand.cc
src/ipcache.cc
src/main.cc
src/neighbors.cc
src/pconn.cc
src/protos.h
src/redirect.cc
src/stat.cc
src/store.cc
src/structs.h
src/tests/stub_cache_manager.cc
src/tests/stub_comm.cc

index 7c6580e91cd5c080df070b4ae017da4df2935be9,84de311ca8ecb93b647f839ecb09de488af7d73a..eaeaca34054f6e490e8c123012baccacc933691a
@@@ -304,9 -353,9 +353,13 @@@ This section gives a thorough account o
        <tag>cpu_affinity_map</tag>
        <p>New setting for SMP support to map Squid processes onto specific CPU cores.
  
-          This directive applies to all hosts, extending the number of connection attempts to each IP address.
 +      <tag>connect_retries</tag>
 +      <p>Replacement for <em>maximum_single_addr_tries</em>, 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. =======
++
+       <tag>dns_packet_max</tag>
+       <p>New setting to configure maximum number of bytes packet size to advertise via EDNS.
+          Set to "none" (the initial default) to disable EDNS large packet support.
  
        <tag>else</tag>
        <p>Part of conditional SMP support syntax. see <em>if</em>
index 8c0d478b647f7c4a7da9becf0e6e7f8bffb4b573,2b3a955ce03e834d8413c14276de3f058b2b7843..696f481828d646bd93645c5e9ba3973ae89c4851
  #ifndef SQUID_CACHEMANAGER_H
  #define SQUID_CACHEMANAGER_H
  
- #include "squid.h"
- #include "Array.h"
 +#include "comm/forward.h"
+ #include "mgr/Action.h"
+ #include "mgr/ActionProfile.h"
+ #include "mgr/Command.h"
+ #include "mgr/forward.h"
+ #include <vector>
  
  /**
   \defgroup CacheManagerAPI Cache Manager API
   */
  class CacheManager
  {
  public:
-     /* the holy trinity - assignment, copy cons, destructor */
-     /* unimplemented - prevents bugs from synthetic */
-     CacheManager & operator = (CacheManager &);
-     /* unimplemented - prevents bugs from synthetic */
-     CacheManager(CacheManager const &);
-     /* inline so that we dont need to link in cachemgr.cc at all in tests */
-     virtual ~CacheManager() {}
-     void registerAction(char const * action, char const * desc, OBJH * handler, int pw_req_flag, int atomic);
-     void registerAction(CacheManagerAction *anAction);
-     CacheManagerAction * findAction(char const * action);
+     typedef std::vector<Mgr::ActionProfilePointer> Menu;
+     void registerProfile(char const * action, char const * desc,
+                          OBJH * handler,
+                          int pw_req_flag, int atomic);
+     void registerProfile(char const * action, char const * desc,
+                          Mgr::ClassActionCreationHandler *handler,
+                          int pw_req_flag, int atomic);
+     Mgr::ActionProfilePointer findAction(char const * action) const;
+     Mgr::Action::Pointer createNamedAction(const char *actionName);
+     Mgr::Action::Pointer createRequestedAction(const Mgr::ActionParams &);
+     const Menu& menu() const { return menu_; }
  
 -    void Start(int fd, HttpRequest * request, StoreEntry * entry);
 +    void Start(const Comm::ConnectionPointer &client, HttpRequest * request, StoreEntry * entry);
  
      static CacheManager* GetInstance();
-     const char *ActionProtection(const CacheManagerAction * at);
+     const char *ActionProtection(const Mgr::ActionProfilePointer &profile);
  
  protected:
-     // command classes. They are private to the cachemanager, they
-     // may require access to local data, plus we avoid polluting
-     // the namespace more than needed.
-     class ShutdownAction : public CacheManagerAction
-     {
-     public:
-         virtual void run (StoreEntry *sentry);
-         ShutdownAction();
-     };
-     class ReconfigureAction : public CacheManagerAction
-     {
-     public:
-         virtual void run (StoreEntry *sentry);
-         ReconfigureAction();
-     };
-     class RotateAction : public CacheManagerAction
-     {
-     public:
-         virtual void run (StoreEntry *sentry);
-         RotateAction();
-     };
-     class OfflineToggleAction : public CacheManagerAction
-     {
-     public:
-         virtual void run (StoreEntry *sentry);
-         OfflineToggleAction();
-     };
-     class MenuAction : public CacheManagerAction
-     {
-     private:
-         //needs to reference the cachemgr in order to get to ActionsList
-         CacheManager *cmgr;
-     public:
-         virtual void run (StoreEntry *sentry);
-         MenuAction(CacheManager *);
-     };
+     CacheManager() {} ///< use Instance() instead
  
-     /// \ingroup CacheManagerInternal
-     typedef struct {
-         StoreEntry *entry;
-         char *action;
-         char *user_name;
-         char *passwd;
-     } cachemgrStateData;
-     CacheManager();
-     cachemgrStateData* ParseUrl(const char *url);
-     void ParseHeaders(cachemgrStateData * mgr, const HttpRequest * request);
-     int CheckPassword(cachemgrStateData * mgr);
+     Mgr::CommandPointer ParseUrl(const char *url);
+     void ParseHeaders(const HttpRequest * request, Mgr::ActionParams &params);
+     int CheckPassword(const Mgr::Command &cmd);
      char *PasswdGet(cachemgr_passwd *, const char *);
  
-     // \ingroup CacheManagerInternal
-     typedef Vector<CacheManagerAction *> CacheManagerActionList;
-     CacheManagerActionList ActionsList;
+     void registerProfile(const Mgr::ActionProfilePointer &profile);
  
+     Menu menu_;
  
  private:
      static CacheManager* instance;
index b08cf474bd0edc3db7d7b5d60619c636fe713a3b,4cd07fdaade048dfe719d14e9851d1babae40c3b..c1f84a8ea83113deff2504354d9d99b6e421f925
  #if ICAP_CLIENT
  #include "adaptation/icap/icap_log.h"
  #endif
 -#include "acl/FilledChecklist.h"
 +#include "auth/UserRequest.h"
 +#include "DnsLookupDetails.h"
+ #include "err_detail_type.h"
 +#include "HttpRequest.h"
 +#include "HttpHeaderRange.h"
 +#include "MemBuf.h"
 +#include "Store.h"
  
  HttpRequest::HttpRequest() : HttpMsg(hoRequest)
  {
diff --cc src/Makefile.am
Simple merge
diff --cc src/Server.cc
Simple merge
diff --cc src/acl/Asn.cc
Simple merge
index b501e8db6be62fe071b9b95ed8dd071530b66df0,8e679921f95c5bc6a89cf487cbeec4b30da78ed6..6aee947d77900044a72b9e69d155a0dc817f4856
  #include "adaptation/Initiator.h"
  #include "auth/UserRequest.h"
  #include "base/TextException.h"
+ #include "base64.h"
  #include "ChunkedCodingParser.h"
  #include "comm.h"
 +#include "comm/Connection.h"
  #include "HttpMsg.h"
  #include "HttpRequest.h"
  #include "HttpReply.h"
Simple merge
Simple merge
diff --cc src/cache_cf.cc
Simple merge
index 1a7c17a6fdd66847815db104684962bbb7b18d04,07fa4081891f3158d216d5049bda0a60fdaa25b5..a4e62283d71cb8172a2b081bdf682b3f26b591e8
   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
   *
   */
  #include "config.h"
+ #include "base/TextException.h"
  #include "CacheManager.h"
 +#include "comm/Connection.h"
+ #include "Debug.h"
  #include "errorpage.h"
+ #include "fde.h"
  #include "HttpReply.h"
  #include "HttpRequest.h"
- #include "Store.h"
- #include "fde.h"
+ #include "mgr/ActionCreator.h"
+ #include "mgr/Action.h"
+ #include "mgr/ActionProfile.h"
+ #include "mgr/BasicActions.h"
+ #include "mgr/Command.h"
+ #include "mgr/Forwarder.h"
+ #include "mgr/FunAction.h"
 -#include "protos.h" /* rotate_logs() */
++/* for rotate_logs() */
++#include "protos.h"
  #include "SquidTime.h"
+ #include "Store.h"
  #include "wordlist.h"
- #include "Debug.h"
+ #include <algorithm>
  
- // for rotate_logs()
- #include "protos.h"
  
  /// \ingroup CacheManagerInternal
  #define MGR_PASSWD_SZ 128
@@@ -71,35 -96,24 +98,30 @@@ CacheManager::registerProfile(const Mgr
   * Implemented via CacheManagerActionLegacy.
   */
  void
- CacheManager::registerAction(char const * action, char const * desc, OBJH * handler, int pw_req_flag, int atomic)
+ CacheManager::registerProfile(char const * action, char const * desc, OBJH * handler, int pw_req_flag, int atomic)
  {
-     debugs(16, 3, "CacheManager::registerAction: registering legacy " <<  action);
-     registerAction(new CacheManagerActionLegacy(action,desc,pw_req_flag,atomic,handler));
+     debugs(16, 3, HERE << "registering legacy " << action);
+     const Mgr::ActionProfile::Pointer profile = new Mgr::ActionProfile(action,
+             desc, pw_req_flag, atomic, new Mgr::FunActionCreator(handler));
+     registerProfile(profile);
  }
  
-  * Registers a C++-style action, via a poiner to a subclass of
 +/**
 + * \ingroup CacheManagerAPI
++ * Registers a C++-style action, via a pointer to a subclass of
 + * a CacheManagerAction object, whose run() method will be invoked when
 + * CacheManager identifies that the user has requested the action.
 + */
  void
- CacheManager::registerAction(CacheManagerAction *anAction)
+ CacheManager::registerProfile(char const * action, char const * desc,
+                               ClassActionCreator::Handler *handler,
+                               int pw_req_flag, int atomic)
  {
-     char *action = anAction->action;
-     if (findAction(action) != NULL) {
-         debugs(16, 2, "CacheManager::registerAction: Duplicate '" << action << "'. Skipping.");
-         return;
-     }
-     assert (strstr (" ", action) == NULL);
-     ActionsList += anAction;
-     debugs(16, 3, "CacheManager::registerAction: registered " <<  action);
+     const Mgr::ActionProfile::Pointer profile = new Mgr::ActionProfile(action,
+             desc, pw_req_flag, atomic, new ClassActionCreator(handler));
+     registerProfile(profile);
  }
  
  /**
   \ingroup CacheManagerInternal
   * Locates an action in the actions registry ActionsList.
@@@ -264,14 -285,13 +293,13 @@@ CacheManager::CheckPassword(const Mgr::
   * all needed internal work and renders the response.
   */
  void
 -CacheManager::Start(int fd, HttpRequest * request, StoreEntry * entry)
 +CacheManager::Start(const Comm::ConnectionPointer &client, HttpRequest * request, StoreEntry * entry)
  {
-     cachemgrStateData *mgr = NULL;
      ErrorState *err = NULL;
-     CacheManagerAction *a;
      debugs(16, 3, "CacheManager::Start: '" << entry->url() << "'" );
  
-     if ((mgr = ParseUrl(entry->url())) == NULL) {
+     Mgr::Command::Pointer cmd = ParseUrl(entry->url());
+     if (!cmd) {
          err = errorCon(ERR_INVALID_URL, HTTP_NOT_FOUND, request);
          err->url = xstrdup(entry->url());
          errorAppendEntry(entry, err);
          return;
      }
  
-     mgr->entry = entry;
+     const char *actionName = cmd->profile->name;
  
-     entry->lock();
      entry->expires = squid_curtime;
  
-     debugs(16, 5, "CacheManager: " << client << " requesting '" << mgr->action << "'");
 -    debugs(16, 5, "CacheManager: " << fd_table[fd].ipaddr << " requesting '" << actionName << "'");
++    debugs(16, 5, "CacheManager: " << client << " requesting '" << actionName << "'");
  
      /* get additional info from request headers */
-     ParseHeaders(mgr, request);
+     ParseHeaders(request, cmd->params);
+     const char *userName = cmd->params.userName.size() ?
+                            cmd->params.userName.termedBuf() : "unknown";
  
      /* Check password */
  
          errState = errorCon(ERR_CACHE_MGR_ACCESS_DENIED, HTTP_UNAUTHORIZED, request);
          /* warn if user specified incorrect password */
  
-         if (mgr->passwd)
+         if (cmd->params.password.size()) {
              debugs(16, DBG_IMPORTANT, "CacheManager: " <<
-                    (mgr->user_name ? mgr->user_name : "<unknown>") << "@" <<
+                    userName << "@" <<
 -                   fd_table[fd].ipaddr << ": incorrect password for '" <<
 +                   client << ": incorrect password for '" <<
-                    mgr->action << "'" );
-         else
+                    actionName << "'" );
+         } else {
              debugs(16, DBG_IMPORTANT, "CacheManager: " <<
-                    (mgr->user_name ? mgr->user_name : "<unknown>") << "@" <<
+                    userName << "@" <<
 -                   fd_table[fd].ipaddr << ": password needed for '" <<
 +                   client << ": password needed for '" <<
-                    mgr->action << "'");
+                    actionName << "'" );
+         }
  
          rep = errState->BuildHttpReply();
  
      }
  
      debugs(16, 2, "CacheManager: " <<
-            (mgr->user_name ? mgr->user_name : "<unknown>") << "@" <<
+            userName << "@" <<
 -           fd_table[fd].ipaddr << " requesting '" <<
 +           client << " requesting '" <<
-            mgr->action << "'" );
-     /* retrieve object requested */
-     a = findAction(mgr->action);
-     assert(a != NULL);
+            actionName << "'" );
  
-     entry->buffer();
-     {
-         HttpReply *rep = new HttpReply;
-         rep->setHeaders(HTTP_OK, NULL, "text/plain", -1, squid_curtime, squid_curtime);
-         entry->replaceHttpReply(rep);
+     if (UsingSmp() && IamWorkerProcess()) {
+         AsyncJob::Start(new Mgr::Forwarder(fd, cmd->params, request, entry));
+         return;
      }
  
-     a->run(entry);
-     entry->flush();
-     if (a->flags.atomic)
-         entry->complete();
-     StateFree(mgr);
+     Mgr::Action::Pointer action = cmd->profile->creator->create(cmd);
+     Must(action != NULL);
+     action->run(entry, true);
  }
  
- /// \ingroup CacheManagerInternal
- void CacheManager::ShutdownAction::run(StoreEntry *sentry)
- {
-     debugs(16, DBG_CRITICAL, "Shutdown by Cache Manager command.");
-     shut_down(0);
- }
- /// \ingroup CacheManagerInternal
- CacheManager::ShutdownAction::ShutdownAction() : CacheManagerAction("shutdown","Shut Down the Squid Process", 1, 1) { }
- /// \ingroup CacheManagerInternal
- void
- CacheManager::ReconfigureAction::run(StoreEntry * sentry)
- {
-     debugs(16, DBG_IMPORTANT, "Reconfigure by Cache Manager command.");
-     storeAppendPrintf(sentry, "Reconfiguring Squid Process ....");
-     reconfigure(SIGHUP);
- }
- /// \ingroup CacheManagerInternal
- CacheManager::ReconfigureAction::ReconfigureAction() : CacheManagerAction("reconfigure","Reconfigure Squid", 1, 1) { }
- /// \ingroup CacheManagerInternal
- void
- CacheManager::RotateAction::run(StoreEntry * sentry)
- {
-     debugs(16, DBG_IMPORTANT, "Rotate Logs by Cache Manager command.");
-     storeAppendPrintf(sentry, "Rotating Squid Process Logs ....");
- #ifdef _SQUID_LINUX_THREADS_
-     rotate_logs(SIGQUIT);
- #else
-     rotate_logs(SIGUSR1);
- #endif
- }
- /// \ingroup CacheManagerInternal
- CacheManager::RotateAction::RotateAction() : CacheManagerAction("rotate","Rotate Squid Logs", 1, 1) { }
- /// \ingroup CacheManagerInternal
- void
- CacheManager::OfflineToggleAction::run(StoreEntry * sentry)
- {
-     Config.onoff.offline = !Config.onoff.offline;
-     debugs(16, DBG_IMPORTANT, "offline_mode now " << (Config.onoff.offline ? "ON" : "OFF") << " by Cache Manager request.");
-     storeAppendPrintf(sentry, "offline_mode is now %s\n",
-                       Config.onoff.offline ? "ON" : "OFF");
- }
- /// \ingroup CacheManagerInternal
- CacheManager::OfflineToggleAction::OfflineToggleAction() : CacheManagerAction ("offline_toggle", "Toggle offline_mode setting", 1, 1) { }
  /*
   \ingroup CacheManagerInternal
   * Renders the protection level text for an action.
diff --cc src/cf.data.pre
Simple merge
index f7460aecc9a0aa4c6cf704df2e344228c3854e24,5c70177abe1b4d4f74a91fbbcf8c1e7d4ffb8b16..1ab505f9d8c1919842489efa261a2151892b6199
@@@ -1972,19 -1982,19 +1981,19 @@@ prepareAcceleratedURL(ConnStateData * c
          /* Put the local socket IP address as the hostname.  */
          int url_sz = strlen(url) + 32 + Config.appendDomainLen;
          http->uri = (char *)xcalloc(url_sz, 1);
 -        http->getConn()->me.ToHostname(ipbuf,MAX_IPSTRLEN);
++        http->getConn()->clientConn->local.ToHostname(ipbuf,MAX_IPSTRLEN);
          snprintf(http->uri, url_sz, "%s://%s:%d%s",
                   http->getConn()->port->protocol,
-                  http->getConn()->clientConn->local.NtoA(ntoabuf,MAX_IPSTRLEN),
-                  http->getConn()->clientConn->local.GetPort(), url);
 -                 ipbuf, http->getConn()->me.GetPort(), url);
++                 ipbuf, http->getConn()->clientConn->local.GetPort(), url);
          debugs(33, 5, "ACCEL VPORT REWRITE: '" << http->uri << "'");
      } else if (vport > 0) {
          /* Put the local socket IP address as the hostname, but static port  */
          int url_sz = strlen(url) + 32 + Config.appendDomainLen;
          http->uri = (char *)xcalloc(url_sz, 1);
 -        http->getConn()->me.ToHostname(ipbuf,MAX_IPSTRLEN);
++        http->getConn()->clientConn->local.ToHostname(ipbuf,MAX_IPSTRLEN);
          snprintf(http->uri, url_sz, "%s://%s:%d%s",
                   http->getConn()->port->protocol,
-                  http->getConn()->clientConn->local.NtoA(ntoabuf,MAX_IPSTRLEN),
-                  vport, url);
+                  ipbuf, vport, url);
          debugs(33, 5, "ACCEL VPORT REWRITE: '" << http->uri << "'");
      }
  }
@@@ -2011,10 -2021,10 +2020,10 @@@ prepareTransparentURL(ConnStateData * c
          /* Put the local socket IP address as the hostname.  */
          int url_sz = strlen(url) + 32 + Config.appendDomainLen;
          http->uri = (char *)xcalloc(url_sz, 1);
 -        http->getConn()->me.ToHostname(ipbuf,MAX_IPSTRLEN),
++        http->getConn()->clientConn->local.ToHostname(ipbuf,MAX_IPSTRLEN),
          snprintf(http->uri, url_sz, "%s://%s:%d%s",
                   http->getConn()->port->protocol,
-                  http->getConn()->clientConn->local.NtoA(ntoabuf,MAX_IPSTRLEN),
-                  http->getConn()->clientConn->local.GetPort(), url);
 -                 ipbuf, http->getConn()->me.GetPort(), url);
++                 ipbuf, http->getConn()->clientConn->local.GetPort(), url);
          debugs(33, 5, "TRANSPARENT REWRITE: '" << http->uri << "'");
      }
  }
@@@ -2475,9 -2482,10 +2484,10 @@@ clientProcessRequest(ConnStateData *con
      request->client_eui64 = conn->peer_eui64;
  #endif
  #if FOLLOW_X_FORWARDED_FOR
 -    request->indirect_client_addr = conn->peer;
 +    request->indirect_client_addr = conn->clientConn->remote;
  #endif /* FOLLOW_X_FORWARDED_FOR */
 -    request->my_addr = conn->me;
 +    request->my_addr = conn->clientConn->local;
+     request->myportname = conn->port->name;
      request->http_ver = http_ver;
  
      if (request->header.chunked()) {
@@@ -3136,8 -3150,48 +3146,48 @@@ httpAccept(int sock, const Comm::Connec
  
      connState->readSomeData();
  
 -    clientdbEstablished(details->peer, 1);
 +    clientdbEstablished(details->remote, 1);
  
+ #if DELAY_POOLS
+     fd_table[newfd].clientInfo = NULL;
+     if (Config.onoff.client_db) {
+         /* it was said several times that client write limiter does not work if client_db is disabled */
+         ClientDelayPools& pools(Config.ClientDelay.pools);
+         for (unsigned int pool = 0; pool < pools.size(); pool++) {
+             /* pools require explicit 'allow' to assign a client into them */
+             if (!pools[pool].access)
+                 continue; // warned in ClientDelayConfig::Finalize()
+             ACLFilledChecklist ch(pools[pool].access, NULL, NULL);
+             // TODO: we check early to limit error response bandwith but we
+             // should recheck when we can honor delay_pool_uses_indirect
+             ch.src_addr = details->peer;
+             ch.my_addr = details->me;
+             if (ch.fastCheck()) {
+                 /*  request client information from db after we did all checks
+                     this will save hash lookup if client failed checks */
+                 ClientInfo * cli = clientdbGetInfo(details->peer);
+                 assert(cli);
+                 /* put client info in FDE */
+                 fd_table[newfd].clientInfo = cli;
+                 /* setup write limiter for this request */
+                 const double burst = floor(0.5 +
+                                            (pools[pool].highwatermark * Config.ClientDelay.initial)/100.0);
+                 cli->setWriteLimiter(pools[pool].rate, burst, pools[pool].highwatermark);
+                 break;
+             }
+         }
+     }
+ #endif
      incoming_sockets_accepted++;
  }
  
Simple merge
Simple merge
Simple merge
diff --cc src/comm.cc
index 4f3187c453fba532cab5b860ba176c162dba97c8,8edf0efa70652cadaf7f2265de71eeb4b1a461a2..49312ace9e999db5b3907cf53327a703b0402704
@@@ -73,9 -75,16 +75,16 @@@ typedef enum 
  
  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
+ CBDATA_CLASS_INIT(CommQuotaQueue);
+ static void commHandleWriteHelper(void * data);
+ #endif
+ static void commSelectOrQueueWrite(const int fd);
  
  struct comm_io_callback_t {
      iocb_type type;
@@@ -1713,21 -2323,42 +2018,42 @@@ comm_write(const Comm::ConnectionPointe
  }
  
  void
 -comm_write(int fd, const char *buf, int size, AsyncCall::Pointer &callback, FREE * free_func)
 +comm_write(const Comm::ConnectionPointer &conn, const char *buf, int size, AsyncCall::Pointer &callback, FREE * free_func)
  {
 -    debugs(5, 5, "comm_write: FD " << fd << ": sz " << size << ": asynCall " << callback);
 +    debugs(5, 5, HERE << conn << ": sz " << size << ": asynCall " << callback);
  
      /* Make sure we are open, not closing, and not writing */
 -    assert(isOpen(fd));
 -    assert(!fd_table[fd].closing());
 -    comm_io_callback_t *ccb = COMMIO_FD_WRITECB(fd);
 +    assert(Comm::IsConnOpen(conn));
 +    assert(!fd_table[conn->fd].closing());
 +    comm_io_callback_t *ccb = COMMIO_FD_WRITECB(conn->fd);
      assert(!ccb->active());
  
 -    fd_table[fd].writeStart = squid_curtime;
 +    fd_table[conn->fd].writeStart = squid_curtime;
      /* Queue the write */
 -    commio_set_callback(fd, IOCB_WRITE, ccb, callback,
 +    commio_set_callback(conn->fd, IOCB_WRITE, ccb, callback,
                          (char *)buf, free_func, size);
-     commSetSelect(conn->fd, COMM_SELECT_WRITE, commHandleWrite, ccb, 0);
 -
 -    commSelectOrQueueWrite(fd);
++    commSelectOrQueueWrite(conn->fd);
+ }
+ // called when fd needs to write but may need to wait in line for its quota
+ static void
+ commSelectOrQueueWrite(const int fd)
+ {
+     comm_io_callback_t *ccb = COMMIO_FD_WRITECB(fd);
+ #if DELAY_POOLS
+     // stand in line if there is one
+     if (ClientInfo *clientInfo = fd_table[fd].clientInfo) {
+         if (clientInfo->writeLimitingActive) {
+             ccb->quotaQueueReserv = clientInfo->quotaEnqueue(fd);
+             clientInfo->kickQuotaQueue();
+             return;
+         }
+     }
+ #endif
+     commSetSelect(fd, COMM_SELECT_WRITE, commHandleWrite, ccb, 0);
++>>>>>>> MERGE-SOURCE
  }
  
  
diff --cc src/defines.h
index b6725511effc0c2efa22597a30e38161f8ed9410,1496edf250c77948353d1f5bbf3cc370c4e94205..afc977ddd06a687e2db2514956822ba576962abe
  #define COMM_SELECT_READ   (0x1)
  #define COMM_SELECT_WRITE  (0x2)
  
- #define safe_free(x)  if (x) { xxfree(x); x = NULL; }
++/*
+ #define COMM_NONBLOCKING      0x01
+ #define COMM_NOCLOEXEC                0x02
+ #define COMM_REUSEADDR                0x04
+ #define COMM_TRANSPARENT      0x08
+ #define COMM_DOBIND           0x10
++*/
  
  #define DISK_OK                   (0)
  #define DISK_ERROR               (-1)
index 14b6a471f34a95e079b8f71b2173cbd455350d04,da97ef7d91390c52ff068fed0d19ac2567eaec78..fcb346d7663a88ad0a3a1d98fe637e9636a12e92
   *
   */
  
 -#include "config.h"
  #include "squid.h"
- #include "CacheManager.h"
 -#include "event.h"
 -#include "SquidTime.h"
 -#include "Store.h"
++#include "base/InstanceId.h"
 +#include "comm/Connection.h"
 +#include "comm/ConnOpener.h"
  #include "comm.h"
 +#include "event.h"
  #include "fde.h"
  #include "ip/tools.h"
  #include "MemBuf.h"
 +#include "SquidTime.h"
 +#include "Store.h"
+ #include "mgr/Registration.h"
+ #include "util.h"
  #include "wordlist.h"
 -#include "base/InstanceId.h"
  
  #if HAVE_ARPA_NAMESER_H
  #include <arpa/nameser.h>
@@@ -189,7 -242,7 +245,8 @@@ static PF idnsRead
  static EVH idnsCheckQueue;
  static void idnsTickleQueue(void);
  static void idnsRcodeCount(int, int);
 +static void idnsVCClosed(int fd, void *data);
+ static unsigned short idnsQueryID(void);
  
  static void
  idnsAddNameserver(const char *buf)
@@@ -1275,11 -1381,13 +1375,11 @@@ idnsReadVC(const Comm::ConnectionPointe
      }
  
      assert(vc->ns < nns);
 -    debugs(78, 3, "idnsReadVC: FD " << fd << ": received " <<
 -           (int) vc->msg->contentSize() << " bytes via tcp from " <<
 -           nameservers[vc->ns].S << ".");
 +    debugs(78, 3, HERE << conn << ": received " << vc->msg->contentSize() << " bytes via TCP from " << nameservers[vc->ns].S << ".");
  
-     idnsGrokReply(vc->msg->buf, vc->msg->contentSize());
+     idnsGrokReply(vc->msg->buf, vc->msg->contentSize(), vc->ns);
      vc->msg->clean();
 -    comm_read(fd, (char *)&vc->msglen, 2 , idnsReadVCHeader, vc);
 +    comm_read(conn, (char *)&vc->msglen, 2 , idnsReadVCHeader, vc);
  }
  
  static void
index b111526d5e4ff70d9ba2e89de32f524392826de0,cc8acc96883758f557780df1447ffb1c8f286594..80d0ae344dfb09806e05dc7b3aca3116edebf1b1
   */
  #include "config.h"
  
 -#include "errorpage.h"
  #include "auth/UserRequest.h"
 -#include "SquidTime.h"
 -#include "Store.h"
 +#include "comm/Connection.h"
++#include "err_detail_type.h"
 +#include "errorpage.h"
 +#include "fde.h"
+ #include "html_quote.h"
  #include "HttpReply.h"
  #include "HttpRequest.h"
 -#include "MemObject.h"
 -#include "fde.h"
  #include "MemBuf.h"
 +#include "MemObject.h"
  #include "rfc1738.h"
 +#include "SquidTime.h"
 +#include "Store.h"
  #include "URLScheme.h"
  #include "wordlist.h"
 -#include "err_detail_type.h"
  
  /**
   \defgroup ErrorPageInternal Error Page Internals
diff --cc src/errorpage.h
Simple merge
Simple merge
diff --cc src/forward.cc
index 594076b133ed0b79b1f84582fa25fd2fa20728b7,3be71918389bb803723d4afaf61e195cf8a2f6e3..ff141ec8ceeaf2ef34894ee74eb9ef280f5fc109
  
  
  #include "squid.h"
 -#include "forward.h"
  #include "acl/FilledChecklist.h"
  #include "acl/Gadgets.h"
--#include "CacheManager.h"
 +#include "comm/Connection.h"
 +#include "comm/ConnOpener.h"
 +#include "CommCalls.h"
  #include "event.h"
  #include "errorpage.h"
  #include "fde.h"
  #include "Store.h"
  #include "icmp/net_db.h"
  #include "ip/Intercept.h"
+ #include "ip/tools.h"
+ #include "mgr/Registration.h"
  
 -static PSC fwdStartCompleteWrapper;
 +static PSC fwdPeerSelectionCompleteWrapper;
  static PF fwdServerClosedWrapper;
  #if USE_SSL
  static PF fwdNegotiateSSLWrapper;
@@@ -855,20 -888,106 +857,23 @@@ FwdState::connectStart(
      entry->mem_obj->checkUrlChecksum();
  #endif
  
 -    outgoing = getOutgoingAddr(request, fs->_peer);
 -
 -    // if IPv6 is disabled try to force IPv4-only outgoing.
 -    if (!Ip::EnableIpv6 && !outgoing.SetIPv4()) {
 -        debugs(50, 4, "fwdConnectStart: IPv6 is Disabled. Cannot connect from " << outgoing);
 -        ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
 -        anErr->xerrno = EAFNOSUPPORT;
 -        fail(anErr);
 -        self = NULL;  // refcounted
 -        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.
 -        outgoing.SetIPv4();
 +    /* Get the server side TOS and Netfilter mark to be set on the connection. */
 +    if (Ip::Qos::TheConfig.isAclTosActive()) {
 +        serverDestinations[0]->tos = GetTosToServer(request);
      }
 -
 -    tos_t tos = GetTosToServer(request);
 -
  #if SO_MARK
-     if (Ip::Qos::TheConfig.isAclNfmarkActive()) {
-         serverDestinations[0]->nfmark = GetNfmarkToServer(request);
-     }
 -    nfmark_t mark = GetNfmarkToServer(request);
++    serverDestinations[0]->nfmark = GetNfmarkToServer(request);
+     debugs(17, 3, "fwdConnectStart: got outgoing addr " << outgoing << ", tos " << int(tos)
 -           << ", netfilter mark " << mark);
++           << ", netfilter mark " << serverDestinations[0]->nfmark);
+ #else
 -    nfmark_t mark = 0;
++    serverDestinations[0]->nfmark = 0;
+     debugs(17, 3, "fwdConnectStart: got outgoing addr " << outgoing << ", tos " << int(tos));
  #endif
  
 -    int commFlags = COMM_NONBLOCKING;
 -    if (request->flags.spoof_client_ip) {
 -        if (!fs->_peer || !fs->_peer->options.no_tproxy)
 -            commFlags |= COMM_TRANSPARENT;
 -        // else no tproxy today ...
 -    }
 -
 -    fd = comm_openex(SOCK_STREAM, IPPROTO_TCP, outgoing, commFlags, tos, mark, url);
 -
 -    debugs(17, 3, "fwdConnectStart: got TCP FD " << fd);
 -
 -    if (fd < 0) {
 -        debugs(50, 4, "fwdConnectStart: " << xstrerror());
 -        ErrorState *anErr = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);
 -        anErr->xerrno = errno;
 -        fail(anErr);
 -        self = NULL;  // refcounted
 -        return;
 -    }
 -
 -    server_fd = fd;
 -    n_tries++;
 -
 -    if (!fs->_peer)
 -        origin_tries++;
 -
 -    request->hier.peer_local_port = comm_local_port(fd);
 -
 -    /*
 -     * stats.conn_open is used to account for the number of
 -     * connections that we have open to the peer, so we can limit
 -     * based on the max-conn option.  We need to increment here,
 -     * even if the connection may fail.
 -     */
 -
 -    if (fs->_peer) {
 -        fs->_peer->stats.conn_open++;
 -        comm_add_close_handler(fd, fwdPeerClosed, fs->_peer);
 -    }
 -
 -    comm_add_close_handler(fd, fwdServerClosedWrapper, this);
 -
 -    commSetTimeout(fd, ctimeout, fwdConnectTimeoutWrapper, this);
 -
 -    updateHierarchyInfo();
 -    commConnectStart(fd, host, port, fwdConnectDoneWrapper, this);
 -}
 -
 -void
 -FwdState::startComplete(FwdServer * theServers)
 -{
 -    debugs(17, 3, "fwdStartComplete: " << entry->url()  );
 -
 -    if (theServers != NULL) {
 -        servers = theServers;
 -        connectStart();
 -    } else {
 -        startFail();
 -    }
 -}
 -
 -void
 -FwdState::startFail()
 -{
 -    debugs(17, 3, "fwdStartFail: " << entry->url()  );
 -    ErrorState *anErr = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE, request);
 -    anErr->xerrno = errno;
 -    fail(anErr);
 -    self = NULL;      // refcounted
 +    AsyncCall::Pointer call = commCbCall(17,3, "fwdConnectDoneWrapper", CommConnectCbPtrFun(fwdConnectDoneWrapper, this));
 +    Comm::ConnOpener *cs = new Comm::ConnOpener(serverDestinations[0], call, ctimeout);
 +    cs->setHost(host);
 +    AsyncJob::Start(cs);
  }
  
  void
index aed4d70e051e08cc9ff4beaa500e1f198e698715,d3cc6108c85f0d6c734cd14dcf10f056187b0e21..0a1e66085c954fd23c5ddf7962eb9925c4503ebc
@@@ -34,9 -34,8 +34,9 @@@
  
  #include "squid.h"
  #include "cbdata.h"
 +#include "DnsLookupDetails.h"
  #include "event.h"
- #include "CacheManager.h"
+ #include "mgr/Registration.h"
  #include "SquidTime.h"
  #include "Store.h"
  #include "wordlist.h"
diff --cc src/ftp.cc
Simple merge
diff --cc src/globals.h
Simple merge
diff --cc src/gopher.cc
Simple merge
diff --cc src/http.cc
index ec747d0dbe89b49aa3e5c753a913fa54f8324539,37f8996f3a1edc6aaac7571ab96cc3219e9d9ff9..bf07e3f3ea5aa15c126f8110b4e18ad179f28426
@@@ -44,7 -44,7 +44,8 @@@
  #include "auth/UserRequest.h"
  #include "base/AsyncJobCalls.h"
  #include "base/TextException.h"
+ #include "base64.h"
 +#include "comm/Connection.h"
  #if DELAY_POOLS
  #include "DelayPools.h"
  #endif
Simple merge
diff --cc src/icp_v2.cc
index 6e3e33c9531924d9cb543d77398dbed47bb7d722,87b2a8369ad05826d8044f62c250770de2e61049..0b9b8b1dbe74d37b57d1c4f92e26a0ee7b444fe6
@@@ -686,7 -677,7 +689,6 @@@ voi
  icpConnectionsOpen(void)
  {
      uint16_t port;
- //    Ip::Address addr;
 -    Ip::Address addr;
  
      if ((port = Config.Port.icp) <= 0)
          return;
              fatal("ICP port cannot be opened.");
          }
          /* split-stack for now requires default IPv4-only ICP */
 -        if (Ip::EnableIpv6&IPV6_SPECIAL_SPLITSTACK && addr.IsAnyAddr()) {
 -            addr.SetIPv4();
 +        if (Ip::EnableIpv6&IPV6_SPECIAL_SPLITSTACK && icpOutgoingConn->local.IsAnyAddr()) {
 +            icpOutgoingConn->local.SetIPv4();
          }
  
 -        theOutIcpConnection = comm_open_listener(SOCK_DGRAM,
 -                              IPPROTO_UDP,
 -                              addr,
 -                              COMM_NONBLOCKING,
 -                              "ICP Port");
 +        enter_suid();
 +        comm_open_listener(SOCK_DGRAM, IPPROTO_UDP, icpOutgoingConn, "Outgoing ICP Port");
          leave_suid();
  
 -        if (theOutIcpConnection < 0)
 +        if (!Comm::IsConnOpen(icpOutgoingConn))
              fatal("Cannot open Outgoing ICP Port");
  
 -        commSetSelect(theOutIcpConnection,
 -                      COMM_SELECT_READ,
 -                      icpHandleUdp,
 -                      NULL,
 -                      0);
 -
 -        debugs(12, 1, "Outgoing ICP messages on port " << addr.GetPort() << ", FD " << theOutIcpConnection << ".");
 +        debugs(12, DBG_CRITICAL, "Sending ICP messages from " << icpOutgoingConn->local);
  
 +        commSetSelect(icpOutgoingConn->fd, COMM_SELECT_READ, icpHandleUdp, NULL, 0);
+         fd_note(theOutIcpConnection, "Outgoing ICP socket");
+         icpGetOutgoingIpAddress();
      }
+ }
  
-     // Ensure that we have the IP address(es) to use for Host ID.
-     // The outgoing address is used as 'private' host ID used only on packets we send
++// Ensure that we have the IP address(es) to use for Host ID.
++// The outgoing address is used as 'private' host ID used only on packets we send
+ static void
+ icpGetOutgoingIpAddress()
+ {
      struct addrinfo *xai = NULL;
 -    theOutICPAddr.InitAddrInfo(xai);
 -
 -    if (getsockname(theOutIcpConnection, xai->ai_addr, &xai->ai_addrlen) < 0)
 -        debugs(50, 1, "theOutIcpConnection FD " << theOutIcpConnection << ": getsockname: " << xstrerror());
+     theOutICPAddr.SetEmpty();
 +    theIcpPrivateHostID.InitAddrInfo(xai);
 +    if (getsockname(icpOutgoingConn->fd, xai->ai_addr, &xai->ai_addrlen) < 0)
 +        debugs(50, DBG_IMPORTANT, "ERROR: Unable to identify ICP host ID to use for " << icpOutgoingConn
 +               << ": getsockname: " << xstrerror());
      else
 -        theOutICPAddr = *xai;
 -
 -    theOutICPAddr.FreeAddrInfo(xai);
 +        theIcpPrivateHostID = *xai;
 +    theIcpPrivateHostID.FreeAddrInfo(xai);
  }
  
  static void
 -icpIncomingConnectionOpened(int fd, int errNo, Ip::Address& addr)
 +icpIncomingConnectionOpened(int errNo)
  {
 -    theInIcpConnection = fd;
 -
 -    if (theInIcpConnection < 0)
 +    if (!Comm::IsConnOpen(icpIncomingConn))
          fatal("Cannot open ICP Port");
  
 -    commSetSelect(theInIcpConnection,
 -                  COMM_SELECT_READ,
 -                  icpHandleUdp,
 -                  NULL,
 -                  0);
 +    commSetSelect(icpIncomingConn->fd, COMM_SELECT_READ, icpHandleUdp, NULL, 0);
  
      for (const wordlist *s = Config.mcast_group_list; s; s = s->next)
 -        ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL);
 +        ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL); // XXX: pass the icpIncomingConn for mcastJoinGroups usage.
  
 -    debugs(12, 1, "Accepting ICP messages at " << addr << ", FD " << theInIcpConnection << ".");
 +    debugs(12, DBG_IMPORTANT, "Accepting ICP messages on " << icpIncomingConn->local);
  
 -    fd_note(theInIcpConnection, "Incoming ICP socket");
 +    fd_note(icpIncomingConn->fd, "Incoming ICP port");
  
      if (Config.Addrs.udp_outgoing.IsNoAddr()) {
 -        theOutIcpConnection = theInIcpConnection;
 +        icpOutgoingConn = icpIncomingConn;
 +        debugs(12, DBG_IMPORTANT, "Sending ICP messages from " << icpOutgoingConn->local);
+         icpGetOutgoingIpAddress();
      }
 +
 +    // Ensure that we have the IP address(es) to use for Host ID.
 +    // The listening address is used as 'public' host ID which can be used to contact us
 +    struct addrinfo *xai = NULL;
 +    theIcpPublicHostID.InitAddrInfo(xai); // reset xai
 +    if (getsockname(icpIncomingConn->fd, xai->ai_addr, &xai->ai_addrlen) < 0)
 +        debugs(50, DBG_IMPORTANT, "ERROR: Unable to identify ICP host ID to use for " << icpIncomingConn
 +               << ": getsockname: " << xstrerror());
 +    else
 +        theIcpPublicHostID = *xai;
 +    theIcpPublicHostID.FreeAddrInfo(xai);
  }
  
  /**
diff --cc src/ip/Qos.cci
Simple merge
index 8064cf7b7f69a397c9460def84a0b568133afd56,e827c295afb18c8f99a7a52ba4f2becd670ca5fd..7b1bf8afa305b9cbdbd5ac48e6e0adbc5a9050dc
@@@ -89,9 -95,11 +89,9 @@@ void Ip::Qos::getNfmarkFromServer(cons
              /* Query the conntrack table using the data previously set */
              int x = nfct_query(h, NFCT_Q_GET, ct);
              if (x == -1) {
-                 debugs(17, 2, "QOS: Failed to retrieve connection mark: (" << x << ") " << xstrerror(errno)
+                 debugs(17, 2, "QOS: Failed to retrieve connection mark: (" << x << ") " << strerror(errno)
 -                       << " (Destination " << servFde->ipaddr << ":" << servFde->remote_port
 -                       << ", source " << serv_fde_local_conn << ")" );
 +                       << " (Destination " << server->remote << ", source " << server->local << ")" );
              }
 -
              nfct_close(h);
          } else {
              debugs(17, 2, "QOS: Failed to open conntrack handle for upstream netfilter mark retrieval.");
Simple merge
index 9508f7b2431544d84d6f4f0e2339f9ca8b8b11a8,d7f341949680a85164f5f784faf0b9cb3bba6b74..fc38a7d27373b9f7c2bb36054a57c63bc4828d49
@@@ -7,9 -7,9 +7,10 @@@
  
  
  #include "config.h"
 -#include "CacheManager.h"
 +#include "base/Subscription.h"
+ #include "base/TextException.h"
  #include "comm.h"
 +#include "comm/Connection.h"
  #include "ipc/Coordinator.h"
  #include "ipc/FdNotes.h"
  #include "ipc/SharedListen.h"
@@@ -96,7 -110,30 +111,30 @@@ Ipc::Coordinator::handleSharedListenReq
      SendMessage(MakeAddr(strandAddrPfx, request.requestorId), message);
  }
  
 -int
+ void
+ Ipc::Coordinator::handleCacheMgrRequest(const Mgr::Request& request)
+ {
+     debugs(54, 4, HERE);
+     // Let the strand know that we are now responsible for handling the request
+     Mgr::Response response(request.requestId);
+     TypedMsgHdr message;
+     response.pack(message);
+     SendMessage(MakeAddr(strandAddrPfx, request.requestorId), message);
+     Mgr::Action::Pointer action =
+         CacheManager::GetInstance()->createRequestedAction(request.params);
+     AsyncJob::Start(new Mgr::Inquirer(action,
+                                       Mgr::ImportHttpFdIntoComm(request.fd), request, strands_));
+ }
+ void
+ Ipc::Coordinator::handleCacheMgrResponse(const Mgr::Response& response)
+ {
+     Mgr::Inquirer::HandleRemoteAck(response);
+ }
 +Comm::ConnectionPointer
  Ipc::Coordinator::openListenSocket(const SharedListenRequest& request,
                                     int &errNo)
  {
index 4c238f7c0c4e363d5715fa79a74c3b71e54b45f0,11856b1d3e2d0f7a0ca956668bab6d4c988e7682..3937cd387f1df9e1834cb6d03ff31e36189e4a8d
@@@ -39,15 -44,16 +44,16 @@@ protected
  
      /// returns cached socket or calls openListenSocket()
      void handleSharedListenRequest(const SharedListenRequest& request);
+     void handleCacheMgrRequest(const Mgr::Request& request);
+     void handleCacheMgrResponse(const Mgr::Response& response);
  
      /// calls comm_open_listener()
 -    int openListenSocket(const SharedListenRequest& request, int &errNo);
 +    Comm::ConnectionPointer openListenSocket(const SharedListenRequest& request, int &errNo);
  
  private:
-     typedef Vector<StrandCoord> Strands; ///< unsorted strands
-     Strands strands; ///< registered processes and threads
+     StrandCoords strands_; ///< registered processes and threads
  
 -    typedef std::map<OpenListenerParams, int> Listeners; ///< params:fd map
 +    typedef std::map<OpenListenerParams, Comm::ConnectionPointer> Listeners; ///< params:fd map
      Listeners listeners; ///< cached comm_open_listener() results
  
      static Coordinator* TheInstance; ///< the only class instance in existence
index af4475003f7a09a08fb61a5460db1849ebcdd7a2,6b76b96acf5893b24b1fc45d2bb4eca12b81686b..d39f829aae68847ed172bc715e1245760ad44883
@@@ -87,18 -88,18 +89,20 @@@ Ipc::SharedListenResponse::SharedListen
  }
  
  Ipc::SharedListenResponse::SharedListenResponse(const TypedMsgHdr &hdrMsg):
 -        fd(-1), errNo(0), mapId(-1)
 +        conn(NULL), errNo(0), mapId(-1)
  {
-     hdrMsg.getData(mtSharedListenResponse, this, sizeof(*this));
+     hdrMsg.checkType(mtSharedListenResponse);
+     hdrMsg.getPod(*this);
 -    fd = hdrMsg.getFd();
 +    conn = new Comm::Connection;
 +    conn->fd = hdrMsg.getFd();
 +    // other conn details are passed in OpenListenerParams and filled out by SharedListenJoin()
  }
  
  void Ipc::SharedListenResponse::pack(TypedMsgHdr &hdrMsg) const
  {
-     hdrMsg.putData(mtSharedListenResponse, this, sizeof(*this));
+     hdrMsg.setType(mtSharedListenResponse);
+     hdrMsg.putPod(*this);
 -    hdrMsg.putFd(fd);
 +    hdrMsg.putFd(conn->fd);
  }
  
  
index ba536809a9bd47eef081dd38ba146ac9a28f0c82,a1e9f59c5dc69b54b451de1fc031185c18a57cb7..bc14620bf9e6e075667e87fdd17979a8882ead18
@@@ -6,14 -6,18 +6,19 @@@
   */
  
  #include "config.h"
 +#include "base/Subscription.h"
  #include "base/TextException.h"
 +#include "comm/Connection.h"
  #include "ipc/Strand.h"
+ #include "ipc/StrandCoord.h"
  #include "ipc/Messages.h"
  #include "ipc/SharedListen.h"
  #include "ipc/Kids.h"
+ #include "mgr/Request.h"
+ #include "mgr/Response.h"
+ #include "mgr/Forwarder.h"
+ #include "CacheManager.h"
  
 -
  CBDATA_NAMESPACED_CLASS_INIT(Ipc, Strand);
  
  
diff --cc src/ipcache.cc
index e93b42b67f23712b3cbc164693993cf8dcaa008a,45e7fc1620cdb9b2d56d6e2c311de71580549dcb..4ac3fdccf853ed264d90ccc71c53fb9ded379d15
   */
  
  #include "squid.h"
- #include "CacheManager.h"
  #include "cbdata.h"
 +#include "CacheManager.h"
 +#include "DnsLookupDetails.h"
  #include "event.h"
  #include "ip/Address.h"
  #include "ip/tools.h"
diff --cc src/main.cc
index 7f3758cab6dd72ea9123a1bdd7355324919db157,182474ed60ba5c2f1de5db2fc3e83d58b74571fe..ed49e83c8b54bf4bdb9f6f9d128d68abbf7aabcb
  #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
 -
 -#if ICAP_CLIENT
 -#include "adaptation/icap/Config.h"
 -#endif
 -#if USE_ECAP
 -#include "adaptation/ecap/Config.h"
 -#endif
 -#if USE_ADAPTATION
 -#include "adaptation/Config.h"
 -#endif
 -#if USE_SQUID_ESI
 -#include "esi/Module.h"
 -#endif
 -#include "fs/Module.h"
 +#include "Mem.h"
 +#include "MemPool.h"
 +#include "pconn.h"
 +#include "PeerSelectState.h"
 +#include "SquidTime.h"
 +#include "Store.h"
 +#include "StoreFileSystem.h"
 +#include "SwapDir.h"
  
+ #if HAVE_PATHS_H
+ #include <paths.h>
+ #endif
  
  #if USE_WIN32_SERVICE
  #include "squid_windows.h"
  #include <process.h>
  
index 55fee734980e96aec3163dd1ad05dc4da87a6334,76edcc34d79f82f90232cae9a231a20922311f0f..a38b1435f7e42209d91ab1de33b3d6079b1e8627
@@@ -33,9 -33,6 +33,8 @@@
  #include "squid.h"
  #include "ProtoPort.h"
  #include "acl/FilledChecklist.h"
- #include "CacheManager.h"
 +#include "comm/Connection.h"
 +#include "comm/ConnOpener.h"
  #include "event.h"
  #include "htcp.h"
  #include "HttpRequest.h"
@@@ -542,15 -541,14 +543,14 @@@ neighborRemove(peer * target
  static void
  neighborsRegisterWithCacheManager()
  {
-     CacheManager *manager = CacheManager::GetInstance();
-     manager->registerAction("server_list",
-                             "Peer Cache Statistics",
-                             neighborDumpPeers, 0, 1);
+     Mgr::RegisterAction("server_list",
+                         "Peer Cache Statistics",
+                         neighborDumpPeers, 0, 1);
  
 -    if (theInIcpConnection >= 0) {
 +    if (Comm::IsConnOpen(icpIncomingConn)) {
-         manager->registerAction("non_peers",
-                                 "List of Unknown sites sending ICP messages",
-                                 neighborDumpNonPeers, 0, 1);
+         Mgr::RegisterAction("non_peers",
+                             "List of Unknown sites sending ICP messages",
+                             neighborDumpNonPeers, 0, 1);
      }
  }
  
diff --cc src/pconn.cc
index 8878b352ce9ea976af5edda9e786633d02c49038,e2fcad7cbb1f36b862adc38c59f2b0ac5193d53e..e14865e6fe10820fc72f557ebfd2c6d0e337a3f8
   */
  
  #include "squid.h"
- #include "CacheManager.h"
 -#include "mgr/Registration.h"
 -#include "Store.h"
  #include "comm.h"
 -#include "pconn.h"
 +#include "comm/Connection.h"
  #include "fde.h"
++#include "mgr/Registration.h"
 +#include "pconn.h"
 +#include "Store.h"
  
  #define PCONN_FDS_SZ  8       /* pconn set size, increase for better memcache hit rate */
  
diff --cc src/protos.h
Simple merge
diff --cc src/redirect.cc
index b3a5b503d09c55080e661146b30073838ea8bca0,999474b5350d44bbc468eca273c02e4c4ad63829..e08b9f8ca805f8b6be519f7de753682e941ff5a5
@@@ -35,8 -35,7 +35,8 @@@
  
  #include "squid.h"
  #include "auth/UserRequest.h"
- #include "CacheManager.h"
 +#include "comm/Connection.h"
+ #include "mgr/Registration.h"
  #include "Store.h"
  #include "fde.h"
  #include "client_side_request.h"
diff --cc src/stat.cc
index 1d9bc563c09340a7a20f64014c41e72522ffa70c,922ee4a3b62a2ce35f0eeb5cb15086437322f82d..428c579a3c0c5be580a42aa9fd5e927e68473b40
@@@ -36,8 -36,7 +36,7 @@@
  #include "event.h"
  #include "StoreClient.h"
  #include "auth/UserRequest.h"
- #include "CacheManager.h"
 -#include "mgr/Registration.h"
 +#include "comm/Connection.h"
  #include "Store.h"
  #include "HttpRequest.h"
  #include "MemObject.h"
  #include "MemBuf.h"
  #include "SquidMath.h"
  #include "SquidTime.h"
+ #include "mgr/CountersAction.h"
+ #include "mgr/FunAction.h"
+ #include "mgr/InfoAction.h"
+ #include "mgr/IntervalAction.h"
+ #include "mgr/IoAction.h"
++#include "mgr/Registration.h"
+ #include "mgr/ServiceTimesAction.h"
  
  /* these are included because they expose stats calls */
  /* TODO: provide a self registration mechanism for those classes
diff --cc src/store.cc
index f24f2155527572b188eaad2ceb6aa375850155e6,0e1fabc63b5c4be92168922b719c9d74e3181883..894b5028819e62e10475d7c6b50b888985cf022f
   */
  
  #include "squid.h"
 +#include "CacheManager.h"
 +#include "comm/Connection.h"
  #include "event.h"
 +#if 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 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
index bb2bb8085d625b3f2f4dd7385388d7d66b2deedc,5b4099eb73ed6b710cc394bc8fa40ee7d80e3479..d89ec362f71ea7473ff183d0728d08c4fd799f77
@@@ -45,7 -41,7 +41,7 @@@ CacheManager::createNamedAction(char co
  }
  
  void
- CacheManager::registerAction(CacheManagerAction *anAction)
 -CacheManager::Start(int fd, HttpRequest * request, StoreEntry * entry)
++CacheManager::Start(const Comm::ConnectionPointer &conn, HttpRequest * request, StoreEntry * entry)
  {
      return;
  }
Simple merge