summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-lib/src/rpc-clnt.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-10-07 05:56:22 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-10-07 05:09:08 -0700
commit5979bc3b964adcb8a536dc354e4eca08acaff03e (patch)
treeca1a5ed41fbc95bd51be7791ae0445132b1593db /rpc/rpc-lib/src/rpc-clnt.c
parent3c0a7fb86eef1eecada77a6f040f96e1fd9e0536 (diff)
protocol/rpc/transport: bring in one more event for 'TRANSPORT-DESTROY'
needed because, a RPC disconnect doesn't mean that a RPC transport/listener is dead. With this, the race in server protocol cleaning up the lock table / fd table when some frames are in transit will be handled properly. Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1843 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1843
Diffstat (limited to 'rpc/rpc-lib/src/rpc-clnt.c')
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index 61bc5263d..bd878f4fc 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -1428,32 +1428,16 @@ rpc_clnt_ref (struct rpc_clnt *rpc)
return rpc;
}
-struct rpc_clnt *
-rpc_clnt_unref (struct rpc_clnt *rpc)
-{
- int count = 0;
-
- if (!rpc)
- return NULL;
- pthread_mutex_lock (&rpc->lock);
- {
- count = --rpc->refcount;
- }
- pthread_mutex_unlock (&rpc->lock);
- if (!count) {
- rpc_clnt_destroy (rpc);
- return NULL;
- }
- return rpc;
-}
-void
+static void
rpc_clnt_destroy (struct rpc_clnt *rpc)
{
if (!rpc)
return;
- rpc_transport_destroy (rpc->conn.trans);
+ if (rpc->conn.trans)
+ rpc_transport_unref (rpc->conn.trans);
+
rpc_clnt_connection_cleanup (&rpc->conn);
rpc_clnt_reconnect_cleanup (&rpc->conn);
saved_frames_destroy (rpc->conn.saved_frames);
@@ -1469,6 +1453,25 @@ rpc_clnt_destroy (struct rpc_clnt *rpc)
return;
}
+struct rpc_clnt *
+rpc_clnt_unref (struct rpc_clnt *rpc)
+{
+ int count = 0;
+
+ if (!rpc)
+ return NULL;
+ pthread_mutex_lock (&rpc->lock);
+ {
+ count = --rpc->refcount;
+ }
+ pthread_mutex_unlock (&rpc->lock);
+ if (!count) {
+ rpc_clnt_destroy (rpc);
+ return NULL;
+ }
+ return rpc;
+}
+
void
rpc_clnt_reconfig (struct rpc_clnt *rpc, struct rpc_clnt_config *config)