summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorPoornima G <pgurusid@redhat.com>2014-05-23 12:58:56 +0530
committerAnand Avati <avati@redhat.com>2014-06-02 11:09:04 -0700
commita96350fa2b68626b8592d5cbd67405e4d8416cca (patch)
treecef7417026f44d41ef067c18ed51f56fa18a0305 /api
parente8c13fa9bd2a838335e923ec48bcb66e2cb5861d (diff)
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>
Diffstat (limited to 'api')
-rw-r--r--api/src/glfs.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/api/src/glfs.c b/api/src/glfs.c
index cefbc645eb3..bcabb29f857 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -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);
+
+ 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);
}
-
- glfs_subvol_done (fs, subvol);
if (gf_log_fini(ctx) != 0)
ret = -1;