Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
substrate
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package 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
Radu Popa
substrate
Commits
217d33bb
Commit
217d33bb
authored
6 years ago
by
Svyatoslav Nikolsky
Browse files
Options
Downloads
Patches
Plain Diff
fixed AsyncImportQueue drop deadlock
parent
6a2432d0
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
substrate/network/src/import_queue.rs
+16
-4
16 additions, 4 deletions
substrate/network/src/import_queue.rs
substrate/network/src/on_demand.rs
+2
-2
2 additions, 2 deletions
substrate/network/src/on_demand.rs
with
18 additions
and
6 deletions
substrate/network/src/import_queue.rs
+
16
−
4
View file @
217d33bb
...
...
@@ -140,6 +140,8 @@ impl<B: BlockT> Drop for AsyncImportQueue<B> {
fn
drop
(
&
mut
self
)
{
if
let
Some
(
handle
)
=
self
.handle
.lock
()
.take
()
{
self
.data.is_stopping
.store
(
true
,
Ordering
::
SeqCst
);
self
.data.signal
.notify_one
();
let
_
=
handle
.join
();
}
}
...
...
@@ -148,8 +150,11 @@ impl<B: BlockT> Drop for AsyncImportQueue<B> {
/// Blocks import thread.
fn
import_thread
<
B
:
BlockT
,
E
:
ExecuteInContext
<
B
>>
(
sync
:
Weak
<
RwLock
<
ChainSync
<
B
>>>
,
service
:
Weak
<
E
>
,
chain
:
Weak
<
Client
<
B
>>
,
qdata
:
Arc
<
AsyncImportQueueData
<
B
>>
)
{
trace!
(
target
:
"sync"
,
"Starting import thread"
);
loop
{
if
qdata
.is_stopping
.load
(
Ordering
::
SeqCst
)
{
break
;
}
let
new_blocks
=
{
let
mut
queue_lock
=
qdata
.queue
.lock
();
if
queue_lock
.is_empty
()
{
...
...
@@ -161,9 +166,6 @@ fn import_thread<B: BlockT, E: ExecuteInContext<B>>(sync: Weak<RwLock<ChainSync<
None
=>
break
,
}
};
if
qdata
.is_stopping
.load
(
Ordering
::
SeqCst
)
{
break
;
}
match
(
sync
.upgrade
(),
service
.upgrade
(),
chain
.upgrade
())
{
(
Some
(
sync
),
Some
(
service
),
Some
(
chain
))
=>
{
...
...
@@ -417,6 +419,7 @@ pub mod tests {
use
message
;
use
test_client
::{
self
,
TestClient
};
use
test_client
::
runtime
::{
Block
,
Hash
};
use
on_demand
::
tests
::
DummyExecutor
;
use
super
::
*
;
/// Blocks import queue that is importing blocks in the same thread.
...
...
@@ -563,4 +566,13 @@ pub mod tests {
qdata
.is_stopping
.store
(
true
,
Ordering
::
SeqCst
);
assert!
(
!
import_many_blocks
(
&
mut
TestLink
::
new
(),
Some
(
&
qdata
),
(
BlockOrigin
::
File
,
vec!
[
block
.clone
(),
block
])));
}
#[test]
fn
async_import_queue_drops
()
{
let
queue
=
AsyncImportQueue
::
new
();
let
service
=
Arc
::
new
(
DummyExecutor
);
let
chain
=
Arc
::
new
(
test_client
::
new
());
queue
.start
(
Weak
::
new
(),
Arc
::
downgrade
(
&
service
),
Arc
::
downgrade
(
&
chain
)
as
Weak
<
Client
<
Block
>>
)
.unwrap
();
drop
(
queue
);
}
}
This diff is collapsed.
Click to expand it.
substrate/network/src/on_demand.rs
+
2
−
2
View file @
217d33bb
...
...
@@ -316,7 +316,7 @@ impl<Block: BlockT> Request<Block> {
}
#[cfg(test)]
mod
tests
{
pub
mod
tests
{
use
std
::
collections
::
VecDeque
;
use
std
::
sync
::
Arc
;
use
std
::
time
::
Instant
;
...
...
@@ -331,7 +331,7 @@ mod tests {
use
super
::{
REQUEST_TIMEOUT
,
OnDemand
,
OnDemandService
};
use
test_client
::
runtime
::{
Block
,
Hash
};
struct
DummyExecutor
;
pub
struct
DummyExecutor
;
struct
DummyFetchChecker
{
ok
:
bool
}
impl
ExecuteInContext
<
Block
>
for
DummyExecutor
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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