summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-sm.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-03-03 05:47:33 +0000
committerAnand V. Avati <avati@dev.gluster.com>2011-03-04 00:41:00 -0800
commit8f132b363d41e7fe94a8712ed297a5f810e8ed56 (patch)
tree18cd6c294c0eb585ca1ac4da479f79f2926b162c /xlators/mgmt/glusterd/src/glusterd-sm.c
parent568d4027033a5cb89d6aaee757d4c71e5369fe25 (diff)
glusterd: check for the variable before dereferencing it
check if 'peerinfo->mgmt' is set (ie, handshake is completed), before sending any request to that peer. Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 2486 ([glusterfs-3.1.3qa2]: Core generated due to SegFault in glusterd_sm.c) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2486
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-sm.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-sm.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c
index bcab9291127..d245e0f2e04 100644
--- a/xlators/mgmt/glusterd/src/glusterd-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.c
@@ -165,7 +165,7 @@ glusterd_broadcast_friend_delete (char *hostname, uuid_t uuid)
goto out;
list_for_each_entry (peerinfo, &priv->peers, uuid_list) {
- if (!peerinfo->connected)
+ if (!peerinfo->connected || !peerinfo->mgmt)
continue;
ret = dict_set_static_ptr (friends, "peerinfo", peerinfo);
@@ -173,7 +173,8 @@ glusterd_broadcast_friend_delete (char *hostname, uuid_t uuid)
gf_log ("", GF_LOG_ERROR, "failed to set peerinfo");
goto out;
}
- proc = &peerinfo->mgmt->proctable[GD_MGMT_FRIEND_UPDATE];
+
+ proc = &peerinfo->mgmt->proctable[GLUSTERD_MGMT_FRIEND_UPDATE];
if (proc->fn) {
ret = proc->fn (NULL, this, friends);
}
@@ -282,7 +283,9 @@ glusterd_ac_friend_add (glusterd_friend_sm_event_t *event, void *ctx)
GF_ASSERT (conf);
- proc = &peerinfo->mgmt->proctable[GD_MGMT_FRIEND_ADD];
+ if (!peerinfo->mgmt)
+ goto out;
+ proc = &peerinfo->mgmt->proctable[GLUSTERD_MGMT_FRIEND_ADD];
if (proc->fn) {
frame = create_frame (this, this->ctx->pool);
if (!frame) {
@@ -329,7 +332,9 @@ glusterd_ac_friend_probe (glusterd_friend_sm_event_t *event, void *ctx)
goto out;
}
- proc = &peerinfo->mgmt->proctable[GD_MGMT_PROBE_QUERY];
+ if (!peerinfo->mgmt)
+ goto out;
+ proc = &peerinfo->mgmt->proctable[GLUSTERD_MGMT_PROBE_QUERY];
if (proc->fn) {
frame = create_frame (this, this->ctx->pool);
if (!frame) {
@@ -418,7 +423,9 @@ glusterd_ac_send_friend_remove_req (glusterd_friend_sm_event_t *event,
goto out;
}
- proc = &peerinfo->mgmt->proctable[GD_MGMT_FRIEND_REMOVE];
+ if (!peerinfo->mgmt)
+ goto out;
+ proc = &peerinfo->mgmt->proctable[GLUSTERD_MGMT_FRIEND_REMOVE];
if (proc->fn) {
frame = create_frame (this, this->ctx->pool);
if (!frame) {
@@ -487,7 +494,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)
+ if (!peerinfo->connected || !peerinfo->mgmt)
continue;
ret = dict_set_static_ptr (friends, "peerinfo", peerinfo);
@@ -496,7 +503,7 @@ glusterd_ac_send_friend_update (glusterd_friend_sm_event_t *event, void *ctx)
goto out;
}
- proc = &peerinfo->mgmt->proctable[GD_MGMT_FRIEND_UPDATE];
+ proc = &peerinfo->mgmt->proctable[GLUSTERD_MGMT_FRIEND_UPDATE];
if (proc->fn) {
ret = proc->fn (NULL, this, friends);
}