Patchwork [BUG:2078] protocol/client: use the new rpc_clnt initialization methods

login
register
Submitter Anand Avati
Date 2010-11-16 13:47:07
Message ID <20101116134707.GA11058@dev.gluster.com>
Download mbox | patch
Permalink /patch/5721/
State Accepted
Headers show

Comments

Anand Avati - 2010-11-16 13:47:07
This way of initializing an rpc_clnt object by splitting into a
passive rpc_clnt_new and a delayed rpc_clnt_start between which
registration of callback programs and notify methods are performed
provides a race-free way to avoid the missing of connect notifications

Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
---
 xlators/protocol/client/src/client.c |   14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)

Patch

diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index 6a40121..198ba08 100644
--- a/xlators/protocol/client/src/client.c
+++ b/xlators/protocol/client/src/client.c
@@ -1607,7 +1607,6 @@  int
 notify (xlator_t *this, int32_t event, void *data, ...)
 {
         clnt_conf_t *conf  = NULL;
-        void        *trans = NULL;
 
         conf = this->private;
         if (!conf)
@@ -1616,20 +1615,11 @@  notify (xlator_t *this, int32_t event, void *data, ...)
         switch (event) {
         case GF_EVENT_PARENT_UP:
         {
-                if (conf->rpc)
-                        trans = conf->rpc->conn.trans;
-
-                if (!trans) {
-                        gf_log (this->name, GF_LOG_DEBUG,
-                                "transport init failed");
-                        return 0;
-                }
-
                 gf_log (this->name, GF_LOG_DEBUG,
                         "got GF_EVENT_PARENT_UP, attempting connect "
                         "on transport");
 
-                rpc_clnt_reconnect (trans);
+                rpc_clnt_start (conf->rpc);
         }
         break;
 
@@ -1761,7 +1751,7 @@  client_init_rpc (xlator_t *this)
                 goto out;
         }
 
-        conf->rpc = rpc_clnt_init (&conf->rpc_conf, this->options, this->ctx,
+        conf->rpc = rpc_clnt_new (&conf->rpc_conf, this->options, this->ctx,
                                    this->name);
         if (!conf->rpc)
                 goto out;