diff options
author | Krishnan Parthasarathi <kparthas@redhat.com> | 2015-05-19 15:01:08 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2015-06-17 00:53:00 -0700 |
commit | e902df70f8157db4db503b7ec3c2635b08b3dcb2 (patch) | |
tree | ad114936a7f4ae3130831f735a3c62ac2a509a65 /rpc/rpc-lib/src/rpc-clnt.c | |
parent | 1b9a2edf2c18324ae961dd143e9e9685a019087f (diff) |
rpc: fix possible deadlock left behind in d448fd1
See http://review.gluster.org/9613 for more details.
Change-Id: I05ac0267b8c6f4e9b354acbbdf5469835455fb10
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/10821
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Tested-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'rpc/rpc-lib/src/rpc-clnt.c')
-rw-r--r-- | rpc/rpc-lib/src/rpc-clnt.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c index 567ff35b86a..48bd35ce084 100644 --- a/rpc/rpc-lib/src/rpc-clnt.c +++ b/rpc/rpc-lib/src/rpc-clnt.c @@ -495,6 +495,7 @@ rpc_clnt_connection_cleanup (rpc_clnt_connection_t *conn) { struct saved_frames *saved_frames = NULL; struct rpc_clnt *clnt = NULL; + int unref = 0; if (!conn) { goto out; @@ -516,12 +517,7 @@ rpc_clnt_connection_cleanup (rpc_clnt_connection_t *conn) conn->connected = 0; - if (conn->ping_timer) { - gf_timer_call_cancel (clnt->ctx, conn->ping_timer); - conn->ping_timer = NULL; - conn->ping_started = 0; - rpc_clnt_unref (clnt); - } + unref = rpc_clnt_remove_ping_timer_locked (clnt); /*reset rpc msgs stats*/ conn->pingcnt = 0; conn->msgcnt = 0; @@ -529,6 +525,8 @@ rpc_clnt_connection_cleanup (rpc_clnt_connection_t *conn) pthread_mutex_unlock (&conn->lock); saved_frames_destroy (saved_frames); + if (unref) + rpc_clnt_unref (clnt); out: return 0; @@ -1709,6 +1707,7 @@ rpc_clnt_disable (struct rpc_clnt *rpc) { rpc_clnt_connection_t *conn = NULL; rpc_transport_t *trans = NULL; + int unref = 0; if (!rpc) { goto out; @@ -1731,12 +1730,7 @@ rpc_clnt_disable (struct rpc_clnt *rpc) } conn->connected = 0; - if (conn->ping_timer) { - gf_timer_call_cancel (rpc->ctx, conn->ping_timer); - conn->ping_timer = NULL; - conn->ping_started = 0; - rpc_clnt_unref (rpc); - } + unref = rpc_clnt_remove_ping_timer_locked (rpc); trans = conn->trans; conn->trans = NULL; @@ -1747,6 +1741,9 @@ rpc_clnt_disable (struct rpc_clnt *rpc) rpc_transport_disconnect (trans); } + if (unref) + rpc_clnt_unref (rpc); + out: return; } @@ -1756,6 +1753,7 @@ rpc_clnt_disconnect (struct rpc_clnt *rpc) { rpc_clnt_connection_t *conn = NULL; rpc_transport_t *trans = NULL; + int unref = 0; if (!rpc) goto out; @@ -1776,11 +1774,7 @@ rpc_clnt_disconnect (struct rpc_clnt *rpc) } conn->connected = 0; - if (conn->ping_timer) { - gf_timer_call_cancel (rpc->ctx, conn->ping_timer); - conn->ping_timer = NULL; - conn->ping_started = 0; - } + unref = rpc_clnt_remove_ping_timer_locked (rpc); trans = conn->trans; } pthread_mutex_unlock (&conn->lock); @@ -1788,6 +1782,8 @@ rpc_clnt_disconnect (struct rpc_clnt *rpc) if (trans) { rpc_transport_disconnect (trans); } + if (unref) + rpc_clnt_unref (rpc); out: return; |