summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2009-07-14 06:41:33 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-07-15 23:15:00 -0700
commit359e87e72fcfc30909b0131a5e559466713245ed (patch)
tree548175629869f43962ed150bb65d9402a0974083
parentfc4aa3ee763e8f05a8bd649d414fb8c278fe7380 (diff)
fuse_bridge: handle failures in init() more gracefully
Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 132 (fuse-bridge could do with some cleanups) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=132
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index f044f2f9526..51878c4e201 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -2649,6 +2649,7 @@ init (xlator_t *this_xl)
fuse_private_t *priv = NULL;
struct stat stbuf = {0,};
struct fuse_args args = FUSE_ARGS_INIT (0, NULL);
+ int xl_name_allocated = 0;
if (this_xl == NULL)
return -1;
@@ -2660,7 +2661,13 @@ init (xlator_t *this_xl)
if (this_xl->name == NULL) {
this_xl->name = strdup ("fuse");
- ERR_ABORT (this_xl->name);
+ if (!this_xl->name) {
+ gf_log("glusterfs-fuse", GF_LOG_ERROR,
+ "Out of memory");
+
+ goto cleanup_exit;
+ }
+ xl_name_allocated = 1;
}
fsname = this_xl->ctx->cmd_args.volume_file;
@@ -2711,12 +2718,22 @@ init (xlator_t *this_xl)
#endif /* LINUX */
#endif /* ! DARWIN_OS */
- if (ret == -1)
- ERR_ABORT (NULL);
+ if (ret == -1) {
+ gf_log("glusterfs-fuse", GF_LOG_ERROR,
+ "Out of memory");
+
+ goto cleanup_exit;
+ }
priv = CALLOC (1, sizeof (*priv));
- ERR_ABORT (priv);
+ if (!priv) {
+ gf_log("glusterfs-fuse", GF_LOG_ERROR,
+ "Out of memory");
+
+ goto cleanup_exit;
+ }
this_xl->private = (void *) priv;
+ priv->mount_point = NULL;
/* get options from option dictionary */
ret = dict_get_str (options, ZR_MOUNTPOINT_OPT, &value_string);
@@ -2752,7 +2769,12 @@ init (xlator_t *this_xl)
goto cleanup_exit;
}
priv->mount_point = strdup (value_string);
- ERR_ABORT (priv->mount_point);
+ if (!priv->mount_point) {
+ gf_log("glusterfs-fuse", GF_LOG_ERROR,
+ "Out of memory");
+
+ goto cleanup_exit;
+ }
ret = dict_get_double (options, "attribute-timeout",
&priv->attribute_timeout);
@@ -2778,6 +2800,14 @@ init (xlator_t *this_xl)
&priv->strict_volfile_check);
}
+ this_xl->itable = inode_table_new (0, this_xl);
+ if (!this_xl->itable) {
+ gf_log("glusterfs-fuse", GF_LOG_ERROR,
+ "Out of memory");
+
+ goto cleanup_exit;
+ }
+
priv->ch = fuse_mount (priv->mount_point, &args);
if (priv->ch == NULL) {
if (errno == ENOTCONN) {
@@ -2855,12 +2885,13 @@ init (xlator_t *this_xl)
this_xl->ctx->top = this_xl;
priv->first_call = 2;
- this_xl->itable = inode_table_new (0, this_xl);
return 0;
umount_exit:
fuse_unmount (priv->mount_point, priv->ch);
cleanup_exit:
+ if (xl_name_allocated)
+ FREE (this_xl->name);
fuse_opt_free_args (&args);
FREE (fsname_opt);
if (priv)