Repository: trafficserver Updated Branches: refs/heads/master 74ecfefb0 -> e37d0b0d1
TS-4050 - Fixes cache_promote crash when buckets=0 This also sets buckets default value to be 10. This closes #361. Leif: I fixed typos in the comments, changed the default bucket size to a minimum bucket size, and decided it'd be better to change to a debug assert. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e37d0b0d Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e37d0b0d Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e37d0b0d Branch: refs/heads/master Commit: e37d0b0d1a49326a727fb3f52db33f5218da1805 Parents: 74ecfef Author: Meera Mosale Nataraja <[email protected]> Authored: Thu Dec 3 15:31:00 2015 -0800 Committer: Leif Hedstrom <[email protected]> Committed: Sat Dec 5 11:18:21 2015 -0700 ---------------------------------------------------------------------- plugins/experimental/cache_promote/cache_promote.cc | 7 +++++++ 1 file changed, 7 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e37d0b0d/plugins/experimental/cache_promote/cache_promote.cc ---------------------------------------------------------------------- diff --git a/plugins/experimental/cache_promote/cache_promote.cc b/plugins/experimental/cache_promote/cache_promote.cc index dab961d..3cf9028 100644 --- a/plugins/experimental/cache_promote/cache_promote.cc +++ b/plugins/experimental/cache_promote/cache_promote.cc @@ -32,6 +32,7 @@ #include "ts/remap.h" #include "ts/ink_config.h" +#define MINIMUM_BUCKET_SIZE 10 static const char *PLUGIN_NAME = "cache_promote"; TSCont gNocacheCont; @@ -209,6 +210,11 @@ public: switch (opt) { case 'b': _buckets = static_cast<unsigned>(strtol(optarg, NULL, 10)); + if (_buckets < MINIMUM_BUCKET_SIZE) { + TSError("%s: Enforcing minimum LRU bucket size of %d", PLUGIN_NAME, MINIMUM_BUCKET_SIZE); + TSDebug(PLUGIN_NAME, "Enforcing minimum bucket size of %d", MINIMUM_BUCKET_SIZE); + _buckets = MINIMUM_BUCKET_SIZE; + } break; case 'h': _hits = static_cast<unsigned>(strtol(optarg, NULL, 10)); @@ -249,6 +255,7 @@ public: map_it = _map.find(&hash); if (_map.end() != map_it) { // We have an entry in the LRU + TSAssert(_list.size() > 0); // mismatch in the LRUs hash and list, shouldn't happen if (++(map_it->second->second) >= _hits) { // Promoted! Cleanup the LRU, and signal success. Save the promoted entry on the freelist. TSDebug(PLUGIN_NAME, "saving the LRUEntry to the freelist");
