summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-sm.c
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-07-14 00:20:28 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-07-14 14:44:18 -0700
commit32451a4dd02bdd95ec800d51267d2e6be43914a4 (patch)
tree6054625db937658faf1d451d4173a95fd76a8a86 /xlators/mgmt/glusterd/src/glusterd-sm.c
parent9186c9e84c857a0b1bfbfa4e7b46e9eb741186fb (diff)
Fixes a crash seen in create volume
Also includes some re-factoring changes. Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1063 (gluster volume create command segfaults) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1063
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-sm.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-sm.c80
1 files changed, 41 insertions, 39 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c
index b55fdd567..ba9c75872 100644
--- a/xlators/mgmt/glusterd/src/glusterd-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.c
@@ -430,9 +430,9 @@ glusterd_sm_t *glusterd_friend_state_table [] = {
glusterd_state_req_sent,
glusterd_state_req_rcvd,
glusterd_state_befriended,
+ glusterd_state_req_accepted,
glusterd_state_req_sent_rcvd,
glusterd_state_rejected,
- glusterd_state_req_accepted,
glusterd_state_unfriend_sent,
};
@@ -481,54 +481,56 @@ glusterd_friend_sm ()
glusterd_peerinfo_t *peerinfo = NULL;
glusterd_friend_sm_event_type_t event_type = 0;
- list_for_each_entry_safe (event, tmp, &gd_friend_sm_queue, list) {
-
- list_del_init (&event->list);
- peerinfo = event->peerinfo;
- event_type = event->event;
-
- if (!peerinfo &&
- (GD_FRIEND_EVENT_PROBE == event_type ||
- GD_FRIEND_EVENT_RCVD_FRIEND_REQ == event_type)) {
- ret = glusterd_friend_add (NULL,
- GD_FRIEND_STATE_DEFAULT,
- NULL, NULL, &peerinfo);
-
- if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "Unable to add peer, "
- "ret = %d", ret);
- continue;
+ while (!list_empty (&gd_friend_sm_queue)) {
+ list_for_each_entry_safe (event, tmp, &gd_friend_sm_queue, list) {
+
+ list_del_init (&event->list);
+ peerinfo = event->peerinfo;
+ event_type = event->event;
+
+ if (!peerinfo &&
+ (GD_FRIEND_EVENT_PROBE == event_type ||
+ GD_FRIEND_EVENT_RCVD_FRIEND_REQ == event_type)) {
+ ret = glusterd_friend_add (NULL,
+ GD_FRIEND_STATE_DEFAULT,
+ NULL, NULL, &peerinfo);
+
+ if (ret) {
+ gf_log ("glusterd", GF_LOG_ERROR, "Unable to add peer, "
+ "ret = %d", ret);
+ continue;
+ }
+ GF_ASSERT (peerinfo);
+ event->peerinfo = peerinfo;
}
- GF_ASSERT (peerinfo);
- event->peerinfo = peerinfo;
- }
- state = glusterd_friend_state_table[peerinfo->state.state];
+ state = glusterd_friend_state_table[peerinfo->state.state];
- GF_ASSERT (state);
+ GF_ASSERT (state);
- handler = state[event_type].handler;
- GF_ASSERT (handler);
+ handler = state[event_type].handler;
+ GF_ASSERT (handler);
- ret = handler (event, event->ctx);
+ ret = handler (event, event->ctx);
- if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "handler returned: "
- "%d", ret);
- return ret;
- }
+ if (ret) {
+ gf_log ("glusterd", GF_LOG_ERROR, "handler returned: "
+ "%d", ret);
+ return ret;
+ }
- ret = glusterd_friend_sm_transition_state (peerinfo, state, event_type);
+ ret = glusterd_friend_sm_transition_state (peerinfo, state, event_type);
- if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR, "Unable to transition"
- "state from %d to %d", peerinfo->state.state,
- state[event_type].next_state);
- return ret;
- }
+ if (ret) {
+ gf_log ("glusterd", GF_LOG_ERROR, "Unable to transition"
+ "state from %d to %d", peerinfo->state.state,
+ state[event_type].next_state);
+ return ret;
+ }
- GF_FREE (event);
+ GF_FREE (event);
+ }
}