changeset 18:350ccab814ca

Fix infinite loops in participant implementation
author Lewin Bormann <lbo@spheniscida.de>
date Sat, 08 Oct 2016 13:16:52 +0200
parents 8ef859976bae
children 507354ead285
files participant_impl.go
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/participant_impl.go	Sat Oct 08 13:16:33 2016 +0200
+++ b/participant_impl.go	Sat Oct 08 13:16:52 2016 +0200
@@ -95,7 +95,7 @@
 
 	// 2. If needed, commit previous changes
 
-	for seq := p.sequence; seq < s; s++ {
+	for seq := p.sequence; seq < s; seq++ {
 		if seq < s {
 			if changes, ok := p.stagedChanges[seq]; ok {
 				for _, c := range changes {
@@ -108,7 +108,7 @@
 
 	// 3. and add staged member
 
-	for seq := p.sequence; seq < s; s++ {
+	for seq := p.sequence; seq < s; seq++ {
 		if seq < s {
 			if member, ok := p.stagedMembers[seq]; ok {
 				p.members = append(p.members, member)
@@ -123,7 +123,7 @@
 	// 4. and commit staged removals
 
 outer:
-	for seq := p.sequence; seq < s; s++ {
+	for seq := p.sequence; seq < s; seq++ {
 		if m, ok := p.stagedRemovals[seq]; ok {
 			for ix, existing := range p.members {
 				if existing == m {
@@ -139,6 +139,7 @@
 
 						p.participantState = state_PARTICIPANT_PENDING
 						delete(p.participants, m)
+						delete(p.stagedRemovals, seq)
 					}
 					break outer
 				}