good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
139439dc
Commit
139439dc
authored
9 years ago
by
Jeffrey Wilcke
Browse files
Options
Downloads
Plain Diff
Merge pull request #1309 from fjl/p2p-fix-lookup-spin
p2p: throttle all discovery lookups
parents
9cf7913c
6fb810ad
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
p2p/dial.go
+15
-15
15 additions, 15 deletions
p2p/dial.go
p2p/server.go
+1
-0
1 addition, 0 deletions
p2p/server.go
with
16 additions
and
15 deletions
p2p/dial.go
+
15
−
15
View file @
139439dc
...
...
@@ -17,10 +17,9 @@ const (
// redialing a certain node.
dialHistoryExpiration
=
30
*
time
.
Second
// Discovery lookup tasks will wait for this long when
// no results are returned. This can happen if the table
// becomes empty (i.e. not often).
emptyLookupDelay
=
10
*
time
.
Second
// Discovery lookups are throttled and can only run
// once every few seconds.
lookupInterval
=
4
*
time
.
Second
)
// dialstate schedules dials and discovery lookups.
...
...
@@ -206,18 +205,19 @@ func (t *dialTask) String() string {
func
(
t
*
discoverTask
)
Do
(
srv
*
Server
)
{
if
t
.
bootstrap
{
srv
.
ntab
.
Bootstrap
(
srv
.
BootstrapNodes
)
}
else
{
var
target
discover
.
NodeID
rand
.
Read
(
target
[
:
])
t
.
results
=
srv
.
ntab
.
Lookup
(
target
)
// newTasks generates a lookup task whenever dynamic dials are
// necessary. Lookups need to take some time, otherwise the
// event loop spins too fast. An empty result can only be
// returned if the table is empty.
if
len
(
t
.
results
)
==
0
{
time
.
Sleep
(
emptyLookupDelay
)
}
return
}
// newTasks generates a lookup task whenever dynamic dials are
// necessary. Lookups need to take some time, otherwise the
// event loop spins too fast.
next
:=
srv
.
lastLookup
.
Add
(
lookupInterval
)
if
now
:=
time
.
Now
();
now
.
Before
(
next
)
{
time
.
Sleep
(
next
.
Sub
(
now
))
}
srv
.
lastLookup
=
time
.
Now
()
var
target
discover
.
NodeID
rand
.
Read
(
target
[
:
])
t
.
results
=
srv
.
ntab
.
Lookup
(
target
)
}
func
(
t
*
discoverTask
)
String
()
(
s
string
)
{
...
...
This diff is collapsed.
Click to expand it.
p2p/server.go
+
1
−
0
View file @
139439dc
...
...
@@ -115,6 +115,7 @@ type Server struct {
ntab
discoverTable
listener
net
.
Listener
ourHandshake
*
protoHandshake
lastLookup
time
.
Time
// These are for Peers, PeerCount (and nothing else).
peerOp
chan
peerOpFunc
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment