Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
97d36156
Unverified
Commit
97d36156
authored
May 17, 2019
by
Felföldi Zsolt
Committed by
GitHub
May 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
les: avoid fetcher deadlock on requestChn (#19571)
* les: avoid fetcher deadlock on requestChn
parent
e687d063
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
fetcher.go
les/fetcher.go
+14
-15
No files found.
les/fetcher.go
View file @
97d36156
...
...
@@ -55,7 +55,8 @@ type lightFetcher struct {
requested
map
[
uint64
]
fetchRequest
deliverChn
chan
fetchResponse
timeoutChn
chan
uint64
requestChn
chan
bool
// true if initiated from outside
requestTriggered
bool
requestTrigger
chan
struct
{}
lastTrustedHeader
*
types
.
Header
}
...
...
@@ -122,7 +123,7 @@ func newLightFetcher(pm *ProtocolManager) *lightFetcher {
deliverChn
:
make
(
chan
fetchResponse
,
100
),
requested
:
make
(
map
[
uint64
]
fetchRequest
),
timeoutChn
:
make
(
chan
uint64
),
request
Chn
:
make
(
chan
bool
,
100
),
request
Trigger
:
make
(
chan
struct
{},
1
),
syncDone
:
make
(
chan
*
peer
),
maxConfirmedTd
:
big
.
NewInt
(
0
),
}
...
...
@@ -135,31 +136,26 @@ func newLightFetcher(pm *ProtocolManager) *lightFetcher {
// syncLoop is the main event loop of the light fetcher
func
(
f
*
lightFetcher
)
syncLoop
()
{
requesting
:=
false
defer
f
.
pm
.
wg
.
Done
()
for
{
select
{
case
<-
f
.
pm
.
quitSync
:
return
// when a new announce is received, request loop keeps running until
// no further requests are necessary or possible
case
newAnnounce
:=
<-
f
.
requestChn
:
// request loop keeps running until no further requests are necessary or possible
case
<-
f
.
requestTrigger
:
f
.
lock
.
Lock
()
s
:=
requesting
requesting
=
false
var
(
rq
*
distReq
reqID
uint64
syncing
bool
)
if
!
f
.
syncing
&&
!
(
newAnnounce
&&
s
)
{
if
!
f
.
syncing
{
rq
,
reqID
,
syncing
=
f
.
nextRequest
()
}
f
.
requestTriggered
=
rq
!=
nil
f
.
lock
.
Unlock
()
if
rq
!=
nil
{
requesting
=
true
if
_
,
ok
:=
<-
f
.
pm
.
reqDist
.
queue
(
rq
);
ok
{
if
syncing
{
f
.
lock
.
Lock
()
...
...
@@ -176,11 +172,11 @@ func (f *lightFetcher) syncLoop() {
}
f
.
reqMu
.
Unlock
()
// keep starting new requests while possible
f
.
request
Chn
<-
false
f
.
request
Trigger
<-
struct
{}{}
}()
}
}
else
{
f
.
request
Chn
<-
false
f
.
request
Trigger
<-
struct
{}{}
}
}
case
reqID
:=
<-
f
.
timeoutChn
:
...
...
@@ -220,7 +216,7 @@ func (f *lightFetcher) syncLoop() {
f
.
checkSyncedHeaders
(
p
)
f
.
syncing
=
false
f
.
lock
.
Unlock
()
f
.
request
Chn
<-
fals
e
f
.
request
Trigger
<-
struct
{}{}
// f.requestTriggered is always true her
e
}
}
}
...
...
@@ -354,7 +350,10 @@ func (f *lightFetcher) announce(p *peer, head *announceData) {
fp
.
lastAnnounced
=
n
p
.
lock
.
Unlock
()
f
.
checkUpdateStats
(
p
,
nil
)
f
.
requestChn
<-
true
if
!
f
.
requestTriggered
{
f
.
requestTriggered
=
true
f
.
requestTrigger
<-
struct
{}{}
}
}
// peerHasBlock returns true if we can assume the peer knows the given block
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment