If the DB fails unexpectedly, dump its contents
authorSteve McIntyre <steve@einval.com>
Thu, 27 Jan 2011 00:39:09 +0000 (00:39 +0000)
committerSteve McIntyre <steve@einval.com>
Thu, 27 Jan 2011 00:39:09 +0000 (00:39 +0000)
C/fmcache.c

index 34ded13..5fc45db 100644 (file)
@@ -208,6 +208,7 @@ int cache_entry_encode_complete(const char *cache_file_name, long long size_used
     {
         CACHELOG0((logfile, "%s: failed to find previous entry to match cache file %s\n",
                    __func__, cache_file_name));
+        db_dump_cache(dbp);
         pthread_mutex_unlock(&cache_db_mutex);
         return error;
     }
@@ -255,6 +256,7 @@ int cache_entry_failed(const char *cache_file_name)
     {
         CACHELOG0((logfile, "%s: failed to find previous entry to match cache file %s\n",
                    __func__, cache_file_name));
+        db_dump_cache(dbp);
         pthread_mutex_unlock(&cache_db_mutex);
         return error;
     }
@@ -268,6 +270,7 @@ int cache_entry_failed(const char *cache_file_name)
     {
         CACHELOG0((logfile, "%s: failed to remove entry for cache file %s\n",
                    __func__, cache_file_name));
+        db_dump_cache(dbp);
         pthread_mutex_unlock(&cache_db_mutex);
         return error;
     }
@@ -301,6 +304,7 @@ char *cache_lookup_for_read(const char *basedir, const char *flac_path)
     {
         CACHELOG0((logfile, "%s: failed to find previous entry to match flac_path %s\n",
                    __func__, in.flac_path));
+        db_dump_cache(dbp);
         pthread_mutex_unlock(&cache_db_mutex);
         return NULL;
     }
@@ -323,6 +327,7 @@ char *cache_lookup_for_read(const char *basedir, const char *flac_path)
     {
         CACHELOG0((logfile, "%s: failed to store replacement entry for flac_path %s\n",
                    __func__, in.flac_path));
+        db_dump_cache(dbp);
     }
     pthread_mutex_unlock(&cache_db_mutex);
     CACHELOG1((logfile, "%s: starting to read from cache file %s\n", __func__, out.cache_path));
@@ -344,6 +349,7 @@ int cache_read_finished(const char *basedir, const char *flac_path)
     {
         CACHELOG0((logfile, "%s: failed to find previous entry to match flac_path %s\n",
                    __func__, in.flac_path));
+        db_dump_cache(dbp);
         pthread_mutex_unlock(&cache_db_mutex);
         return ENOENT;
     }
@@ -356,6 +362,7 @@ int cache_read_finished(const char *basedir, const char *flac_path)
     {
         CACHELOG0((logfile, "%s: failed to store replacement entry for flac_path %s\n",
                    __func__, in.flac_path));
+        db_dump_cache(dbp);
     }
     pthread_mutex_unlock(&cache_db_mutex);
     CACHELOG1((logfile, "%s: finished reading from cache file %s\n", __func__, out.cache_path));