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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
8f0a4a25
Commit
8f0a4a25
authored
Jul 26, 2016
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
eth/downloader: abort sync if master drops (timeout prev)
parent
a724952f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
eth/downloader/downloader.go
+15
-2
15 additions, 2 deletions
eth/downloader/downloader.go
with
15 additions
and
2 deletions
eth/downloader/downloader.go
+
15
−
2
View file @
8f0a4a25
...
...
@@ -147,8 +147,10 @@ type Downloader struct {
stateWakeCh
chan
bool
// [eth/63] Channel to signal the state fetcher of new tasks
headerProcCh
chan
[]
*
types
.
Header
// [eth/62] Channel to feed the header processor new tasks
// Cancellation and termination
cancelPeer
string
// Identifier of the peer currently being used as the master (cancel on drop)
cancelCh
chan
struct
{}
// Channel to cancel mid-flight syncs
cancelLock
sync
.
RWMutex
// Lock to protect the cancel channel in delivers
cancelLock
sync
.
RWMutex
// Lock to protect the cancel channel
and peer
in delivers
quitCh
chan
struct
{}
// Quit channel to signal termination
quitLock
sync
.
RWMutex
// Lock to prevent double closes
...
...
@@ -254,12 +256,22 @@ func (d *Downloader) RegisterPeer(id string, version int, head common.Hash,
// the specified peer. An effort is also made to return any pending fetches into
// the queue.
func
(
d
*
Downloader
)
UnregisterPeer
(
id
string
)
error
{
// Unregister the peer from the active peer set and revoke any fetch tasks
glog
.
V
(
logger
.
Detail
)
.
Infoln
(
"Unregistering peer"
,
id
)
if
err
:=
d
.
peers
.
Unregister
(
id
);
err
!=
nil
{
glog
.
V
(
logger
.
Error
)
.
Infoln
(
"Unregister failed:"
,
err
)
return
err
}
d
.
queue
.
Revoke
(
id
)
// If this peer was the master peer, abort sync immediately
d
.
cancelLock
.
RLock
()
master
:=
id
==
d
.
cancelPeer
d
.
cancelLock
.
RUnlock
()
if
master
{
d
.
cancel
()
}
return
nil
}
...
...
@@ -332,9 +344,10 @@ func (d *Downloader) synchronise(id string, hash common.Hash, td *big.Int, mode
empty
=
true
}
}
// Create cancel channel for aborting mid-flight
// Create cancel channel for aborting mid-flight
and mark the master peer
d
.
cancelLock
.
Lock
()
d
.
cancelCh
=
make
(
chan
struct
{})
d
.
cancelPeer
=
id
d
.
cancelLock
.
Unlock
()
defer
d
.
cancel
()
// No matter what, we can't leave the cancel channel open
...
...
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