summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-sm.c
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kp@gluster.com>2012-03-13 16:48:58 +0530
committerVijay Bellur <vijay@gluster.com>2012-03-13 04:55:02 -0700
commit4a37d78da3fef69f0074cab3ff71182a68876358 (patch)
tree588f45cc51c6320a45e9f72243736dd2bc0d40e4 /xlators/mgmt/glusterd/src/glusterd-sm.c
parent8c7549f9094d99d679de447230edaa5040db3e92 (diff)
glusterd: Updates on members of cluster must include peer to-be friended
Updates about members of cluster must be sent to the peer to-be friended. Change-Id: I56745885d75af7c609227ba8582da1bb07c1b894 BUG: 801731 Signed-off-by: Krishnan Parthasarathi <kp@gluster.com> Reviewed-on: http://review.gluster.com/2934 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-sm.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-sm.c47
1 files changed, 32 insertions, 15 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c
index a53057fab44..5376c5b6b08 100644
--- a/xlators/mgmt/glusterd/src/glusterd-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.c
@@ -444,22 +444,40 @@ out:
return ret;
}
+static gf_boolean_t
+glusterd_is_valid_recipient_peer (glusterd_peerinfo_t *peerinfo,
+ glusterd_peerinfo_t *cur_peerinfo)
+{
+ gf_boolean_t is_valid = _gf_false;
+
+ if (peerinfo == cur_peerinfo)
+ is_valid = _gf_true;
+
+ else if (peerinfo->connected && peerinfo->peer &&
+ peerinfo->state.state == GD_FRIEND_STATE_BEFRIENDED)
+ is_valid = _gf_true;
+
+
+ return is_valid;
+}
+
static int
glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
{
- int ret = 0;
- glusterd_peerinfo_t *peerinfo = NULL;
- rpc_clnt_procedure_t *proc = NULL;
- xlator_t *this = NULL;
- glusterd_friend_update_ctx_t ev_ctx = {{0}};
- glusterd_conf_t *priv = NULL;
- dict_t *friends = NULL;
- char key[100] = {0,};
- char *dup_buf = NULL;
- int32_t count = 0;
+ int ret = 0;
+ glusterd_peerinfo_t *cur_peerinfo = NULL;
+ glusterd_peerinfo_t *peerinfo = NULL;
+ rpc_clnt_procedure_t *proc = NULL;
+ xlator_t *this = NULL;
+ glusterd_friend_update_ctx_t ev_ctx = {{0}};
+ glusterd_conf_t *priv = NULL;
+ dict_t *friends = NULL;
+ char key[100] = {0,};
+ char *dup_buf = NULL;
+ int32_t count = 0;
GF_ASSERT (event);
- peerinfo = event->peerinfo;
+ cur_peerinfo = event->peerinfo;
this = THIS;
priv = this->private;
@@ -478,9 +496,9 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
goto out;
list_for_each_entry (peerinfo, &priv->peers, uuid_list) {
- if (!peerinfo->connected || !peerinfo->peer ||
- peerinfo->state.state != GD_FRIEND_STATE_BEFRIENDED)
+ if (!glusterd_is_valid_recipient_peer (peerinfo, cur_peerinfo))
continue;
+
count++;
snprintf (key, sizeof (key), "friend%d.uuid", count);
dup_buf = gf_strdup (uuid_utoa (peerinfo->uuid));
@@ -500,8 +518,7 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
goto out;
list_for_each_entry (peerinfo, &priv->peers, uuid_list) {
- if (!peerinfo->connected || !peerinfo->peer ||
- peerinfo->state.state != GD_FRIEND_STATE_BEFRIENDED)
+ if (!glusterd_is_valid_recipient_peer (peerinfo, cur_peerinfo))
continue;
ret = dict_set_static_ptr (friends, "peerinfo", peerinfo);