diff --git a/plugins/experimental/cache_promote/cache_promote.cc b/plugins/experimental/cache_promote/cache_promote.cc index dab961d3420..056aaaba8d4 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 DEFAULT_BUCKET_SIZE 10 static const char *PLUGIN_NAME = "cache_promote"; TSCont gNocacheCont; @@ -138,8 +139,8 @@ class ChancePolicy : public PromotionPolicy ////////////////////////////////////////////////////////////////////////////////////////////// -// The LRU based policy keeps track of number of URLs, with a counter for each slot. -// Objects are not promoted unless the counter reaches before it gets evicted. An +// The LRU basedo policy keeps track of number of URLs, with a counter for each slot. +// Objects are not promted unless the counter reaches before it gets evicted. An // optional parameter can be used to sample hits, this can reduce contention and // churning in the LRU as well. // @@ -209,6 +210,12 @@ class LRUPolicy : public PromotionPolicy switch (opt) { case 'b': _buckets = static_cast(strtol(optarg, NULL, 10)); + if (_buckets <= 0) { + // buckets size of 0 doesn't make sense and is not supported. Set to default value of 10. + TSDebug(PLUGIN_NAME, "buckets size of 0 is not allowed. Use buckets size >= 10"); + TSDebug(PLUGIN_NAME, "Setting to default bucket size of 10"); + _buckets = DEFAULT_BUCKET_SIZE; + } break; case 'h': _hits = static_cast(strtol(optarg, NULL, 10)); @@ -249,6 +256,7 @@ class LRUPolicy : public PromotionPolicy map_it = _map.find(&hash); if (_map.end() != map_it) { // We have an entry in the LRU + TSReleaseAssert(_list.size() > 0); // mismatch in the LRUs hash and list 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");