Code

git: remove $Id$ svn cruft
[fusedav.git] / src / statcache.c
index b7cb063bb305cf950fe3e7474b014608fa16cdfb..28f3e275199d561d2274bcb5e79e0a6b6693f826 100644 (file)
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   Copyright (c) 2004-2006 Lennart Poettering
 
@@ -91,20 +89,20 @@ int stat_cache_get(const char *fn, struct stat *st) {
 
     if (debug)
         fprintf(stderr, "CGET: %s\n", fn);
-    
+
     assert(cache);
-    
+
     h = calc_hash(fn);
     ce = cache + (h % CACHE_SIZE);
 
     pthread_mutex_lock(&stat_cache_mutex);
-    
+
     if (ce->stat_info.valid &&
         ce->stat_info.filename &&
         ce->stat_info.hash == h &&
         !strcmp(ce->stat_info.filename, fn) &&
         time(NULL) <= ce->stat_info.dead) {
-        
+
         *st = ce->stat_info.st;
 
         if ((f = file_cache_get(fn))) {
@@ -116,7 +114,7 @@ int stat_cache_get(const char *fn, struct stat *st) {
     }
 
     pthread_mutex_unlock(&stat_cache_mutex);
-    
+
     return r;
 }
 
@@ -127,7 +125,7 @@ void stat_cache_set(const char *fn, const struct stat*st) {
     if (debug)
         fprintf(stderr, "CSET: %s\n", fn);
     assert(cache);
-    
+
     h = calc_hash(fn);
     ce = cache + (h % CACHE_SIZE);
 
@@ -138,7 +136,7 @@ void stat_cache_set(const char *fn, const struct stat*st) {
         ce->stat_info.filename = strdup(fn);
         ce->stat_info.hash = h;
     }
-        
+
     ce->stat_info.st = *st;
     ce->stat_info.dead = time(NULL)+CACHE_TIMEOUT;
     ce->stat_info.valid = 1;
@@ -151,7 +149,7 @@ void stat_cache_invalidate(const char*fn) {
     struct cache_entry *ce;
 
     assert(cache);
-    
+
     h = calc_hash(fn);
     ce = cache + (h % CACHE_SIZE);
 
@@ -160,7 +158,7 @@ void stat_cache_invalidate(const char*fn) {
     ce->stat_info.valid = 0;
     free(ce->stat_info.filename);
     ce->stat_info.filename = NULL;
-    
+
     pthread_mutex_unlock(&stat_cache_mutex);
 }
 
@@ -179,14 +177,14 @@ void dir_cache_begin(const char *fn) {
     struct cache_entry *ce;
     struct dir_entry *de = NULL, *de2 = NULL;
     assert(cache);
-    
+
     h = calc_hash(fn);
     ce = cache + (h % CACHE_SIZE);
-    
+
     pthread_mutex_lock(&dir_cache_mutex);
 
     if (!ce->dir_info.filling) {
-        
+
         if (!ce->dir_info.filename || ce->dir_info.hash != h || strcmp(ce->dir_info.filename, fn)) {
             free(ce->dir_info.filename);
             ce->dir_info.filename = strdup(fn);
@@ -202,7 +200,7 @@ void dir_cache_begin(const char *fn) {
         ce->dir_info.valid2 = 0;
         ce->dir_info.filling = 1;
     }
-    
+
     pthread_mutex_unlock(&dir_cache_mutex);
     free_dir_entries(de);
     free_dir_entries(de2);
@@ -213,12 +211,12 @@ void dir_cache_finish(const char *fn, int success) {
     struct cache_entry *ce;
     struct dir_entry *de = NULL;
     assert(cache);
-    
+
     h = calc_hash(fn);
     ce = cache + (h % CACHE_SIZE);
-    
+
     pthread_mutex_lock(&dir_cache_mutex);
-    
+
     if (ce->dir_info.filling &&
         ce->dir_info.filename &&
         ce->dir_info.hash == h &&
@@ -227,11 +225,11 @@ void dir_cache_finish(const char *fn, int success) {
         assert(!ce->dir_info.valid2);
 
         if (success) {
-            
+
             ce->dir_info.valid2 = 1;
             ce->dir_info.filling = 0;
             ce->dir_info.dead2 = time(NULL)+CACHE_TIMEOUT;
-            
+
             if (!ce->dir_info.in_use) {
                 de = ce->dir_info.entries;
                 ce->dir_info.entries = ce->dir_info.entries2;
@@ -240,7 +238,7 @@ void dir_cache_finish(const char *fn, int success) {
                 ce->dir_info.valid2 = 0;
                 ce->dir_info.valid = 1;
             }
-            
+
         } else {
             ce->dir_info.filling = 0;
             de = ce->dir_info.entries2;
@@ -256,12 +254,12 @@ void dir_cache_add(const char *fn, const char *subdir) {
     uint32_t h;
     struct cache_entry *ce;
     assert(cache);
-    
+
     h = calc_hash(fn);
     ce = cache + (h % CACHE_SIZE);
-    
+
     pthread_mutex_lock(&dir_cache_mutex);
-    
+
     if (ce->dir_info.filling &&
         ce->dir_info.filename &&
         ce->dir_info.hash == h &&
@@ -275,7 +273,7 @@ void dir_cache_add(const char *fn, const char *subdir) {
         assert(n);
 
         strcpy(n->filename, subdir);
-        
+
         n->next = ce->dir_info.entries2;
         ce->dir_info.entries2 = n;
     }
@@ -290,12 +288,12 @@ int dir_cache_enumerate(const char *fn, void (*f) (const char*fn, const char *su
     int r = -1;
 
     assert(cache && f);
-    
+
     h = calc_hash(fn);
     ce = cache + (h % CACHE_SIZE);
-    
+
     pthread_mutex_lock(&dir_cache_mutex);
-    
+
     if (ce->dir_info.valid &&
         ce->dir_info.filename &&
         ce->dir_info.hash == h &&
@@ -322,23 +320,23 @@ int dir_cache_enumerate(const char *fn, void (*f) (const char*fn, const char *su
 
         r = 0;
     }
-    
+
     pthread_mutex_unlock(&dir_cache_mutex);
     free_dir_entries(de);
 
     return r;
-}   
+}
 
 void dir_cache_invalidate(const char*fn) {
     uint32_t h;
     struct cache_entry *ce;
     struct dir_entry *de = NULL;
     assert(cache && fn);
-    
+
     h = calc_hash(fn);
     ce = cache + (h % CACHE_SIZE);
     pthread_mutex_lock(&dir_cache_mutex);
-    
+
     if (ce->dir_info.valid &&
         ce->dir_info.filename &&
         ce->dir_info.hash == h &&
@@ -348,7 +346,7 @@ void dir_cache_invalidate(const char*fn) {
         de = ce->dir_info.entries;
         ce->dir_info.entries = NULL;
     }
-    
+
     pthread_mutex_unlock(&dir_cache_mutex);
     free_dir_entries(de);
 }
@@ -363,7 +361,7 @@ void dir_cache_invalidate_parent(const char *fn) {
             if (p[l-1] == '/')
                 p[l-1] = 0;
         }
-        
+
         dir_cache_invalidate(p);
         free(p);
     } else
@@ -388,7 +386,7 @@ void cache_free(void) {
 }
 
 void cache_alloc(void) {
-    
+
     if (cache)
         return;
 
@@ -396,4 +394,3 @@ void cache_alloc(void) {
     assert(cache);
     memset(cache, 0, sizeof(struct cache_entry)*CACHE_SIZE);
 }
-