Skip to content

Commit

Permalink
squash: feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
karampok committed Nov 15, 2019
1 parent d5a78c0 commit 8b1b42c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
7 changes: 4 additions & 3 deletions go/beacon_srv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,14 @@ func (t *periodicTasks) Start() error {
t.running = true
topo := t.topoProvider.Get()
topoAddress := topo.PublicAddress(addr.SvcBS, cfg.General.ID)
if topoAddress == nil {
return serrors.New("Unable to find topo address")
}
bs := &net.UDPAddr{
IP: topoAddress.L3.IP(),
Port: int(topoAddress.L4),
}
if topoAddress == nil {
return serrors.New("Unable to find topo address")
}

var err error
if t.registrars, err = t.startSegRegRunners(); err != nil {
return err
Expand Down
13 changes: 3 additions & 10 deletions go/examples/discovery_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"net"
"net/url"
"os"
"strconv"
"sync"
"time"

Expand Down Expand Up @@ -128,11 +127,7 @@ func getTopo() (*topology.Topo, error) {
ctx, cancelF := context.WithTimeout(context.Background(), *timeout)
defer cancelF()

ip, sport, err := net.SplitHostPort(*ds)
if err != nil {
return nil, err
}
port, err := strconv.Atoi(sport)
a, err := net.ResolveUDPAddr("udp", *ds)
if err != nil {
return nil, err
}
Expand All @@ -141,10 +136,8 @@ func getTopo() (*topology.Topo, error) {
File: file(),
Mode: mode(),
Https: *https,
}, &net.UDPAddr{
IP: net.ParseIP(ip),
Port: port,
}, nil)
}, a,
nil)
return ret, err
}
log.Info("Load initial topology from disk", "topo", topoPath)
Expand Down
8 changes: 6 additions & 2 deletions go/lib/discovery/discoveryinfo/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ func New(key string, addr *net.UDPAddr) *Info {
func (h *Info) Update(a *net.UDPAddr) {
h.mu.Lock()
defer h.mu.Unlock()
if !h.addr.IP.Equal(a.IP) {
h.addr = a
if !h.addr.IP.Equal(a.IP) || h.addr.Port != a.Port {
h.addr.Port = a.Port
copy(h.addr.IP, a.IP)
h.failCount = 0
h.lastFail = time.Now()
h.lastExp = time.Now()
Expand All @@ -74,6 +75,9 @@ func (h *Info) Key() string {
func (h *Info) Addr() *net.UDPAddr {
h.mu.Lock()
defer h.mu.Unlock()
ret := &net.UDPAddr{}
ret.Port = h.addr.Port
copy(ret.IP, h.addr.IP)
return h.addr
}

Expand Down
1 change: 0 additions & 1 deletion go/lib/discovery/discoverypool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func (p *Pool) Update(svcInfo topology.IDAddrMap) error {
} else {
info.Update(y)
}

}
// Get list of outdated DS servers.
var del []string
Expand Down

0 comments on commit 8b1b42c

Please sign in to comment.