summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@zresearch.com>2009-06-10 06:59:34 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-06-30 14:36:23 -0700
commit66ebd6dda5b9b33bc3d74ee26080d31344135fba (patch)
tree518a03eb4d72c594713b6b28cc259863b4f25cb4
parent8e0f1ff466a5ce94730829f2005e8a4d7112f44d (diff)
libglusterfsclient: make glusterfs_umount thread safe
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c60
1 files changed, 42 insertions, 18 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index 57849687a..586a918f8 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -1418,39 +1418,64 @@ out:
return ret;
}
-int
-glusterfs_umount (char *vmp)
-{
+inline int
+_libgf_umount (char *vmp)
+{
struct vmp_entry *entry= NULL;
- int ret = -1;
- char *vmp_resolved = NULL;
-
- GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, vmp, out);
-
- vmp_resolved = libgf_resolve_path_light (vmp);
- if (!vmp_resolved)
- goto out;
+ int ret = -1;
- entry = libgf_vmp_search_entry (vmp_resolved);
+ entry = _libgf_vmp_search_entry (vmp);
if (entry == NULL) {
gf_log ("libglusterfsclient", GF_LOG_ERROR,
- "path (%s) not mounted", vmp_resolved);
+ "path (%s) not mounted", vmp);
goto out;
}
- /* FIXME: make this thread safe */
- list_del_init (&entry->list);
-
if (entry->handle == NULL) {
gf_log ("libglusterfsclient", GF_LOG_ERROR,
"path (%s) has no corresponding glusterfs handle",
- vmp_resolved);
+ vmp);
goto out;
}
ret = glusterfs_fini (entry->handle);
libgf_free_vmp_entry (entry);
+ list_del_init (&entry->list);
+ vmplist.entries--;
+
+out:
+ return ret;
+}
+
+inline int
+libgf_umount (char *vmp)
+{
+ int ret = -1;
+
+ pthread_mutex_lock (&lock);
+ {
+ ret = _libgf_umount (vmp);
+ }
+ pthread_mutex_unlock (&lock);
+
+ return ret;
+}
+
+int
+glusterfs_umount (char *vmp)
+{
+ int ret = -1;
+ char *vmp_resolved = NULL;
+
+ GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, vmp, out);
+
+ vmp_resolved = libgf_resolve_path_light (vmp);
+ if (!vmp_resolved)
+ goto out;
+
+ ret = libgf_umount (vmp_resolved);
+
out:
if (vmp_resolved)
FREE (vmp_resolved);
@@ -1464,7 +1489,6 @@ glusterfs_reset (void)
first_fini = first_init = 1;
}
-
void
glusterfs_log_lock (void)
{