Преглед изворни кода

etcd-runner: fix race on nextc

fanmin shi пре 9 година
родитељ
комит
b44bd6d2a9
1 измењених фајлова са 3 додато и 1 уклоњено
  1. 3 1
      tools/functional-tester/etcd-runner/command/election_command.go

+ 3 - 1
tools/functional-tester/etcd-runner/command/election_command.go

@@ -129,8 +129,10 @@ func runElectionFunc(cmd *cobra.Command, args []string) {
 				return err
 			}
 			if observedLeader == v {
-				close(nextc)
+				oldNextc := nextc
 				nextc = make(chan struct{})
+				close(oldNextc)
+
 			}
 			<-rcNextc
 			observedLeader = ""