Re: Proper error path handling when libgfapi routines fail

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

 



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 <bharata.rao@xxxxxxxxx> 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/


[Index of Archives]     [Gluster Users]     [Ceph Users]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux