summaryrefslogtreecommitdiffstats
path: root/api/src/glfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/glfs.c')
-rw-r--r--api/src/glfs.c50
1 files changed, 28 insertions, 22 deletions
diff --git a/api/src/glfs.c b/api/src/glfs.c
index d995b7f130c..b151936a6e8 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -541,6 +541,32 @@ pub_glfs_from_glfd (struct glfs_fd *glfd)
GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_from_glfd, 3.4.0);
+void
+glfs_fd_destroy (void *data)
+{
+ struct glfs_fd *glfd = NULL;
+
+ if (!data)
+ return;
+
+ glfd = (struct glfs_fd *)data;
+
+ glfs_lock (glfd->fs);
+ {
+ list_del_init (&glfd->openfds);
+ }
+ glfs_unlock (glfd->fs);
+
+ if (glfd->fd) {
+ fd_unref (glfd->fd);
+ glfd->fd = NULL;
+ }
+
+ GF_FREE (glfd->readdirbuf);
+
+ GF_FREE (glfd);
+}
+
struct glfs_fd *
glfs_fd_new (struct glfs *fs)
@@ -555,6 +581,8 @@ glfs_fd_new (struct glfs *fs)
INIT_LIST_HEAD (&glfd->openfds);
+ GF_REF_INIT (glfd, glfs_fd_destroy);
+
return glfd;
}
@@ -573,28 +601,6 @@ glfs_fd_bind (struct glfs_fd *glfd)
glfs_unlock (fs);
}
-void
-glfs_fd_destroy (struct glfs_fd *glfd)
-{
- if (!glfd)
- return;
-
- glfs_lock (glfd->fs);
- {
- list_del_init (&glfd->openfds);
- }
- glfs_unlock (glfd->fs);
-
- if (glfd->fd) {
- fd_unref (glfd->fd);
- glfd->fd = NULL;
- }
-
- GF_FREE (glfd->readdirbuf);
-
- GF_FREE (glfd);
-}
-
static void *
glfs_poller (void *data)