summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorRaghavendra G <rgowdapp@redhat.com>2018-06-03 11:24:18 +0530
committerRaghavendra G <rgowdapp@redhat.com>2018-06-04 12:57:42 +0530
commit3894f4262d53d1c1c593a78b21d72ba1103c86cd (patch)
treece4744ca47344f4ec6096e4569a77e0b32b1551a /xlators
parenta6f0e7a4f1ca203762cae2ed5e426b52124c74dc (diff)
rpc/clnt: Don't let consumers manage "connected" state
The state management of "connected" in rpc is ad-hoc as far as the responsibility goes. Note that there is nothing wrong with functionality itself. rpc layer manages this state in disconnect codepath and has exposed an api to manage this one from consumers. Note that rpc layer never sets "connected" to true by itself, which forces the consumers to use this api to get a working rpc connection. The situation is best captured from a comment in code from Jeff Darcy in glusterfsd/src/gf-attach.c: -/* - * In a sane world, the generic RPC layer would be capable of tracking - * connection status by itself, with no help from us. It might invoke our - * callback if we had registered one, but only to provide information. Sadly, - * we don't live in that world. Instead, the callback *must* exist and *must* - * call rpc_clnt_{set,unset}_connected, because that's the only way those - * fields get set (with RPC both above and below us on the stack). If we don't - * do that, then rpc_clnt_submit doesn't think we're connected even when we - * are. It calls the socket code to reconnect, but the socket code tracks this - * stuff in a sane way so it knows we're connected and returns EINPROGRESS. - * Then we're stuck, connected but unable to use the connection. To make it - * work, we define and register this trivial callback. - */ Also, consumers of rpc know about state of connection only through the notifications sent by rpc-clnt. So, consumers don't have any extra information to manage the state and hence letting them manage the state is counter intuitive. This patch cleans that up and instead moves the responsibility of state management of rpc layer into itself. Change-Id: I31e641a60795fc480ca753917f4b2579f1e05094 Signed-off-by: Raghavendra G <rgowdapp@redhat.com> Fixes: bz#1585585
Diffstat (limited to 'xlators')
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog-rpc.c1
-rw-r--r--xlators/features/changelog/src/changelog-ev-handle.c1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c4
-rw-r--r--xlators/protocol/client/src/client-handshake.c2
4 files changed, 0 insertions, 8 deletions
diff --git a/xlators/features/changelog/lib/src/gf-changelog-rpc.c b/xlators/features/changelog/lib/src/gf-changelog-rpc.c
index c113942..7eb5416 100644
--- a/xlators/features/changelog/lib/src/gf-changelog-rpc.c
+++ b/xlators/features/changelog/lib/src/gf-changelog-rpc.c
@@ -21,7 +21,6 @@ gf_changelog_rpc_notify (struct rpc_clnt *rpc,
{
switch (event) {
case RPC_CLNT_CONNECT:
- rpc_clnt_set_connected (&rpc->conn);
break;
case RPC_CLNT_DISCONNECT:
case RPC_CLNT_MSG:
diff --git a/xlators/features/changelog/src/changelog-ev-handle.c b/xlators/features/changelog/src/changelog-ev-handle.c
index b568194..46d45fb 100644
--- a/xlators/features/changelog/src/changelog-ev-handle.c
+++ b/xlators/features/changelog/src/changelog-ev-handle.c
@@ -138,7 +138,6 @@ changelog_rpc_notify (struct rpc_clnt *rpc,
switch (event) {
case RPC_CLNT_CONNECT:
- rpc_clnt_set_connected (&rpc->conn);
selection = &priv->ev_selection;
LOCK (&c_clnt->wait_lock);
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 9e8a586..64ff9ff 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -6111,7 +6111,6 @@ __glusterd_brick_rpc_notify (struct rpc_clnt *rpc, void *mydata,
break;
}
- rpc_clnt_set_connected (&rpc->conn);
gf_msg_debug (this->name, 0, "Connected to %s:%s",
brickinfo->hostname, brickinfo->path);
@@ -6126,7 +6125,6 @@ __glusterd_brick_rpc_notify (struct rpc_clnt *rpc, void *mydata,
break;
case RPC_CLNT_DISCONNECT:
- rpc_clnt_unset_connected (&rpc->conn);
if (rpc != brickinfo->rpc) {
/*
* There used to be a bunch of races in the volume
@@ -6358,7 +6356,6 @@ __glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata,
switch (event) {
case RPC_CLNT_CONNECT:
{
- rpc_clnt_set_connected (&rpc->conn);
gf_msg_debug (this->name, 0, "got RPC_CLNT_CONNECT");
peerinfo->connected = 1;
peerinfo->quorum_action = _gf_true;
@@ -6391,7 +6388,6 @@ __glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata,
if (is_rpc_clnt_disconnected (&rpc->conn))
break;
- rpc_clnt_unset_connected (&rpc->conn);
gf_msg (this->name, GF_LOG_INFO, 0,
GD_MSG_PEER_DISCONNECTED,
"Peer <%s> (<%s>), in state <%s>, has disconnected "
diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c
index 5c0b475..1c705f5 100644
--- a/xlators/protocol/client/src/client-handshake.c
+++ b/xlators/protocol/client/src/client-handshake.c
@@ -1175,8 +1175,6 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m
conf->rpc->conn.name,
remote_subvol);
- rpc_clnt_set_connected (&conf->rpc->conn);
-
op_ret = 0;
conf->connecting = 0;
conf->connected = 1;