glfs_fini: Fix a possible hang in glfs_fini.

glfs_fini is called when there is a failure in glfs_new,
glfs_init etc. If an application sees a failure in glfs_new
and calls glfs_fini, it will result in hang in glfs_fini.

Fixed the hang.

Change-Id: I80b52cd76d1d7f3fe9a10a91b7226d54176a8982
BUG: 1091335
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-on: http://review.gluster.org/7857
Reviewed-by: soumya k <skoduri@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
This commit is contained in:
Poornima G 2014-05-23 12:58:56 +05:30 committed by Anand Avati
parent e8c13fa9bd
commit a96350fa2b

View File

@ -726,6 +726,7 @@ glfs_fini (struct glfs *fs)
xlator_t *subvol = NULL;
glusterfs_ctx_t *ctx = NULL;
call_pool_t *call_pool = NULL;
int fs_init = 0;
ctx = fs->ctx;
@ -750,22 +751,29 @@ glfs_fini (struct glfs *fs)
*pool*/
ret = (call_pool->cnt == 0)? 0: -1;
subvol = glfs_active_subvol (fs);
if (subvol) {
/* PARENT_DOWN within glfs_subvol_done() is issued only
on graph switch (new graph should activiate and
decrement the extra @winds count taken in glfs_graph_setup()
Since we are explicitly destroying, PARENT_DOWN is necessary
*/
xlator_notify (subvol, GF_EVENT_PARENT_DOWN, subvol, 0);
/* TBD: wait for CHILD_DOWN before exiting, in case of
asynchronous cleanup like graceful socket disconnection
in the future.
*/
pthread_mutex_lock (&fs->mutex);
{
fs_init = fs->init;
}
pthread_mutex_unlock (&fs->mutex);
glfs_subvol_done (fs, subvol);
if (fs_init != 0) {
subvol = glfs_active_subvol (fs);
if (subvol) {
/* PARENT_DOWN within glfs_subvol_done() is issued only
on graph switch (new graph should activiate and
decrement the extra @winds count taken in glfs_graph_setup()
Since we are explicitly destroying, PARENT_DOWN is necessary
*/
xlator_notify (subvol, GF_EVENT_PARENT_DOWN, subvol, 0);
/* TBD: wait for CHILD_DOWN before exiting, in case of
asynchronous cleanup like graceful socket
disconnection in the future.
*/
}
glfs_subvol_done (fs, subvol);
}
if (gf_log_fini(ctx) != 0)
ret = -1;