Patchwork [BUG:1611] rdma: do event_unregister() in fini() too.

login
register
Submitter Amar Tumballi
Date 2010-09-18 04:51:55
Message ID <20100918045155.GA4169@gluster.com>
Download mbox | patch
Permalink /patch/4847/
State Accepted
Headers show

Comments

Amar Tumballi - 2010-09-18 04:51:55
Signed-off-by: Amar Tumballi <amar@gluster.com>
---
 rpc/rpc-lib/src/rpc-clnt.c        |    1 +
 rpc/rpc-transport/rdma/src/rdma.c |   31 +++++++++++++++++++------------
 2 files changed, 20 insertions(+), 12 deletions(-)

Patch

diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index 836f45f..8a0f7d4 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -457,6 +457,7 @@  rpc_clnt_reconnect_cleanup (rpc_clnt_connection_t *conn)
                 }
 
         }
+        pthread_mutex_unlock (&conn->lock);
 
 out:
         return 0;
diff --git a/rpc/rpc-transport/rdma/src/rdma.c b/rpc/rpc-transport/rdma/src/rdma.c
index 5704996..7790971 100644
--- a/rpc/rpc-transport/rdma/src/rdma.c
+++ b/rpc/rpc-transport/rdma/src/rdma.c
@@ -4713,6 +4713,8 @@  init (rpc_transport_t *this)
         rdma_private_t *priv = NULL;
 
         priv = GF_CALLOC (1, sizeof (*priv), gf_common_mt_rdma_private_t);
+        if (!priv)
+                return -1;
 
         this->private = priv;
         priv->sock = -1;
@@ -4726,27 +4728,32 @@  init (rpc_transport_t *this)
         return 0;
 }
 
-void  
+void
 fini (struct rpc_transport *this)
 {
         /* TODO: verify this function does graceful finish */
         rdma_private_t *priv = this->private;
         this->private = NULL;
 
-        pthread_mutex_destroy (&priv->recv_mutex);
-        pthread_mutex_destroy (&priv->write_mutex);
-        pthread_mutex_destroy (&priv->read_mutex);
+        if (priv) {
+                pthread_mutex_destroy (&priv->recv_mutex);
+                pthread_mutex_destroy (&priv->write_mutex);
+                pthread_mutex_destroy (&priv->read_mutex);
 
-        mem_pool_destroy (priv->request_ctx_pool);
-        mem_pool_destroy (priv->ioq_pool);
-        mem_pool_destroy (priv->reply_info_pool);
+                mem_pool_destroy (priv->request_ctx_pool);
+                mem_pool_destroy (priv->ioq_pool);
+                mem_pool_destroy (priv->reply_info_pool);
 
-        /*  pthread_cond_destroy (&priv->recv_cond); */
+                /*  pthread_cond_destroy (&priv->recv_cond); */
+                if (priv->sock != -1) {
+                        event_unregister (this->ctx->event_pool,
+                                          priv->sock, priv->idx);
+                }
 
-        gf_log (this->name, GF_LOG_TRACE,
-                "called fini on transport: %p",
-                this);
-        GF_FREE (priv);
+                gf_log (this->name, GF_LOG_TRACE,
+                        "called fini on transport: %p", this);
+                GF_FREE (priv);
+        }
         return;
 }