summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/src/glfs.c19
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;
}