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
5da4203c
Commit
5da4203c
authored
May 19, 2015
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix memory leak in the asio based multiplexer
parent
b23f2def
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
9 deletions
+8
-9
libcaf_io/caf/io/network/multiplexer.hpp
libcaf_io/caf/io/network/multiplexer.hpp
+4
-3
libcaf_io/src/asio_multiplexer.cpp
libcaf_io/src/asio_multiplexer.cpp
+1
-3
libcaf_io/src/default_multiplexer.cpp
libcaf_io/src/default_multiplexer.cpp
+3
-3
No files found.
libcaf_io/caf/io/network/multiplexer.hpp
View file @
5da4203c
...
@@ -116,13 +116,13 @@ class multiplexer {
...
@@ -116,13 +116,13 @@ class multiplexer {
/**
/**
* Simple wrapper for runnables
* Simple wrapper for runnables
*/
*/
struct
runnable
:
memory_manag
ed
{
struct
runnable
:
ref_count
ed
{
static
constexpr
auto
memory_cache_flag
=
detail
::
needs_embedding
;
static
constexpr
auto
memory_cache_flag
=
detail
::
needs_embedding
;
virtual
void
run
()
=
0
;
virtual
void
run
()
=
0
;
virtual
~
runnable
();
virtual
~
runnable
();
};
};
using
runnable_ptr
=
std
::
unique_ptr
<
runnable
,
detail
::
disposer
>
;
using
runnable_ptr
=
intrusive_ptr
<
runnable
>
;
/**
/**
* Makes sure the multipler does not exit its event loop until
* Makes sure the multipler does not exit its event loop until
...
@@ -176,7 +176,8 @@ class multiplexer {
...
@@ -176,7 +176,8 @@ class multiplexer {
f
();
f
();
}
}
};
};
dispatch_runnable
(
runnable_ptr
{
detail
::
memory
::
create
<
impl
>
(
std
::
move
(
fun
))});
dispatch_runnable
(
runnable_ptr
{
detail
::
memory
::
create
<
impl
>
(
std
::
move
(
fun
)),
false
});
}
}
/**
/**
...
...
libcaf_io/src/asio_multiplexer.cpp
View file @
5da4203c
...
@@ -266,10 +266,8 @@ asio_multiplexer::add_tcp_doorman(broker* self, uint16_t port, const char* in,
...
@@ -266,10 +266,8 @@ asio_multiplexer::add_tcp_doorman(broker* self, uint16_t port, const char* in,
}
}
void
asio_multiplexer
::
dispatch_runnable
(
runnable_ptr
ptr
)
{
void
asio_multiplexer
::
dispatch_runnable
(
runnable_ptr
ptr
)
{
auto
r
=
ptr
.
release
();
backend
().
post
([
=
]()
{
backend
().
post
([
=
]()
{
r
->
run
();
ptr
->
run
();
r
->
request_deletion
(
false
);
});
});
}
}
...
...
libcaf_io/src/default_multiplexer.cpp
View file @
5da4203c
...
@@ -592,7 +592,7 @@ void default_multiplexer::wr_dispatch_request(runnable* ptr) {
...
@@ -592,7 +592,7 @@ void default_multiplexer::wr_dispatch_request(runnable* ptr) {
# endif
# endif
if
(
res
<=
0
)
{
if
(
res
<=
0
)
{
// pipe closed, discard runnable
// pipe closed, discard runnable
ptr
->
request_deletion
(
false
);
ptr
->
deref
(
);
}
else
if
(
static_cast
<
size_t
>
(
res
)
<
sizeof
(
ptrval
))
{
}
else
if
(
static_cast
<
size_t
>
(
res
)
<
sizeof
(
ptrval
))
{
// must not happen: wrote invalid pointer to pipe
// must not happen: wrote invalid pointer to pipe
std
::
cerr
<<
"[CAF] Fatal error: wrote invalid data to pipe"
<<
std
::
endl
;
std
::
cerr
<<
"[CAF] Fatal error: wrote invalid data to pipe"
<<
std
::
endl
;
...
@@ -666,7 +666,7 @@ void default_multiplexer::handle_socket_event(native_socket fd, int mask,
...
@@ -666,7 +666,7 @@ void default_multiplexer::handle_socket_event(native_socket fd, int mask,
CAF_LOG_DEBUG
(
"read message from pipe"
);
CAF_LOG_DEBUG
(
"read message from pipe"
);
auto
cb
=
rd_dispatch_request
();
auto
cb
=
rd_dispatch_request
();
cb
->
run
();
cb
->
run
();
cb
->
request_deletion
(
false
);
cb
->
deref
(
);
}
}
}
}
if
(
mask
&
output_mask
)
{
if
(
mask
&
output_mask
)
{
...
@@ -713,7 +713,7 @@ default_multiplexer::~default_multiplexer() {
...
@@ -713,7 +713,7 @@ default_multiplexer::~default_multiplexer() {
nonblocking
(
m_pipe
.
first
,
true
);
nonblocking
(
m_pipe
.
first
,
true
);
auto
ptr
=
rd_dispatch_request
();
auto
ptr
=
rd_dispatch_request
();
while
(
ptr
)
{
while
(
ptr
)
{
ptr
->
request_deletion
(
false
);
ptr
->
deref
(
);
ptr
=
rd_dispatch_request
();
ptr
=
rd_dispatch_request
();
}
}
closesocket
(
m_pipe
.
first
);
closesocket
(
m_pipe
.
first
);
...
...
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