Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New version #2487

Merged
merged 2 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"PublishExcept": null
},
"PollInterval": "6h0m0s",
"PollRetryAfter": "2h0m0s",
"PollRetryAfter": "10m0s",
"PollStopAfter": "168h0m0s",
"PollOverrides": null,
"UseAssigner": false
Expand Down
10 changes: 6 additions & 4 deletions internal/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -1311,17 +1311,19 @@ func (r *Registry) pollProviders(normalPoll polling, pollOverrides map[peer.ID]p
return
}

// Sort from least to most recent.
// Sort from least to most recently polled.
sort.Slice(needPoll, func(i, j int) bool {
return needPoll[i].lastPoll < needPoll[j].lastPoll
})

// Do not poll more than the max, if it is set to non-zero. This selects
// the n least recently used.
// Do not poll more than the max when set to non-zero.
if maxPoll != 0 && len(needPoll) > maxPoll {
needPoll = needPoll[:maxPoll]
}
// Record last poll sequence for infos getting polled

// Record last poll sequence for infos getting polled. This avoids polling
// the same providers during each poll period, if there are others that
// should be polled.
r.provMutex.Lock()
for _, info := range needPoll {
info.lastPoll = pollSeq
Expand Down
6 changes: 3 additions & 3 deletions internal/registry/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,16 +417,16 @@ func TestPollProvider(t *testing.T) {
// Check that registry is not blocked by unread auto-sync channel.
poll.retryAfter = 0
poll.deactivateAfter = 0
r.pollProviders(poll, nil, 2)
r.pollProviders(poll, nil, 3)
done := make(chan struct{})
go func() {
r.pollProviders(poll, nil, 2)
r.pollProviders(poll, nil, 3)
_, ok := r.ProviderInfo(peerID)
require.True(t, ok)
close(done)
}()

timeout.Reset(time.Second)
timeout.Reset(2 * time.Second)
select {
case <-done:
case <-timeout.C:
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "v0.8.17"
"version": "v0.8.18"
}