From 7691550a5bd281e9d21771b37066d44434e92934 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Mon, 24 Jan 2011 22:55:07 +0000 Subject: use rpc_clnt_{new,start} (), instead of rpc_clnt_init(); to prevent a race between getting a CONNECT/DISCONNECT event before registering a notify function Signed-off-by: Amar Tumballi Signed-off-by: Anand V. Avati BUG: 2314 (notify function registration in CLI) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2314 --- cli/src/cli.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'cli') diff --git a/cli/src/cli.c b/cli/src/cli.c index 075b7f43d21..7a0d1ab389e 100644 --- a/cli/src/cli.c +++ b/cli/src/cli.c @@ -522,11 +522,18 @@ cli_rpc_init (struct cli_state *state) if (ret) goto out; - rpc = rpc_clnt_init (&rpc_cfg, options, this->ctx, this->name); + rpc = rpc_clnt_new (&rpc_cfg, options, this->ctx, this->name); - if (rpc) { - ret = rpc_clnt_register_notify (rpc, cli_rpc_notify, this); + if (!rpc) + goto out; + + ret = rpc_clnt_register_notify (rpc, cli_rpc_notify, this); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "failed to register notify"); + goto out; } + + rpc_clnt_start (rpc); out: return rpc; } -- cgit