]> sourceware.org Git - systemtap.git/commitdiff
Minor changes to cache.cxx (cache_clean).
authorKent Sebastian <ksebasti@toddy.(none)>
Fri, 17 Oct 2008 18:39:33 +0000 (14:39 -0400)
committerKent Sebastian <ksebasti@toddy.(none)>
Fri, 17 Oct 2008 18:39:33 +0000 (14:39 -0400)
ChangeLog
cache.cxx
session.h

index ba5fa7d712eae90fc685ce6a678492c0863109a4..9d75a951b5a10615899eb54599342ca991bd9dca 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-10-14  Kent Sebastian  <ksebasti@redhat.com>
+
+       * cache.cxx (cache_clean): Minor changes, mainly stylistic.
+       * session.h: remove cache_max member var (used only in cache.cxx now)
+
 2008-10-10  Frank Ch. Eigler  <fche@elastic.org>
 
        PR6749
index ce57e2d0f252e17d42e06a65072092e09f158bc8..750e23097ecedc0817da83981a1c76847a47883e 100644 (file)
--- a/cache.cxx
+++ b/cache.cxx
@@ -149,32 +149,22 @@ clean_cache(systemtap_session& s)
       string cache_max_filename = s.cache_path + "/";
       cache_max_filename += SYSTEMTAP_CACHE_MAX_FILENAME;
       ifstream cache_max_file(cache_max_filename.c_str(), ios::in);
+      unsigned long cache_mb_max;
 
       if (cache_max_file.is_open())
         {
-          cache_max_file >> s.cache_max;
+          cache_max_file >> cache_mb_max;
           cache_max_file.close();
-          s.cache_max *= 1024 * 1024;           //convert to bytes
-
-          //bad content in the file?
-          if (s.cache_max < 0)
-            s.cache_max = 0;
         }
       else
         {
           //file doesnt exist or error
-          s.cache_max = 0;
-        }
-
-      if (s.cache_max == 0)
-        {
           if (s.verbose > 1)
             clog << "Missing cache limit file " << s.cache_path << "/" << SYSTEMTAP_CACHE_MAX_FILENAME << ", I/O error or invalid content." << endl;
 
           return;
         }
 
-
       //glob for all kernel modules in the cache dir
       glob_t cache_glob;
       string glob_str = s.cache_path + "/*/*.ko";
@@ -182,7 +172,7 @@ clean_cache(systemtap_session& s)
 
 
       set<struct cache_ent_info, struct weight_sorter> cache_contents;
-      long cache_size = 0;
+      unsigned long cache_size_b = 0;
 
       //grab info for each cache entry (.ko and .c)
       for (unsigned int i = 0; i < cache_glob.gl_pathc; i++)
@@ -197,7 +187,7 @@ clean_cache(systemtap_session& s)
 
           cur_size = get_cache_file_size(cache_ent_path);
           cur_info.size = cur_size;
-          cache_size += cur_size;
+          cache_size_b += cur_size;
 
           if (cur_info.size != 0 && cur_info.weight != 0)
             {
@@ -208,35 +198,28 @@ clean_cache(systemtap_session& s)
       globfree(&cache_glob);
 
       set<struct cache_ent_info, struct weight_sorter>::iterator i;
-      long r_cache_size = cache_size;
+      unsigned long r_cache_size = cache_size_b;
       string removed_dirs = "";
 
       //unlink .ko and .c until the cache size is under the limit
       for (i = cache_contents.begin(); i != cache_contents.end(); ++i)
         {
-          if (r_cache_size < s.cache_max)
+          if ( (r_cache_size / 1024 / 1024) < cache_mb_max)    //convert r_cache_size to MiB
             break;
 
-          //delete this (*i) cache_entry, add to removed list
-          r_cache_size -= (*i).size;
-          unlink_cache_entry((*i).path);
-          removed_dirs += (*i).path + ", ";
+          //remove this (*i) cache_entry, add to removed list
+          r_cache_size -= i->size;
+          unlink_cache_entry(i->path);
+          removed_dirs += i->path + ", ";
         }
 
       cache_contents.clear();
 
-      if (s.verbose > 1)
+      if (s.verbose > 1 && removed_dirs != "")
         {
-          if (removed_dirs == "")
-            {
-              clog << "Cache size under limit, no entries removed." << endl;
-            }
-          else
-            {
-              //remove trailing ", "
-              removed_dirs = removed_dirs.substr(0, removed_dirs.length() - 2);
-              clog << "Cache cleaning successful, removed entries: " << removed_dirs << endl;
-            }
+                 //remove trailing ", "
+                 removed_dirs = removed_dirs.substr(0, removed_dirs.length() - 2);
+                 clog << "Cache cleaning successful, removed entries: " << removed_dirs << endl;
         }
     }
   else
@@ -268,7 +251,7 @@ get_cache_file_size(const string &cache_ent_path)
     cache_ent_size += file_info.st_size;
 
 
-  return cache_ent_size;
+  return cache_ent_size; // / 1024 / 1024;     //convert to MiB
 }
 
 //Assign a weight to this cache entry. A lower weight
index a848a8e5d7ae16c647ed51d33ed3089b9459e2a4..4746422f585996dc314bfdad0092f8a65e05766c 100644 (file)
--- a/session.h
+++ b/session.h
@@ -110,7 +110,6 @@ struct systemtap_session
   bool use_cache;
   std::string cache_path;
   std::string hash_path;
-  long cache_max;
 
   // dwarfless operation
   bool consult_symtab;
This page took 0.037346 seconds and 5 git commands to generate.