summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@gluster.com>2009-09-24 00:49:50 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-24 01:19:05 -0700
commitcd13c7e7368ec60ec9b6559e2eced41bcc10d6bc (patch)
treee4fba79727a4ee42de782e8d2c46f425c36ddea9 /libglusterfsclient
parent881e5f243d3c56dcaf54595378beb91c45f1ded5 (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')
-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 0f2c2dd..8ed1493 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -1816,11 +1816,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);