Skip to content

Commit

Permalink
Merge pull request #683 from mirokuratczyk/master
Browse files Browse the repository at this point in the history
Discovery fixes
  • Loading branch information
rod-hynes authored Jun 3, 2024
2 parents db032a5 + 69712e5 commit 1191a6b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions psiphon/server/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ func (d *Discovery) reload(reloadedTactics bool) error {
// Initialize and set underlying discovery component. Replaces old
// component if discovery is already initialized.

oldDiscovery := d.discovery

discovery := discovery.MakeDiscovery(
d.support.PsinetDatabase.GetDiscoveryServers(),
discoveryStrategy)
Expand All @@ -120,6 +118,7 @@ func (d *Discovery) reload(reloadedTactics bool) error {

d.Lock()

oldDiscovery := d.discovery
d.discovery = discovery
d.currentStrategy = strategy

Expand All @@ -143,6 +142,8 @@ func (d *Discovery) reload(reloadedTactics bool) error {

// Stop stops discovery and cleans up underlying resources.
func (d *Discovery) Stop() {
d.Lock()
defer d.Unlock()
d.discovery.Stop()
}

Expand Down
3 changes: 2 additions & 1 deletion psiphon/server/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ func (d *Discovery) Start() {
// Note: servers with a discovery date range in the past are not
// removed from d.all in case the wall clock has drifted;
// otherwise, we risk removing them prematurely.
servers, nextUpdate := discoverableServers(d.all, d.clk)
var servers []*psinet.DiscoveryServer
servers, nextUpdate = discoverableServers(d.all, d.clk)

// Update the set of discoverable servers.
d.strategy.serversChanged(servers)
Expand Down
4 changes: 2 additions & 2 deletions psiphon/server/discovery/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ func runDiscoveryTest(tt *discoveryTest, now time.Time) error {
discovery.Start()

for _, check := range tt.checks {
time.Sleep(1 * time.Second) // let async code complete
time.Sleep(10 * time.Millisecond) // let async code complete
clk.SetNow(check.t)
time.Sleep(1 * time.Second) // let async code complete
time.Sleep(10 * time.Millisecond) // let async code complete
discovered := discovery.SelectServers(net.IP{})
discoveredIPs := make([]string, len(discovered))
for i := range discovered {
Expand Down

0 comments on commit 1191a6b

Please sign in to comment.