From 9460675a921d504a31088b0e0f42143cc7f2a56f Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Tue, 27 Jul 2010 14:49:07 +0000 Subject: DVM: Changes in CLI output Signed-off-by: Vijay Bellur Signed-off-by: Anand V. Avati BUG: 1220 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1220 --- cli/src/cli-cmd.c | 65 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 14 deletions(-) (limited to 'cli/src/cli-cmd.c') diff --git a/cli/src/cli-cmd.c b/cli/src/cli-cmd.c index c88d3fe8505..ee30ea996e6 100644 --- a/cli/src/cli-cmd.c +++ b/cli/src/cli-cmd.c @@ -175,23 +175,41 @@ out: } int -cli_cmd_await_response () +cli_cmd_cond_init () { + pthread_mutex_init (&cond_mutex, NULL); pthread_cond_init (&cond, NULL); - cmd_done = 0; + pthread_mutex_init (&conn_mutex, NULL); + pthread_cond_init (&conn, NULL); + + return 0; +} + +int +cli_cmd_lock () +{ pthread_mutex_lock (&cond_mutex); - { - cli_op_ret = 0; - while (!cmd_done) { - pthread_cond_wait (&cond, &cond_mutex); - } - } + return 0; +} + +int +cli_cmd_unlock () +{ pthread_mutex_unlock (&cond_mutex); + return 0; +} + +int +cli_cmd_await_response () +{ - pthread_mutex_destroy (&cond_mutex); - pthread_cond_destroy (&cond); + cmd_done = 0; + while (!cmd_done) + pthread_cond_wait (&cond, &cond_mutex); + + cli_cmd_unlock (); return cli_op_ret; } @@ -214,8 +232,6 @@ cli_cmd_broadcast_response (int32_t status) int32_t cli_cmd_await_connected () { - pthread_mutex_init (&conn_mutex, NULL); - pthread_cond_init (&conn, NULL); pthread_mutex_lock (&conn_mutex); { @@ -225,8 +241,6 @@ cli_cmd_await_connected () } pthread_mutex_unlock (&conn_mutex); - pthread_mutex_destroy (&conn_mutex); - pthread_cond_destroy (&conn); return 0; } @@ -245,3 +259,26 @@ cli_cmd_broadcast_connected () return 0; } + +int +cli_cmd_submit (void *req, call_frame_t *frame, + rpc_clnt_prog_t *prog, + int procnum, struct iobref *iobref, + cli_serialize_t sfunc, xlator_t *this, + fop_cbk_fn_t cbkfn) +{ + int ret = -1; + + cli_cmd_lock (); + ret = cli_submit_request (req, frame, prog, + procnum, NULL, sfunc, + this, cbkfn); + + if (!ret) + ret = cli_cmd_await_response (); + else + cli_cmd_unlock (); + + gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); + return ret; +} -- cgit