You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2015/04/26 23:59:40 UTC

trafficserver git commit: TS-3505 A few improvements, thanks Gancho for review

Repository: trafficserver
Updated Branches:
  refs/heads/master d9f1bc531 -> 778b952d9


TS-3505 A few improvements, thanks Gancho for review


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/778b952d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/778b952d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/778b952d

Branch: refs/heads/master
Commit: 778b952d9983c96508653f0d70e0e03c7e30f713
Parents: d9f1bc5
Author: Leif Hedstrom <zw...@apache.org>
Authored: Sun Apr 26 15:59:19 2015 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Sun Apr 26 15:59:19 2015 -0600

----------------------------------------------------------------------
 .../experimental/cache_promote/cache_promote.cc | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/778b952d/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 76368a2..d3820b9 100644
--- a/plugins/experimental/cache_promote/cache_promote.cc
+++ b/plugins/experimental/cache_promote/cache_promote.cc
@@ -197,16 +197,7 @@ typedef std::map<LRUHash *, LRUList::iterator> LRUMap;
 class LRUPolicy : public PromotionPolicy
 {
 public:
-  LRUPolicy() : PromotionPolicy(), _buckets(1000), _hits(10)
-  {
-    // This doesn't have to be perfect, since this is just chance sampling.
-    // coverity[dont_call]
-    srand48((long)time(NULL) ^ (long)getpid() ^ (long)getppid());
-#if HAVE_UNORDERED_MAP
-    _map.reserve(_buckets);
-#endif
-    _lock = TSMutexCreate();
-  }
+  LRUPolicy() : PromotionPolicy(), _buckets(1000), _hits(10), _lock(TSMutexCreate()) {}
 
   ~LRUPolicy()
   {
@@ -237,6 +228,13 @@ public:
       return false;
     }
 
+    // This doesn't have to be perfect, since this is just chance sampling.
+    // coverity[dont_call]
+    srand48((long)time(NULL) ^ (long)getpid() ^ (long)getppid());
+#if HAVE_UNORDERED_MAP
+    _map.reserve(_buckets);
+#endif
+
     return true;
   }
 
@@ -257,7 +255,7 @@ public:
 
     map_it = _map.find(&hash);
     if (_map.end() != map_it) {
-      // We have an entry in the URL
+      // We have an entry in the LRU
       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");