summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
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-11 07:28:59 -0700
commit82130d7ef5e4e4842dba44f0283336d98035a590 (patch)
tree8b6e0ba2ab900e72fca68d06c411618bc19a5050 /libglusterfsclient
parent54976b687227e5e12d4138e29a64640318a2db3b (diff)
libglusterfsclient: make glusterfs_umount thread safe
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
Diffstat (limited to 'libglusterfsclient')
-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 ddfc8b4d2..26d9a5234 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)
{