From c0dfd786795a8704e92b8e35120780b8c8907f32 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Tue, 17 Aug 2010 06:06:30 +0000 Subject: cli: block command hang Signed-off-by: Vijay Bellur Signed-off-by: Anand V. Avati BUG: 1370 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1370 --- cli/src/cli-cmd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'cli/src/cli-cmd.c') diff --git a/cli/src/cli-cmd.c b/cli/src/cli-cmd.c index d7a4fcd83..7dc416803 100644 --- a/cli/src/cli-cmd.c +++ b/cli/src/cli-cmd.c @@ -239,7 +239,7 @@ cli_cmd_await_response () int ret = 0; cli_op_ret = -1; - cmd_done = 0; + time (&ts.tv_sec); ts.tv_sec += CLI_DEFAULT_CMD_TIMEOUT; while (!cmd_done && !ret) { @@ -247,6 +247,8 @@ cli_cmd_await_response () &ts); } + cmd_done = 0; + cli_cmd_unlock (); if (ret) @@ -258,19 +260,19 @@ cli_cmd_await_response () int cli_cmd_broadcast_response (int32_t status) { - if (!cmd_sent) - goto out; pthread_mutex_lock (&cond_mutex); { + if (!cmd_sent) + goto out; cmd_done = 1; cli_op_ret = status; pthread_cond_broadcast (&cond); } - pthread_mutex_unlock (&cond_mutex); out: + pthread_mutex_unlock (&cond_mutex); return 0; } -- cgit