summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-cmd.c
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-07-27 14:49:07 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-07-27 19:39:40 -0700
commit9460675a921d504a31088b0e0f42143cc7f2a56f (patch)
tree30e00eeb0f42da671d778df73a014483ae931ea7 /cli/src/cli-cmd.c
parent26cc6b015bb29f942194d1ca2a3dd21d5483d829 (diff)
DVM: Changes in CLI output
Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1220 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1220
Diffstat (limited to 'cli/src/cli-cmd.c')
-rw-r--r--cli/src/cli-cmd.c65
1 files changed, 51 insertions, 14 deletions
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;
+}