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
6ed812db
Unverified
Commit
6ed812db
authored
3 years ago
by
Martin Holst Swende
Committed by
GitHub
3 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
les: avoid shutdown hang (#23139)
parent
3212fb68
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
10 deletions
+4
-10
servingqueue.go
les/servingqueue.go
+4
-10
No files found.
les/servingqueue.go
View file @
6ed812db
...
...
@@ -159,27 +159,23 @@ func (sq *servingQueue) newTask(peer *clientPeer, maxTime uint64, priority int64
// run tokens from the token channel and allow the corresponding tasks to run
// without entering the priority queue.
func
(
sq
*
servingQueue
)
threadController
()
{
defer
sq
.
wg
.
Done
()
for
{
token
:=
make
(
runToken
)
select
{
case
best
:=
<-
sq
.
queueBestCh
:
best
.
tokenCh
<-
token
case
<-
sq
.
stopThreadCh
:
sq
.
wg
.
Done
()
return
case
<-
sq
.
quit
:
sq
.
wg
.
Done
()
return
}
<-
token
select
{
case
<-
sq
.
stopThreadCh
:
sq
.
wg
.
Done
()
return
case
<-
sq
.
quit
:
sq
.
wg
.
Done
()
return
default
:
case
<-
token
:
}
}
}
...
...
@@ -298,6 +294,7 @@ func (sq *servingQueue) addTask(task *servingTask) {
// and always tries to send the highest priority task to queueBestCh. Successfully sent
// tasks are removed from the queue.
func
(
sq
*
servingQueue
)
queueLoop
()
{
defer
sq
.
wg
.
Done
()
for
{
if
sq
.
best
!=
nil
{
expTime
:=
sq
.
best
.
expTime
...
...
@@ -316,7 +313,6 @@ func (sq *servingQueue) queueLoop() {
sq
.
best
,
_
=
sq
.
queue
.
PopItem
()
.
(
*
servingTask
)
}
case
<-
sq
.
quit
:
sq
.
wg
.
Done
()
return
}
}
else
{
...
...
@@ -324,7 +320,6 @@ func (sq *servingQueue) queueLoop() {
case
task
:=
<-
sq
.
queueAddCh
:
sq
.
addTask
(
task
)
case
<-
sq
.
quit
:
sq
.
wg
.
Done
()
return
}
}
...
...
@@ -335,6 +330,7 @@ func (sq *servingQueue) queueLoop() {
// of active thread controller goroutines.
func
(
sq
*
servingQueue
)
threadCountLoop
()
{
var
threadCountTarget
int
defer
sq
.
wg
.
Done
()
for
{
for
threadCountTarget
>
sq
.
threadCount
{
sq
.
wg
.
Add
(
1
)
...
...
@@ -347,14 +343,12 @@ func (sq *servingQueue) threadCountLoop() {
case
sq
.
stopThreadCh
<-
struct
{}{}
:
sq
.
threadCount
--
case
<-
sq
.
quit
:
sq
.
wg
.
Done
()
return
}
}
else
{
select
{
case
threadCountTarget
=
<-
sq
.
setThreadsCh
:
case
<-
sq
.
quit
:
sq
.
wg
.
Done
()
return
}
}
...
...
This diff is collapsed.
Click to expand it.
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