Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
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
abdullh.alsoleman
Front-End
Commits
9cc61b0f
Unverified
Commit
9cc61b0f
authored
Mar 24, 2021
by
Jonah Williams
Committed by
GitHub
Mar 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] handle concurrent modification in signal callback (#78913)
parent
d165ea5c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
6 deletions
+25
-6
signals.dart
packages/flutter_tools/lib/src/base/signals.dart
+10
-6
signals_test.dart
...s/flutter_tools/test/general.shard/base/signals_test.dart
+15
-0
No files found.
packages/flutter_tools/lib/src/base/signals.dart
View file @
9cc61b0f
...
@@ -128,12 +128,16 @@ class LocalSignals implements Signals {
...
@@ -128,12 +128,16 @@ class LocalSignals implements Signals {
}
}
Future
<
void
>
_handleSignal
(
ProcessSignal
s
)
async
{
Future
<
void
>
_handleSignal
(
ProcessSignal
s
)
async
{
for
(
final
SignalHandler
handler
in
_handlersList
[
s
]
??
<
SignalHandler
>[])
{
final
List
<
SignalHandler
>?
handlers
=
_handlersList
[
s
];
try
{
if
(
handlers
!=
null
)
{
await
asyncGuard
<
void
>(()
async
=>
handler
(
s
));
final
List
<
SignalHandler
>
handlersCopy
=
handlers
.
toList
();
}
on
Exception
catch
(
e
)
{
for
(
final
SignalHandler
handler
in
handlersCopy
)
{
if
(
_errorStreamController
.
hasListener
)
{
try
{
_errorStreamController
.
add
(
e
);
await
asyncGuard
<
void
>(()
async
=>
handler
(
s
));
}
on
Exception
catch
(
e
)
{
if
(
_errorStreamController
.
hasListener
)
{
_errorStreamController
.
add
(
e
);
}
}
}
}
}
}
}
...
...
packages/flutter_tools/test/general.shard/base/signals_test.dart
View file @
9cc61b0f
...
@@ -56,6 +56,21 @@ void main() {
...
@@ -56,6 +56,21 @@ void main() {
await
completer
.
future
;
await
completer
.
future
;
});
});
testWithoutContext
(
'signal handlers do not cause concurrent modification errors when removing handlers in a signal callback'
,
()
async
{
final
Completer
<
void
>
completer
=
Completer
<
void
>();
Object
token
;
Future
<
void
>
handle
(
ProcessSignal
s
)
async
{
expect
(
s
,
signalUnderTest
);
expect
(
await
signals
.
removeHandler
(
signalUnderTest
,
token
),
true
);
completer
.
complete
();
}
token
=
signals
.
addHandler
(
signalUnderTest
,
handle
);
fakeSignal
.
controller
.
add
(
fakeSignal
);
await
completer
.
future
;
});
testWithoutContext
(
'signal handler error goes on error stream'
,
()
async
{
testWithoutContext
(
'signal handler error goes on error stream'
,
()
async
{
final
Exception
exn
=
Exception
(
'Error'
);
final
Exception
exn
=
Exception
(
'Error'
);
signals
.
addHandler
(
signalUnderTest
,
(
ProcessSignal
s
)
{
signals
.
addHandler
(
signalUnderTest
,
(
ProcessSignal
s
)
{
...
...
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