From 34d8edf58ac0379d7495e57c9a846cdec3794b0d Mon Sep 17 00:00:00 2001 From: Mohammed Junaid Date: Tue, 29 Jan 2013 09:55:26 +0530 Subject: gfapi: Mark fs->init status done in glfs_init_done for the case of glfs_init_async. This seen when we call glfs_init_async. The glfs_init_done function, calls the call-back function without assigning 1 to fs->init. The problem occurs when we call glfs_read or a similar api next time which checks if fs->init is 1 and will enter into an infinite wait if it is zero. Change-Id: I34a3d1652c80e737f5b05082a3fbb6e5978b14cd BUG: 839950 Signed-off-by: Mohammed Junaid Reviewed-on: http://review.gluster.org/4445 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- api/src/glfs.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'api') diff --git a/api/src/glfs.c b/api/src/glfs.c index f0bdc86f..7be675da 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -473,20 +473,31 @@ glfs_init_wait (struct glfs *fs) void glfs_init_done (struct glfs *fs, int ret) { - if (fs->init_cbk) { - fs->init_cbk (fs, ret); - return; + glfs_init_cbk init_cbk; + + if (!fs) { + gf_log ("glfs", GF_LOG_ERROR, + "fs is NULL"); + goto out; } + init_cbk = fs->init_cbk; + pthread_mutex_lock (&fs->mutex); { fs->init = 1; fs->ret = ret; fs->err = errno; - pthread_cond_broadcast (&fs->cond); + if (!init_cbk) + pthread_cond_broadcast (&fs->cond); } pthread_mutex_unlock (&fs->mutex); + + if (init_cbk) + init_cbk (fs, ret); +out: + return; } -- cgit