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
92f040cc
Commit
92f040cc
authored
Feb 20, 2017
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix leak in stream serv and its test
parent
9b98f73d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
13 deletions
+27
-13
libcaf_core/test/stream_multiplexing.cpp
libcaf_core/test/stream_multiplexing.cpp
+12
-5
libcaf_io/src/middleman.cpp
libcaf_io/src/middleman.cpp
+15
-8
No files found.
libcaf_core/test/stream_multiplexing.cpp
View file @
92f040cc
...
...
@@ -54,22 +54,22 @@ void streamer_impl(event_based_actor* self, const actor& dest) {
// destination of the stream
dest
,
// initialize state
[
&
](
buf
&
xs
)
{
[](
buf
&
xs
)
{
xs
=
buf
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
};
},
// get next element
[
=
](
buf
&
xs
,
downstream
<
int
>&
out
,
size_t
num
)
{
[](
buf
&
xs
,
downstream
<
int
>&
out
,
size_t
num
)
{
auto
n
=
std
::
min
(
num
,
xs
.
size
());
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
out
.
push
(
xs
[
i
]);
xs
.
erase
(
xs
.
begin
(),
xs
.
begin
()
+
static_cast
<
ptrdiff_t
>
(
n
));
},
// check whether we reached the end
[
=
](
const
buf
&
xs
)
{
[](
const
buf
&
xs
)
{
return
xs
.
empty
();
},
// handle result of the stream
[
=
](
expected
<
int
>
)
{
[](
expected
<
int
>
)
{
// nop
}
);
...
...
@@ -146,6 +146,13 @@ public:
};
}
void
on_exit
()
override
{
CAF_CHECK_EQUAL
(
incoming_
.
num_streams
(),
0u
);
CAF_CHECK_EQUAL
(
outgoing_
.
num_streams
(),
0u
);
CAF_CHECK
(
streams
().
empty
());
remotes
().
empty
();
}
strong_actor_ptr
remote_stream_serv
(
const
node_id
&
nid
)
override
;
private:
...
...
@@ -157,7 +164,7 @@ private:
// Simulates a regular forwarding_actor_proxy by pushing a handle to the
// original to the forwarding stack and redirecting each message to the
// stream_serv.
class
pseudo_proxy
:
public
raw_event_based_actor
{
class
pseudo_proxy
:
public
raw_event_based_actor
{
public:
pseudo_proxy
(
actor_config
&
cfg
,
actor
stream_serv
,
actor
original
)
:
raw_event_based_actor
(
cfg
),
...
...
libcaf_io/src/middleman.cpp
View file @
92f040cc
...
...
@@ -255,14 +255,14 @@ strong_actor_ptr middleman::remote_lookup(atom_value name, const node_id& nid) {
void
middleman
::
start
()
{
CAF_LOG_TRACE
(
""
);
//
create hooks
//
Create hooks.
for
(
auto
&
f
:
system
().
config
().
hook_factories
)
hooks_
.
emplace_back
(
f
(
system_
));
//
launch backend
//
Launch backend.
backend_supervisor_
=
backend
().
make_supervisor
();
if
(
!
backend_supervisor_
)
{
//
t
he only backend that returns a `nullptr` is the `test_multiplexer`
// which does not have its own thread but uses the main thread instead
//
T
he only backend that returns a `nullptr` is the `test_multiplexer`
// which does not have its own thread but uses the main thread instead
.
backend
().
thread_id
(
std
::
this_thread
::
get_id
());
}
else
{
thread_
=
std
::
thread
{[
this
]
{
...
...
@@ -272,9 +272,7 @@ void middleman::start() {
}};
backend
().
thread_id
(
thread_
.
get_id
());
}
auto
basp
=
named_broker
<
basp_broker
>
(
atom
(
"BASP"
));
manager_
=
make_middleman_actor
(
system
(),
basp
);
// Install stream serv into the actor system.
// Default implementation of the stream server.
class
stream_serv
:
public
raw_event_based_actor
,
public
detail
::
stream_multiplexer
::
backend
{
public:
...
...
@@ -354,11 +352,20 @@ void middleman::start() {
return
result
;
}
void
on_exit
()
override
{
// Make sure to not keep references to remotes after shutdown.
remotes
().
clear
();
}
private:
detail
::
incoming_stream_multiplexer
incoming_
;
detail
::
outgoing_stream_multiplexer
outgoing_
;
};
auto
ssi
=
system
().
spawn
<
stream_serv
,
lazy_init
+
hidden
>
(
actor_cast
<
actor
>
(
basp
));
// Spawn utility actors.
auto
basp
=
named_broker
<
basp_broker
>
(
atom
(
"BASP"
));
manager_
=
make_middleman_actor
(
system
(),
basp
);
auto
hdl
=
actor_cast
<
actor
>
(
basp
);
auto
ssi
=
system
().
spawn
<
stream_serv
,
lazy_init
+
hidden
>
(
std
::
move
(
hdl
));
system
().
stream_serv
(
actor_cast
<
strong_actor_ptr
>
(
std
::
move
(
ssi
)));
}
...
...
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