gluster-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gluster-devel] Proper error path handling when libgfapi routines fa


From: Anand Avati
Subject: Re: [Gluster-devel] Proper error path handling when libgfapi routines fail
Date: Tue, 17 Jul 2012 23:44:23 -0700

I plan to enhance glfs_fini() to be the common destruction routine for initialized and half-initialized objects. So call glfs_fini() for all failures for now and assume libgfapi will do the cleanup.

Avati

On Tue, Jul 17, 2012 at 11:06 PM, Bharata B Rao <address@hidden> wrote:
Hi Avati,

In QEMU, this is how I am planning to use libgfapi to set the GlusterFS backend.

struct glfs *glfs;
int ret = 0;

glfs = glfs_new(volname);
if (!glfs) {
    ret = -errno;
    goto out_glfs_new_failed;
}

ret = glfs_set_volfile_server(glfs, "socket", server, port);
if (ret < 0) {
    ret = -errno;
    goto out_set_volfile_failed;
}

/* optional */
ret = glfs_set_logging(glfs, logfile, loglevel);
if (ret < 0) {
    ret = -errno;
    goto out_set_logging_failed;
}

ret = glfs_init(glfs);
if (ret < 0) {
    ret = -errno;
    goto out_glfs_init_failed;
}
return ret;

out_glfs_init_failed:
    glfs_unset_logging(glfs, ...);
out_set_logging_failed:
    glfs_unset_volfile_server(glfs, ...);
out_set_volfile_failed:
    glfs_free(glfs);
out_glfs_new_failed:
    return ret;

I see only glfs_fini() in libgfapi currently. I see that all of the
APIs I am using above at least allocate memory which needs to be freed
up at the end or during failure. Are such cleanup routines already
present in libgfapi that could use ? If not, can you please provide
the clean up routines for the above mentioned 4 APIs that QEMU would
be using ?

Regards,
Bharata.
--
http://bharata.sulekha.com/blog/posts.htm, http://raobharata.wordpress.com/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]