diff options
author | Atin Mukherjee <amukherj@redhat.com> | 2016-03-20 18:31:00 +0530 |
---|---|---|
committer | Jeff Darcy <jdarcy@redhat.com> | 2016-03-22 12:24:53 -0700 |
commit | 1081584d4c2d26e56fea623ecfadd305c6e3d3bc (patch) | |
tree | 9f6d06ae7e136e428a9f284a2db7a211ed4495d6 /rpc/rpc-lib | |
parent | 056bce103c31be8416bd3ede93c7258c5b3f8554 (diff) |
glusterd/rpc : Discard duplicate Disconnect events
If a peer rpc disconnect event has been already processed, skip the furthers as
processing them are overheads and sometimes may lead to a crash like due to a
double free
Change-Id: Iec589ce85daf28fd5b267cb6fc82a4238e0e8adc
BUG: 1318546
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: http://review.gluster.org/13790
Smoke: Gluster Build System <jenkins@build.gluster.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'rpc/rpc-lib')
-rw-r--r-- | rpc/rpc-lib/src/rpc-clnt.c | 20 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpc-clnt.h | 4 |
2 files changed, 24 insertions, 0 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c index 2ae3bbad370..27e394093cf 100644 --- a/rpc/rpc-lib/src/rpc-clnt.c +++ b/rpc/rpc-lib/src/rpc-clnt.c @@ -782,6 +782,7 @@ rpc_clnt_set_connected (rpc_clnt_connection_t *conn) pthread_mutex_lock (&conn->lock); { conn->connected = 1; + conn->disconnected = _gf_false; } pthread_mutex_unlock (&conn->lock); @@ -800,6 +801,7 @@ rpc_clnt_unset_connected (rpc_clnt_connection_t *conn) pthread_mutex_lock (&conn->lock); { conn->connected = 0; + conn->disconnected = _gf_true; } pthread_mutex_unlock (&conn->lock); @@ -807,6 +809,24 @@ out: return; } +gf_boolean_t +is_rpc_clnt_disconnected (rpc_clnt_connection_t *conn) +{ + gf_boolean_t disconnected = _gf_true; + + if (!conn) + return disconnected; + + pthread_mutex_lock (&conn->lock); + { + if (conn->disconnected == _gf_false) + disconnected = _gf_false; + } + pthread_mutex_unlock (&conn->lock); + + return disconnected; +} + static void rpc_clnt_destroy (struct rpc_clnt *rpc); diff --git a/rpc/rpc-lib/src/rpc-clnt.h b/rpc/rpc-lib/src/rpc-clnt.h index 6a4bb40793f..01caeb814c0 100644 --- a/rpc/rpc-lib/src/rpc-clnt.h +++ b/rpc/rpc-lib/src/rpc-clnt.h @@ -140,6 +140,7 @@ struct rpc_clnt_connection { gf_timer_t *ping_timer; struct rpc_clnt *rpc_clnt; char connected; + gf_boolean_t disconnected; struct saved_frames *saved_frames; int32_t frame_timeout; struct timeval last_sent; @@ -234,6 +235,9 @@ int rpc_clnt_connection_cleanup (rpc_clnt_connection_t *conn); void rpc_clnt_set_connected (rpc_clnt_connection_t *conn); void rpc_clnt_unset_connected (rpc_clnt_connection_t *conn); + +gf_boolean_t is_rpc_clnt_disconnected (rpc_clnt_connection_t *conn); + void rpc_clnt_reconnect (void *trans_ptr); void rpc_clnt_reconfig (struct rpc_clnt *rpc, struct rpc_clnt_config *config); |