etcd: fix datarace in peer.go

This commit is contained in:
Xiang Li 2014-07-16 21:40:19 -07:00 committed by Yicheng Qin
parent b8b5734689
commit 7adb765660

View File

@ -48,6 +48,7 @@ func (p *peer) participate() {
p.queue = make(chan []byte)
p.status = participant
for i := 0; i < maxInflight; i++ {
p.wg.Add(1)
go p.handle(p.queue)
}
}
@ -72,11 +73,10 @@ func (p *peer) stop() {
}
func (p *peer) handle(queue chan []byte) {
p.wg.Add(1)
defer p.wg.Done()
for d := range queue {
p.post(d)
}
p.wg.Done()
}
func (p *peer) send(d []byte) error {