Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
dfa342e8
Unverified
Commit
dfa342e8
authored
Aug 19, 2019
by
Joseph Noir
Committed by
GitHub
Aug 19, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #881
Fix potential deadlock in proxy_registry
parents
6eeee3f3
10f5de50
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
19 deletions
+42
-19
libcaf_core/src/proxy_registry.cpp
libcaf_core/src/proxy_registry.cpp
+42
-19
No files found.
libcaf_core/src/proxy_registry.cpp
View file @
dfa342e8
...
...
@@ -88,17 +88,28 @@ bool proxy_registry::empty() const {
void
proxy_registry
::
erase
(
const
node_id
&
nid
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
nid
));
// Move submap for `nid` to a local variable.
proxy_map
tmp
;
{
using
std
::
swap
;
std
::
unique_lock
<
std
::
mutex
>
guard
{
mtx_
};
auto
i
=
proxies_
.
find
(
nid
);
if
(
i
==
proxies_
.
end
())
return
;
for
(
auto
&
kvp
:
i
->
second
)
kill_proxy
(
kvp
.
second
,
exit_reason
::
remote_link_unreachable
);
swap
(
i
->
second
,
tmp
);
proxies_
.
erase
(
i
);
}
// Call kill_proxy outside the critical section.
for
(
auto
&
kvp
:
tmp
)
kill_proxy
(
kvp
.
second
,
exit_reason
::
remote_link_unreachable
);
}
void
proxy_registry
::
erase
(
const
node_id
&
nid
,
actor_id
aid
,
error
rsn
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
nid
)
<<
CAF_ARG
(
aid
));
// Try to find the actor handle in question.
strong_actor_ptr
erased_proxy
;
{
using
std
::
swap
;
std
::
unique_lock
<
std
::
mutex
>
guard
{
mtx_
};
auto
i
=
proxies_
.
find
(
nid
);
if
(
i
!=
proxies_
.
end
())
{
...
...
@@ -106,16 +117,28 @@ void proxy_registry::erase(const node_id& nid, actor_id aid, error rsn) {
auto
j
=
submap
.
find
(
aid
);
if
(
j
==
submap
.
end
())
return
;
kill_proxy
(
j
->
second
,
std
::
move
(
rsn
)
);
swap
(
j
->
second
,
erased_proxy
);
submap
.
erase
(
j
);
if
(
submap
.
empty
())
proxies_
.
erase
(
i
);
}
}
// Call kill_proxy outside the critical section.
if
(
erased_proxy
!=
nullptr
)
kill_proxy
(
erased_proxy
,
std
::
move
(
rsn
));
}
void
proxy_registry
::
clear
()
{
CAF_LOG_TRACE
(
""
);
// Move the content of proxies_ to a local variable.
std
::
unordered_map
<
node_id
,
proxy_map
>
tmp
;
{
using
std
::
swap
;
std
::
unique_lock
<
std
::
mutex
>
guard
{
mtx_
};
for
(
auto
&
kvp
:
proxies_
)
swap
(
proxies_
,
tmp
);
}
// Call kill_proxy outside the critical section.
for
(
auto
&
kvp
:
tmp
)
for
(
auto
&
sub_kvp
:
kvp
.
second
)
kill_proxy
(
sub_kvp
.
second
,
exit_reason
::
remote_link_unreachable
);
proxies_
.
clear
();
...
...
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