]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/peer_userhash.cc
Supply AccessLogEntry (ALE) for more fast ACL checks. (#182)
[thirdparty/squid.git] / src / peer_userhash.cc
index 82f24559256be3c683f20edec13dfbcf73638b15..d92c1de113dcb767e7d94ce4d8706d0c2a7751be 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -18,6 +18,7 @@
 #include "HttpRequest.h"
 #include "mgr/Registration.h"
 #include "neighbors.h"
+#include "PeerSelectState.h"
 #include "SquidConfig.h"
 #include "Store.h"
 
@@ -120,11 +121,11 @@ peerUserHashInit(void)
      */
     K = n_userhash_peers;
 
-    P_last = 0.0;              /* Empty P_0 */
+    P_last = 0.0;       /* Empty P_0 */
 
-    Xn = 1.0;                  /* Empty starting point of X_1 * X_2 * ... * X_{x-1} */
+    Xn = 1.0;           /* Empty starting point of X_1 * X_2 * ... * X_{x-1} */
 
-    X_last = 0.0;              /* Empty X_0, nullifies the first pow statement */
+    X_last = 0.0;       /* Empty X_0, nullifies the first pow statement */
 
     for (k = 1; k <= K; ++k) {
         double Kk1 = (double) (K - k + 1);
@@ -146,7 +147,7 @@ peerUserHashRegisterWithCacheManager(void)
 }
 
 CachePeer *
-peerUserHashSelectParent(HttpRequest * request)
+peerUserHashSelectParent(PeerSelector *ps)
 {
     int k;
     const char *c;
@@ -161,6 +162,9 @@ peerUserHashSelectParent(HttpRequest * request)
     if (n_userhash_peers == 0)
         return NULL;
 
+    assert(ps);
+    HttpRequest *request = ps->request;
+
     if (request->auth_user_request != NULL)
         key = request->auth_user_request->username();
 
@@ -183,7 +187,7 @@ peerUserHashSelectParent(HttpRequest * request)
         debugs(39, 3, "peerUserHashSelectParent: " << tp->name << " combined_hash " << combined_hash  <<
                " score " << std::setprecision(0) << score);
 
-        if ((score > high_score) && peerHTTPOkay(tp, request)) {
+        if ((score > high_score) && peerHTTPOkay(tp, ps)) {
             p = tp;
             high_score = score;
         }
@@ -220,3 +224,4 @@ peerUserHashCachemgr(StoreEntry * sentry)
 }
 
 #endif /* USE_AUTH */
+