summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient/src
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@gluster.com>2009-09-24 00:57:38 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-24 01:19:39 -0700
commit84ad18a00cf0ddd5723eb2d43a0c046a4ed66059 (patch)
treef4db121946af751785015b2464ec4ea9f8ab7e0c /libglusterfsclient/src
parentd2a961b3d6792864d6852590c7dba93dc28906fa (diff)
libglusterfsclient: Wait for all call pools to be destroyed
This ensures that the process using libglusterfsclient does not exit before all the fops and calls have been replied to. It helps to ensure that the backends are in a sane state when the program exits. Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 279 (File written with booster results in self-heal after dd exits) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=279
Diffstat (limited to 'libglusterfsclient/src')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index 41b9d7b6c..abb027232 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -1815,11 +1815,45 @@ void glusterfs_log_unlock (void)
}
+void
+libgf_wait_for_frames_unwind (libglusterfs_client_ctx_t *ctx)
+{
+ call_pool_t *pool = NULL;
+ int canreturn = 0;
+
+ if (!ctx)
+ return;
+
+ pool = (call_pool_t *)ctx->gf_ctx.pool;
+ while (1) {
+ LOCK (&pool->lock);
+ {
+ if (pool->cnt == 0) {
+ canreturn = 1;
+ goto unlock_out;
+ }
+ }
+unlock_out:
+ UNLOCK (&pool->lock);
+
+ if (canreturn)
+ break;
+
+ gf_log (LIBGF_XL_NAME, GF_LOG_DEBUG, "Waiting for call frames");
+ sleep (1);
+ }
+
+ return;
+}
+
+
int
glusterfs_fini (glusterfs_handle_t handle)
{
libglusterfs_client_ctx_t *ctx = handle;
+ libgf_wait_for_frames_unwind (ctx);
+
FREE (ctx->gf_ctx.cmd_args.log_file);
FREE (ctx->gf_ctx.cmd_args.volume_file);
FREE (ctx->gf_ctx.cmd_args.volume_name);