mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: only redirect msg produced by own node (#11466)
Signed-off-by: Fullstop000 <fullstop1005@gmail.com>
This commit is contained in:
parent
5404b44b15
commit
7eae024ead
@ -293,10 +293,11 @@ func TestNodeReadIndexToOldLeader(t *testing.T) {
|
||||
if len(r1.msgs) != 2 {
|
||||
t.Fatalf("len(r1.msgs) expected 1, got %d", len(r1.msgs))
|
||||
}
|
||||
readIndxMsg3 := raftpb.Message{From: 1, To: 3, Type: raftpb.MsgReadIndex, Entries: testEntries}
|
||||
readIndxMsg3 := raftpb.Message{From: 2, To: 3, Type: raftpb.MsgReadIndex, Entries: testEntries}
|
||||
if !reflect.DeepEqual(r1.msgs[0], readIndxMsg3) {
|
||||
t.Fatalf("r1.msgs[0] expected %+v, got %+v", readIndxMsg3, r1.msgs[0])
|
||||
}
|
||||
readIndxMsg3 = raftpb.Message{From: 3, To: 3, Type: raftpb.MsgReadIndex, Entries: testEntries}
|
||||
if !reflect.DeepEqual(r1.msgs[1], readIndxMsg3) {
|
||||
t.Fatalf("r1.msgs[1] expected %+v, got %+v", readIndxMsg3, r1.msgs[1])
|
||||
}
|
||||
|
@ -399,7 +399,9 @@ func (r *raft) hardState() pb.HardState {
|
||||
|
||||
// send persists state to stable storage and then sends to its mailbox.
|
||||
func (r *raft) send(m pb.Message) {
|
||||
m.From = r.id
|
||||
if m.From == None {
|
||||
m.From = r.id
|
||||
}
|
||||
if m.Type == pb.MsgVote || m.Type == pb.MsgVoteResp || m.Type == pb.MsgPreVote || m.Type == pb.MsgPreVoteResp {
|
||||
if m.Term == 0 {
|
||||
// All {pre-,}campaign messages need to have the term set when
|
||||
|
Loading…
x
Reference in New Issue
Block a user