summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-lib
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2012-10-08 14:16:21 +0530
committerAnand Avati <avati@redhat.com>2012-10-11 16:35:52 -0700
commit92754cd1d12cdda18b27911f3e50eabd907edce6 (patch)
tree5b354de1f73658d2fd6e3d865fb0081dc372784a /rpc/rpc-lib
parent85866c6a9ef9b7401bb05f93fa9602f844d5a35b (diff)
client-handshake: synchronize config.remote_port setting b/w
rpc_clnt_reconnect and client_query_portmap_cbk problem: ------- Theoretically there is a possibility that we could complete querying the remote brick's port number before rpc_transport_connect can return. If rpc_clnt_reconnect happens to be the caller of rpc_transport_connect and we've already got the remote brick's port number by the time rpc_transport_connect returns, without synchronization, rpc_clnt_connect resets config.remote_port to zero even before we have attempted a connection with remote brick. fix: --- By making only poll thread do setting and resetting of config.remote_port, we avoid the race-condition. Change-Id: I51879ba1cac651a80ff5c9c070ec7fe1ceea9e05 BUG: 765051 Signed-off-by: Raghavendra G <raghavendra@gluster.com> Reviewed-on: http://review.gluster.org/4044 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'rpc/rpc-lib')
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index f68c57230..fef604765 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -426,15 +426,6 @@ rpc_clnt_reconnect (void *trans_ptr)
"attempting reconnect");
ret = rpc_transport_connect (trans,
conn->config.remote_port);
- /* Every time there is a disconnection, processes
- should try to connect to 'glusterd' (ie, default
- port) or whichever port given as 'option remote-port'
- in volume file. */
- /* Below code makes sure the (re-)configured port lasts
- for just one successful attempt */
- if (!ret)
- conn->config.remote_port = 0;
-
conn->reconnect =
gf_timer_call_after (clnt->ctx, tv,
rpc_clnt_reconnect,
@@ -923,6 +914,14 @@ rpc_clnt_notify (rpc_transport_t *trans, void *mydata,
case RPC_TRANSPORT_CONNECT:
{
+ /* Every time there is a disconnection, processes
+ should try to connect to 'glusterd' (ie, default
+ port) or whichever port given as 'option remote-port'
+ in volume file. */
+ /* Below code makes sure the (re-)configured port lasts
+ for just one successful attempt */
+ conn->config.remote_port = 0;
+
if (clnt->notifyfn)
ret = clnt->notifyfn (clnt, clnt->mydata,
RPC_CLNT_CONNECT, NULL);
@@ -1479,10 +1478,6 @@ rpc_clnt_submit (struct rpc_clnt *rpc, rpc_clnt_prog_t *prog,
if (conn->connected == 0) {
ret = rpc_transport_connect (conn->trans,
conn->config.remote_port);
- /* Below code makes sure the (re-)configured port lasts
- for just one successful connect attempt */
- if (!ret)
- conn->config.remote_port = 0;
}
ret = rpc_transport_submit_request (rpc->conn.trans,