Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
bboreham committed Mar 21, 2016
1 parent 86a96ee commit 33f84db
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions nameserver/entry.go
Expand Up @@ -108,7 +108,7 @@ func (e1 *Entry) addLowercase() {
e1.lHostname = strings.ToLower(e1.Hostname)
}

func (e *Entry) makeTombstone() {
func (e *Entry) tombstone() {
e.Version++
e.Tombstone = now()
}
Expand Down Expand Up @@ -190,7 +190,7 @@ func (es *Entries) tombstone(ourname mesh.PeerName, f func(*Entry) bool) Entries
tombstoned := Entries{}
for i, e := range *es {
if f(&e) && e.Origin == ourname {
e.makeTombstone()
e.tombstone()
(*es)[i] = e
tombstoned = append(tombstoned, e)
}
Expand Down
10 changes: 5 additions & 5 deletions nameserver/nameserver.go
Expand Up @@ -203,11 +203,8 @@ func (n *Nameserver) receiveGossip(msg []byte) (mesh.GossipData, mesh.GossipData
return nil, nil, fmt.Errorf("clock skew of %d detected", delta)
}

n.Lock()
isKnownPeer := n.isKnownPeer
n.Unlock() // Don't hold the lock over call out to code elsewhere
gossip.Entries.filter(func(e *Entry) bool {
return isKnownPeer(e.Origin)
return n.isKnownPeer(e.Origin)
})

n.Lock()
Expand All @@ -216,6 +213,7 @@ func (n *Nameserver) receiveGossip(msg []byte) (mesh.GossipData, mesh.GossipData
// Check entries claiming to originate from us against our current data
gossip.Entries.filter(func(e *Entry) bool {
if e.Origin == n.ourName {
n.infof("Received entry like mine: %v", e)
if ourEntry, ok := n.entries.findEqual(e); ok {
if ourEntry.Version < e.Version ||
(ourEntry.Version == e.Version && ourEntry.Tombstone != e.Tombstone) {
Expand All @@ -225,7 +223,7 @@ func (n *Nameserver) receiveGossip(msg []byte) (mesh.GossipData, mesh.GossipData
e.Version = higherVersion + 1
}
} else { // We have no entry matching the one that came in with us as Origin
e.makeTombstone()
e.tombstone()
}
}
return true
Expand All @@ -241,13 +239,15 @@ func (n *Nameserver) receiveGossip(msg []byte) (mesh.GossipData, mesh.GossipData
// merge received data into state and return "everything new I've
// just learnt", or nil if nothing in the received data was new
func (n *Nameserver) OnGossip(msg []byte) (mesh.GossipData, error) {
n.infof("Received gossip")
newEntries, _, err := n.receiveGossip(msg)
return newEntries, err
}

// merge received data into state and return a representation of
// the received data, for further propagation
func (n *Nameserver) OnGossipBroadcast(s mesh.PeerName, msg []byte) (mesh.GossipData, error) {
n.infof("Received gossip broadcast from %s", s)
_, entries, err := n.receiveGossip(msg)
return entries, err
}
Expand Down
2 changes: 1 addition & 1 deletion tools
Submodule tools updated 4 files
+2 −1 rebuild-image
+1 −1 scheduler/main.py
+13 −4 socks/main.go
+6 −2 test

0 comments on commit 33f84db

Please sign in to comment.