]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/DelayId.cc
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / DelayId.cc
index 4e9cb1e66ec2b4de547d2eb20d5b5256e65317ac..c1fd2b8d82c33e1115c9bfa89621b02d0be4595d 100644 (file)
@@ -1,63 +1,34 @@
-
 /*
- * $Id: DelayId.cc,v 1.25 2008/01/20 19:46:35 serassio Exp $
- *
- * DEBUG: section 77    Delay Pools
- * AUTHOR: Robert Collins <robertc@squid-cache.org>
- * Based upon original delay pools code by
- *   David Luyer <david@luyer.net>
- *
- * SQUID Web Proxy Cache          http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- *  Squid is the result of efforts by numerous individuals from
- *  the Internet community; see the CONTRIBUTORS file for full
- *  details.   Many organizations have provided support for Squid's
- *  development; see the SPONSORS file for full details.  Squid is
- *  Copyrighted (C) 2001 by the Regents of the University of
- *  California; see the COPYRIGHT file for full details.  Squid
- *  incorporates software developed and/or copyrighted by other
- *  sources; see the CREDITS file for full details.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *  
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *  
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
+ * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
  *
- * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
  */
 
-#include "config.h"
+/* DEBUG: section 77    Delay Pools */
+
+#include "squid.h"
 
 /* MS Visual Studio Projects are monolithic, so we need the following
  * #if to exclude the delay pools code from compile process when not needed.
  */
-#if DELAY_POOLS
-
-#include "squid.h"
-#include "DelayId.h"
+#if USE_DELAY_POOLS
+#include "acl/FilledChecklist.h"
 #include "client_side_request.h"
-#include "ACLChecklist.h"
-#include "DelayPools.h"
+#include "CommRead.h"
+#include "DelayId.h"
 #include "DelayPool.h"
+#include "DelayPools.h"
+#include "http/Stream.h"
 #include "HttpRequest.h"
-#include "CommRead.h"
+#include "SquidConfig.h"
 
 DelayId::DelayId () : pool_ (0), compositeId(NULL), markedAsNoDelay(false)
 {}
 
 DelayId::DelayId (unsigned short aPool) :
-        pool_ (aPool), compositeId (NULL), markedAsNoDelay (false)
+    pool_ (aPool), compositeId (NULL), markedAsNoDelay (false)
 {
     debugs(77, 3, "DelayId::DelayId: Pool " << aPool << "u");
 }
@@ -81,7 +52,7 @@ bool
 DelayId::operator == (DelayId const &rhs) const
 {
     /* Doesn't compare composites properly....
-     * only use to test against default ID's 
+     * only use to test against default ID's
      */
     return pool_ == rhs.pool_ && compositeId == rhs.compositeId;
 }
@@ -93,44 +64,51 @@ DelayId::operator bool() const
 
 /* create a delay Id for a given request */
 DelayId
-DelayId::DelayClient(ClientHttpRequest * http)
+DelayId::DelayClient(ClientHttpRequest * http, HttpReply *reply)
 {
     HttpRequest *r;
     unsigned short pool;
     assert(http);
     r = http->request;
 
-    if (r->client_addr.IsNoAddr()) {
+    if (r->client_addr.isNoAddr()) {
         debugs(77, 2, "delayClient: WARNING: Called with 'NO_ADDR' address, ignoring");
         return DelayId();
     }
 
-    for (pool = 0; pool < DelayPools::pools(); pool++)
-    {
-        ACLChecklist ch;
+    for (pool = 0; pool < DelayPools::pools(); ++pool) {
+
+        /* pools require explicit 'allow' to assign a client into them */
+        if (!DelayPools::delay_data[pool].access) {
+            debugs(77, DBG_IMPORTANT, "delay_pool " << pool <<
+                   " has no delay_access configured. This means that no clients will ever use it.");
+            continue;
+        }
+
+        ACLFilledChecklist ch(DelayPools::delay_data[pool].access, r, NULL);
+        if (reply) {
+            ch.reply = reply;
+            HTTPMSGLOCK(reply);
+        }
 #if FOLLOW_X_FORWARDED_FOR
-    if (Config.onoff.delay_pool_uses_indirect_client)
-        ch.src_addr = r->indirect_client_addr;
-    else
-#endif /* FOLLOW_X_FORWARDED_FOR */        
-        ch.src_addr = r->client_addr;
+        if (Config.onoff.delay_pool_uses_indirect_client)
+            ch.src_addr = r->indirect_client_addr;
+        else
+#endif /* FOLLOW_X_FORWARDED_FOR */
+            ch.src_addr = r->client_addr;
         ch.my_addr = r->my_addr;
 
         if (http->getConn() != NULL)
             ch.conn(http->getConn());
 
-        ch.request = HTTPMSGLOCK(r);
-
-        ch.accessList = cbdataReference(DelayPools::delay_data[pool].access);
+        if (DelayPools::delay_data[pool].theComposite().getRaw() && ch.fastCheck().allowed()) {
 
-        /* cbdataReferenceDone() happens in either fastCheck() or ~ACLCheckList */
-
-        if (DelayPools::delay_data[pool].theComposite().getRaw() &&
-                ch.fastCheck()) {
             DelayId result (pool + 1);
             CompositePoolNode::CompositeSelectionDetails details;
             details.src_addr = ch.src_addr;
+#if USE_AUTH
             details.user = r->auth_user_request;
+#endif
             details.tag = r->tag;
             result.compositePosition(DelayPools::delay_data[pool].theComposite()->id(details));
             return result;
@@ -195,4 +173,5 @@ DelayId::delayRead(DeferredRead const &aRead)
 
 }
 
-#endif /* DELAY_POOLS */
+#endif /* USE_DELAY_POOLS */
+