Skip to content

Commit

Permalink
Merge branch 'master' of github.com:hashicorp/raft into master-read
Browse files Browse the repository at this point in the history
* 'master' of github.com:hashicorp/raft:
  Fail starting a tcp_transport with no ip (hashicorp#403)
  Removed the travis-ci build status label (hashicorp#407)
  Use previously set candidate value
  Return decoded candidate address on duplicate requestVote log
  • Loading branch information
yuyang committed Jun 29, 2020
2 parents 4e2c35a + ae3f4f2 commit 3a254c9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
raft [![Build Status](https://travis-ci.org/hashicorp/raft.png)](https://travis-ci.org/hashicorp/raft) [![CircleCI](https://circleci.com/gh/hashicorp/raft.svg?style=svg)](https://circleci.com/gh/hashicorp/raft)
raft [![CircleCI](https://circleci.com/gh/hashicorp/raft.svg?style=svg)](https://circleci.com/gh/hashicorp/raft)
====

raft is a [Go](http://www.golang.org) library that manages a replicated
Expand Down
2 changes: 1 addition & 1 deletion raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ func (r *Raft) requestVote(rpc RPC, req *RequestVoteRequest) {
if lastVoteTerm == req.Term && lastVoteCandBytes != nil {
r.logger.Info("duplicate requestVote for same term", "term", req.Term)
if bytes.Compare(lastVoteCandBytes, req.Candidate) == 0 {
r.logger.Warn("duplicate requestVote from", "candidate", req.Candidate)
r.logger.Warn("duplicate requestVote from", "candidate", candidate)
resp.Granted = true
}
return
Expand Down
2 changes: 1 addition & 1 deletion tcp_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func newTCPTransport(bindAddr string,
list.Close()
return nil, errNotTCP
}
if addr.IP.IsUnspecified() {
if addr.IP == nil || addr.IP.IsUnspecified() {
list.Close()
return nil, errNotAdvertisable
}
Expand Down
7 changes: 7 additions & 0 deletions tcp_transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ func TestTCPTransport_BadAddr(t *testing.T) {
}
}

func TestTCPTransport_EmptyAddr(t *testing.T) {
_, err := NewTCPTransportWithLogger(":0", nil, 1, 0, newTestLogger(t))
if err != errNotAdvertisable {
t.Fatalf("err: %v", err)
}
}

func TestTCPTransport_WithAdvertise(t *testing.T) {
addr := &net.TCPAddr{IP: []byte{127, 0, 0, 1}, Port: 12345}
trans, err := NewTCPTransportWithLogger("0.0.0.0:0", addr, 1, 0, newTestLogger(t))
Expand Down

0 comments on commit 3a254c9

Please sign in to comment.