-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not use invasive lists to store CachePeers (#1424)
Using invasive lists for CachePeer objects gives no advantages, but requires maintaining non-standard error-prone code that leads to excessive locking and associated memory overheads. Also fixed a neighbors_init() bug that resulted in accessing an already deleted "looks like this host" CachePeer object.
- Loading branch information
1 parent
3e50f1a
commit 2e24d0b
Showing
19 changed files
with
217 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,8 +47,6 @@ CachePeer::~CachePeer() | |
xfree(digest_url); | ||
#endif | ||
|
||
delete next; | ||
|
||
xfree(login); | ||
|
||
delete standby.pool; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 1996-2023 The Squid Software Foundation and contributors | ||
* | ||
* 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 "squid.h" | ||
#include "CachePeers.h" | ||
#include "SquidConfig.h" | ||
|
||
CachePeer & | ||
CachePeers::nextPeerToPing(const size_t pollIndex) | ||
{ | ||
Assure(size()); | ||
|
||
// Remember the number of polls to keep shifting each poll starting point, | ||
// to avoid always polling the same group of peers before other peers and | ||
// risk overloading that first group with requests. | ||
if (!pollIndex) | ||
++peerPolls_; | ||
|
||
// subtract 1 to set the very first pos to zero | ||
const auto pos = (peerPolls_ - 1 + pollIndex) % size(); | ||
|
||
return *storage[pos]; | ||
} | ||
|
||
void | ||
CachePeers::remove(CachePeer * const peer) | ||
{ | ||
const auto pos = std::find_if(storage.begin(), storage.end(), [&](const auto &storePeer) { | ||
return storePeer.get() == peer; | ||
}); | ||
Assure(pos != storage.end()); | ||
storage.erase(pos); | ||
} | ||
|
||
const CachePeers & | ||
CurrentCachePeers() | ||
{ | ||
if (Config.peers) | ||
return *Config.peers; | ||
|
||
static const CachePeers empty; | ||
return empty; | ||
} | ||
|
||
void | ||
DeleteConfigured(CachePeer * const peer) | ||
{ | ||
Assure(Config.peers); | ||
Config.peers->remove(peer); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.