rpc-clnt: separate out connection_cleanup() from destroy()
noticed that there are possibilities where one would like to do a connection_cleanup() before destroying a RPC connection itself, also current code is such that, rpc_clnt_connection_cleanup() does rpc_clnt_ref() and unref(), creating a race window/double unref possibilities in the code. by separating out the functions, this race window/double fault can be prevented. Change-Id: I7ebd3392efa891232857b6db9108b0b19e40fc12 Signed-off-by: Amar Tumballi <amarts@redhat.com> BUG: 802403 Reviewed-on: http://review.gluster.com/2979 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
This commit is contained in:
parent
55c22fbfae
commit
d98c3e1934
@ -815,8 +815,11 @@ cleanup_and_exit (int signum)
|
|||||||
exit (0);
|
exit (0);
|
||||||
#if 0
|
#if 0
|
||||||
/* TODO: Properly do cleanup_and_exit(), with synchronization */
|
/* TODO: Properly do cleanup_and_exit(), with synchronization */
|
||||||
if (ctx->mgmt)
|
if (ctx->mgmt) {
|
||||||
|
/* cleanup the saved-frames before last unref */
|
||||||
|
rpc_clnt_connection_cleanup (&ctx->mgmt->conn);
|
||||||
rpc_clnt_unref (ctx->mgmt);
|
rpc_clnt_unref (ctx->mgmt);
|
||||||
|
}
|
||||||
|
|
||||||
/* call fini() of each xlator */
|
/* call fini() of each xlator */
|
||||||
trav = NULL;
|
trav = NULL;
|
||||||
|
@ -1573,7 +1573,6 @@ rpc_clnt_destroy (struct rpc_clnt *rpc)
|
|||||||
rpc_transport_unref (rpc->conn.trans);
|
rpc_transport_unref (rpc->conn.trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
rpc_clnt_connection_cleanup (&rpc->conn);
|
|
||||||
rpc_clnt_reconnect_cleanup (&rpc->conn);
|
rpc_clnt_reconnect_cleanup (&rpc->conn);
|
||||||
saved_frames_destroy (rpc->conn.saved_frames);
|
saved_frames_destroy (rpc->conn.saved_frames);
|
||||||
pthread_mutex_destroy (&rpc->lock);
|
pthread_mutex_destroy (&rpc->lock);
|
||||||
|
@ -228,6 +228,8 @@ rpc_clnt_ref (struct rpc_clnt *rpc);
|
|||||||
struct rpc_clnt *
|
struct rpc_clnt *
|
||||||
rpc_clnt_unref (struct rpc_clnt *rpc);
|
rpc_clnt_unref (struct rpc_clnt *rpc);
|
||||||
|
|
||||||
|
int rpc_clnt_connection_cleanup (rpc_clnt_connection_t *conn);
|
||||||
|
|
||||||
void rpc_clnt_set_connected (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);
|
void rpc_clnt_unset_connected (rpc_clnt_connection_t *conn);
|
||||||
|
@ -888,6 +888,9 @@ glusterd_friend_cleanup (glusterd_peerinfo_t *peerinfo)
|
|||||||
glusterd_peerctx_t *peerctx = NULL;
|
glusterd_peerctx_t *peerctx = NULL;
|
||||||
|
|
||||||
if (peerinfo->rpc) {
|
if (peerinfo->rpc) {
|
||||||
|
/* cleanup the saved-frames before last unref */
|
||||||
|
rpc_clnt_connection_cleanup (&peerinfo->rpc->conn);
|
||||||
|
|
||||||
peerctx = peerinfo->rpc->mydata;
|
peerctx = peerinfo->rpc->mydata;
|
||||||
peerinfo->rpc->mydata = NULL;
|
peerinfo->rpc->mydata = NULL;
|
||||||
peerinfo->rpc = rpc_clnt_unref (peerinfo->rpc);
|
peerinfo->rpc = rpc_clnt_unref (peerinfo->rpc);
|
||||||
@ -1299,6 +1302,9 @@ glusterd_brick_disconnect (glusterd_brickinfo_t *brickinfo)
|
|||||||
GF_ASSERT (brickinfo);
|
GF_ASSERT (brickinfo);
|
||||||
|
|
||||||
if (brickinfo->rpc) {
|
if (brickinfo->rpc) {
|
||||||
|
/* cleanup the saved-frames before last unref */
|
||||||
|
rpc_clnt_connection_cleanup (&brickinfo->rpc->conn);
|
||||||
|
|
||||||
rpc_clnt_unref (brickinfo->rpc);
|
rpc_clnt_unref (brickinfo->rpc);
|
||||||
brickinfo->rpc = NULL;
|
brickinfo->rpc = NULL;
|
||||||
}
|
}
|
||||||
|
@ -315,8 +315,14 @@ nlm_set_rpc_clnt (rpc_clnt_t *rpc_clnt, char *caller_name)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
ret:
|
ret:
|
||||||
UNLOCK (&nlm_client_list_lk);
|
UNLOCK (&nlm_client_list_lk);
|
||||||
if (rpc_clnt_old)
|
|
||||||
|
if (rpc_clnt_old) {
|
||||||
|
/* cleanup the saved-frames before last unref */
|
||||||
|
rpc_clnt_connection_cleanup (&rpc_clnt_old->conn);
|
||||||
|
|
||||||
rpc_clnt_unref (rpc_clnt_old);
|
rpc_clnt_unref (rpc_clnt_old);
|
||||||
|
}
|
||||||
|
|
||||||
if (old_name)
|
if (old_name)
|
||||||
GF_FREE (old_name);
|
GF_FREE (old_name);
|
||||||
return ret;
|
return ret;
|
||||||
@ -340,8 +346,12 @@ nlm_unset_rpc_clnt (rpc_clnt_t *rpc)
|
|||||||
if (rpc_clnt == NULL) {
|
if (rpc_clnt == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (rpc_clnt)
|
if (rpc_clnt) {
|
||||||
|
/* cleanup the saved-frames before last unref */
|
||||||
|
rpc_clnt_connection_cleanup (&rpc_clnt->conn);
|
||||||
|
|
||||||
rpc_clnt_unref (rpc_clnt);
|
rpc_clnt_unref (rpc_clnt);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2199,6 +2199,9 @@ client_destroy_rpc (xlator_t *this)
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (conf->rpc) {
|
if (conf->rpc) {
|
||||||
|
/* cleanup the saved-frames before last unref */
|
||||||
|
rpc_clnt_connection_cleanup (&conf->rpc->conn);
|
||||||
|
|
||||||
conf->rpc = rpc_clnt_unref (conf->rpc);
|
conf->rpc = rpc_clnt_unref (conf->rpc);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
gf_log (this->name, GF_LOG_DEBUG,
|
gf_log (this->name, GF_LOG_DEBUG,
|
||||||
@ -2434,8 +2437,12 @@ fini (xlator_t *this)
|
|||||||
this->private = NULL;
|
this->private = NULL;
|
||||||
|
|
||||||
if (conf) {
|
if (conf) {
|
||||||
if (conf->rpc)
|
if (conf->rpc) {
|
||||||
|
/* cleanup the saved-frames before last unref */
|
||||||
|
rpc_clnt_connection_cleanup (&conf->rpc->conn);
|
||||||
|
|
||||||
rpc_clnt_unref (conf->rpc);
|
rpc_clnt_unref (conf->rpc);
|
||||||
|
}
|
||||||
|
|
||||||
/* Saved Fds */
|
/* Saved Fds */
|
||||||
/* TODO: */
|
/* TODO: */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user