Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add async queue to keep list of file changes, delete extra code

  • Loading branch information...
commit b62436c0294ab4ba1b5b5a2407eac3e79904a442 1 parent 637ce2d
@paulcbetts authored
Showing with 15 additions and 13 deletions.
  1. +9 −13 src/vcachefs.c
  2. +6 −0 src/vcachefs.h
View
22 src/vcachefs.c
@@ -60,8 +60,13 @@ static struct vcachefs_fdentry* fdentry_ref(struct vcachefs_fdentry* obj)
static void fdentry_unref(struct vcachefs_fdentry* obj)
{
- if(g_atomic_int_dec_and_test(&obj->refcnt))
+ if(g_atomic_int_dec_and_test(&obj->refcnt)) {
+ if(obj->source_fd > 0)
+ close(obj->source_fd);
+ if(obj->filecache_fd > 0)
+ close(obj->filecache_fd);
g_free(obj);
+ }
}
static struct vcachefs_fdentry* fdentry_from_fd(uint fd)
@@ -89,6 +94,7 @@ static void* vcachefs_init(struct fuse_conn_info *conn)
/* Create the file descriptor table */
mount_object->fd_table = g_hash_table_new(g_int_hash, g_int_equal);
g_static_rw_lock_init(&mount_object->fd_table_rwlock);
+ mount_object->file_copy_queue = g_async_queue_new();
mount_object->next_fd = 4;
return mount_object;
@@ -103,6 +109,8 @@ static void vcachefs_destroy(void *mount_object_ptr)
{
struct vcachefs_mount* mount_object = mount_object_ptr;
+ g_async_queue_unref(mount_object->file_copy_queue;
+
/* XXX: We need to make sure no one is using this before we trash it */
g_hash_table_foreach(mount_object->fd_table, trash_fdtable_item, NULL);
g_hash_table_destroy(mount_object->fd_table);
@@ -238,18 +246,6 @@ static int vcachefs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
struct dirent* dentry;
char path_buf[NAME_MAX];
- /*
- (void) offset;
- (void) fi;
-
- if(strcmp(path, "/") != 0)
- return -ENOENT;
-
- filler(buf, ".", NULL, 0);
- filler(buf, "..", NULL, 0);
- filler(buf, vcachefs_path + 1, NULL, 0);
- */
-
if(path == NULL || strlen(path) == 0)
return -ENOENT;
View
6 src/vcachefs.h
@@ -35,6 +35,9 @@ struct vcachefs_mount {
GHashTable* fd_table;
uint next_fd;
GStaticRWLock fd_table_rwlock;
+
+ /* File-based caching */
+ GAsyncQueue* file_copy_queue;
};
struct vcachefs_fdentry {
@@ -43,6 +46,9 @@ struct vcachefs_fdentry {
uint64_t source_fd;
off_t source_offset;
+
+ uint64_t filecache_fd;
+ off_t filecache_offset;
};
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.