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
655b3f6f
Commit
655b3f6f
authored
Mar 21, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix leak with weak ptr after latest optimization
parent
3a24d16d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
libcaf_core/caf/actor_proxy.hpp
libcaf_core/caf/actor_proxy.hpp
+1
-1
libcaf_core/src/actor_proxy.cpp
libcaf_core/src/actor_proxy.cpp
+8
-3
No files found.
libcaf_core/caf/actor_proxy.hpp
View file @
655b3f6f
...
@@ -71,7 +71,7 @@ class actor_proxy : public abstract_actor {
...
@@ -71,7 +71,7 @@ class actor_proxy : public abstract_actor {
* Tries to expire this anchor. Fails if reference
* Tries to expire this anchor. Fails if reference
* count of the proxy is nonzero.
* count of the proxy is nonzero.
*/
*/
bool
try_expire
(
size_t
)
noexcept
;
bool
try_expire
()
noexcept
;
std
::
atomic
<
actor_proxy
*>
m_ptr
;
std
::
atomic
<
actor_proxy
*>
m_ptr
;
detail
::
shared_spinlock
m_lock
;
detail
::
shared_spinlock
m_lock
;
};
};
...
...
libcaf_core/src/actor_proxy.cpp
View file @
655b3f6f
...
@@ -55,10 +55,10 @@ actor_proxy_ptr actor_proxy::anchor::get() {
...
@@ -55,10 +55,10 @@ actor_proxy_ptr actor_proxy::anchor::get() {
return
result
;
return
result
;
}
}
bool
actor_proxy
::
anchor
::
try_expire
(
size_t
expected_rc
)
noexcept
{
bool
actor_proxy
::
anchor
::
try_expire
()
noexcept
{
std
::
lock_guard
<
detail
::
shared_spinlock
>
guard
{
m_lock
};
std
::
lock_guard
<
detail
::
shared_spinlock
>
guard
{
m_lock
};
// double-check reference count
// double-check reference count
if
(
m_ptr
.
load
()
->
get_reference_count
()
==
expected_rc
)
{
if
(
m_ptr
.
load
()
->
get_reference_count
()
==
0
)
{
m_ptr
=
nullptr
;
m_ptr
=
nullptr
;
return
true
;
return
true
;
}
}
...
@@ -76,7 +76,12 @@ actor_proxy::actor_proxy(actor_id aid, node_id nid)
...
@@ -76,7 +76,12 @@ actor_proxy::actor_proxy(actor_id aid, node_id nid)
}
}
void
actor_proxy
::
request_deletion
(
bool
decremented_rc
)
noexcept
{
void
actor_proxy
::
request_deletion
(
bool
decremented_rc
)
noexcept
{
if
(
m_anchor
->
try_expire
(
decremented_rc
?
0
:
1
))
{
// make sure ref count is 0 because try_expire might leak otherwise
if
(
!
decremented_rc
&&
m_rc
.
fetch_sub
(
1
,
std
::
memory_order_acq_rel
)
!=
1
)
{
// deletion request canceled due to a weak ptr access
return
;
}
if
(
m_anchor
->
try_expire
())
{
delete
this
;
delete
this
;
}
}
}
}
...
...
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