Go to the documentation of this file.
23 #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
35 return (*p1)->
weight - (*p2)->weight;
44 double P_last, X_last, Xn;
90 for (t = p->
name; *t != 0; ++t)
100 if (floor(p->
sourcehash.load_factor * 1000.0) == 0.0)
126 for (k = 1; k <= K; ++k) {
127 double Kk1 = (
double) (K - k + 1);
130 p->
sourcehash.load_multiplier += pow(X_last, Kk1);
152 unsigned int user_hash = 0;
153 unsigned int combined_hash;
155 double high_score = 0;
156 const char *key =
NULL;
165 key =
request->client_addr.toStr(ntoabuf,
sizeof(ntoabuf));
168 debugs(39, 2,
"peerSourceHashSelectParent: Calculating hash for " << key);
170 for (c = key; *c != 0; ++c)
176 combined_hash = (user_hash ^ tp->
sourcehash.hash);
177 combined_hash += combined_hash * 0x62531965;
179 score = combined_hash * tp->
sourcehash.load_multiplier;
180 debugs(39, 3,
"peerSourceHashSelectParent: " << tp->
name <<
" combined_hash " << combined_hash <<
181 " score " << std::setprecision(0) << score);
190 debugs(39, 2,
"peerSourceHashSelectParent: selected " << p->
name);
215 sumfetches ? (
double) p->
stats.
fetches / sumfetches : -1.0);
void * xcalloc(size_t n, size_t sz)
struct CachePeer::@30 options
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
static int n_sourcehash_peers
static void peerSourceHashRegisterWithCacheManager(void)
#define cbdataReference(var)
#define ROTATE_LEFT(x, n)
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
struct CachePeer::@28 stats
static int peerSortWeight(const void *a, const void *b)
#define cbdataReferenceDone(var)
CachePeer * peerSourceHashSelectParent(PeerSelector *ps)
static CachePeer ** sourcehash_peers
int peerHTTPOkay(const CachePeer *p, PeerSelector *ps)
void RegisterAction(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
static OBJH peerSourceHashCachemgr
struct _request * request(char *urlin)
#define debugs(SECTION, LEVEL, CONTENT)
void peerSourceHashInit(void)