mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
rafthttp: fix race between AddRemote and Send
This commit is contained in:
parent
91dc6b29a6
commit
813afc3d11
@ -165,10 +165,11 @@ func (t *Transport) Send(msgs []raftpb.Message) {
|
|||||||
to := types.ID(m.To)
|
to := types.ID(m.To)
|
||||||
|
|
||||||
t.mu.RLock()
|
t.mu.RLock()
|
||||||
p, ok := t.peers[to]
|
p, pok := t.peers[to]
|
||||||
|
g, rok := t.remotes[to]
|
||||||
t.mu.RUnlock()
|
t.mu.RUnlock()
|
||||||
|
|
||||||
if ok {
|
if pok {
|
||||||
if m.Type == raftpb.MsgApp {
|
if m.Type == raftpb.MsgApp {
|
||||||
t.ServerStats.SendAppendReq(m.Size())
|
t.ServerStats.SendAppendReq(m.Size())
|
||||||
}
|
}
|
||||||
@ -176,8 +177,7 @@ func (t *Transport) Send(msgs []raftpb.Message) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
g, ok := t.remotes[to]
|
if rok {
|
||||||
if ok {
|
|
||||||
g.send(m)
|
g.send(m)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user