DBLOG0((logfile, " mtime: %ld\n", entry->mtime));
}
-static int db_dump_size(FMDB *dbp)
+static int db_dump_size_unlocked(db_state_t *state)
{
int error = 0;
- db_state_t *state = dbp;
char *open_error;
int result_type = RES_CACHE;
char sql_command[2 * PATH_MAX];
return error;
}
+int db_dump_size(FMDB *dbp)
+{
+ int error = 0;
+
+ pthread_mutex_lock(&db_mutex);
+ free_results();
+
+ error = db_dump_size_unlocked(dbp);
+ pthread_mutex_unlock(&db_mutex);
+ return error;
+}
+
static int db_count_size(FMDB *dbp)
{
int error = 0;
DBLOG0((logfile, " mtime: %ld\n", entry->mtime));
}
-static int db_dump_cache(FMDB *dbp)
+static int db_dump_cache_unlocked(db_state_t *state)
{
int error = 0;
- db_state_t *state = dbp;
char *open_error;
int result_type = RES_CACHE;
char sql_command[2 * PATH_MAX];
return error;
}
+int db_dump_cache(FMDB *dbp)
+{
+ int error = 0;
+
+ pthread_mutex_lock(&db_mutex);
+ free_results();
+
+ error = db_dump_cache_unlocked(dbp);
+ pthread_mutex_unlock(&db_mutex);
+ return error;
+}
+
int db_count_cache(FMDB *dbp)
{
int error = 0;
{
DBLOG0((logfile, "%s: failed to find an LRU entry\n", __func__));
error = ENOENT;
- db_dump_cache(dbp);
+ db_dump_cache_unlocked(dbp);
}
pthread_mutex_unlock(&db_mutex);
int db_lookup_size_entry(FMDB *dbp, const db_size_entry_t *in, db_size_entry_t *out);
/* Remove. Needed? */
int db_remove_size_entry(FMDB *dbp, const db_size_entry_t *in);
+/* Dump the contents of the DB to the logfile */
+int db_dump_size(FMDB *dbp);
/********************
*
int db_lookup_cache_entry_by_lru(FMDB *dbp, db_cache_entry_t *out);
/* Remove */
int db_remove_cache_entry(FMDB *dbp, const db_cache_entry_t *in);
+/* Dump the contents of the DB to the logfile */
+int db_dump_cache(FMDB *dbp);
+
/* Synchronise at startup */
int sync_cache_and_db(FMDB *dbp, char *cache_dir);