diff options
| author | Mohammed Junaid <junaid@redhat.com> | 2013-01-29 09:55:26 +0530 | 
|---|---|---|
| committer | Anand Avati <avati@redhat.com> | 2013-02-03 12:11:31 -0800 | 
| commit | 34d8edf58ac0379d7495e57c9a846cdec3794b0d (patch) | |
| tree | 9c3af962120c8911757a7a2d790971add0f2a1f6 /api/src/glfs.c | |
| parent | 26d9d2bd27dd9e6ed9a77789afea0944032223d8 (diff) | |
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 <junaid@redhat.com>
Reviewed-on: http://review.gluster.org/4445
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'api/src/glfs.c')
| -rw-r--r-- | api/src/glfs.c | 19 | 
1 files changed, 15 insertions, 4 deletions
diff --git a/api/src/glfs.c b/api/src/glfs.c index f0bdc86f0c6..7be675da3b7 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;  }  | 
