Skip to content

Commit

Permalink
Exclude duplicates from batches.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvander committed Sep 7, 2014
1 parent 09c28bd commit 2279ee2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions valve/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ func (this *MasterServerQuerier) tryQuery(callback MasterQueryCallback, filters
// Chop off the response header.
packet = packet[6:]

seen := map[string]bool{}

done := false
ip := kNullIP
port := uint16(0)
Expand Down Expand Up @@ -150,10 +152,16 @@ func (this *MasterServerQuerier) tryQuery(callback MasterQueryCallback, filters
break
}

servers = append(servers, &net.TCPAddr{
addr := &net.TCPAddr{
IP: ip,
Port: int(port),
})
}
if _, found := seen[addr.String()]; found {
continue
}

servers = append(servers, addr)
seen[addr.String()] = true
}

if err := callback(servers); err != nil {
Expand Down

0 comments on commit 2279ee2

Please sign in to comment.