Skip to content

Commit

Permalink
Merge branch 'master' into fill-stat-info-from-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
h4sh5 authored Nov 4, 2024
2 parents 5f767de + c9bf8ad commit 1a52814
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ struct cache_dirent {
static void free_node(gpointer node_)
{
struct node *node = (struct node *) node_;
if (node->dir != NULL)
if (node->dir != NULL) {
g_ptr_array_free(node->dir, TRUE);
}
g_free(node);
}

Expand Down Expand Up @@ -207,8 +208,9 @@ static void cache_add_dir(const char *path, GPtrArray *dir)

pthread_mutex_lock(&cache.lock);
node = cache_get(path);
if (node->dir != NULL)
if (node->dir != NULL) {
g_ptr_array_free(node->dir, TRUE);
}
node->dir = dir;
node->dir_valid = time(NULL) + cache.dir_timeout_secs;
if (node->dir_valid > node->valid)
Expand Down Expand Up @@ -391,8 +393,9 @@ static int cache_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
if (node != NULL && node->dir != NULL) {
time_t now = time(NULL);
if (node->dir_valid - now >= 0) {
for(cdent = (struct cache_dirent**)node->dir->pdata; *cdent != NULL; cdent++)
for(cdent = (struct cache_dirent**)node->dir->pdata; *cdent != NULL; cdent++) {
filler(buf, (*cdent)->name, &(*cdent)->stat, 0, 0);
}
pthread_mutex_unlock(&cache.lock);
return 0;
}
Expand Down

0 comments on commit 1a52814

Please sign in to comment.