From 813afc3d11464706ca176f31518c6693a9a249bd Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Sun, 27 Mar 2016 03:07:33 -0700 Subject: [PATCH] rafthttp: fix race between AddRemote and Send --- rafthttp/transport.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rafthttp/transport.go b/rafthttp/transport.go index f9ee78bdf..3c4ce3c19 100644 --- a/rafthttp/transport.go +++ b/rafthttp/transport.go @@ -165,10 +165,11 @@ func (t *Transport) Send(msgs []raftpb.Message) { to := types.ID(m.To) t.mu.RLock() - p, ok := t.peers[to] + p, pok := t.peers[to] + g, rok := t.remotes[to] t.mu.RUnlock() - if ok { + if pok { if m.Type == raftpb.MsgApp { t.ServerStats.SendAppendReq(m.Size()) } @@ -176,8 +177,7 @@ func (t *Transport) Send(msgs []raftpb.Message) { continue } - g, ok := t.remotes[to] - if ok { + if rok { g.send(m) continue }