summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 0f2c2dd80a6..8ed1493faa5 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);