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
9ed4db36
Commit
9ed4db36
authored
Jun 17, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix possible race in test multiplexer
parent
ab865a9c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
8 deletions
+11
-8
libcaf_io/caf/io/network/test_multiplexer.hpp
libcaf_io/caf/io/network/test_multiplexer.hpp
+2
-1
libcaf_io/src/test_multiplexer.cpp
libcaf_io/src/test_multiplexer.cpp
+5
-2
libcaf_io/test/basp.cpp
libcaf_io/test/basp.cpp
+4
-5
No files found.
libcaf_io/caf/io/network/test_multiplexer.hpp
View file @
9ed4db36
...
...
@@ -109,7 +109,7 @@ public:
using
pending_scribes_map
=
std
::
map
<
std
::
pair
<
std
::
string
,
uint16_t
>
,
connection_handle
>
;
pending_scribes_map
&
pending_scribes
(
);
bool
has_pending_scribe
(
std
::
string
host
,
uint16_t
port
);
/// Accepts a pending connect on `hdl`.
void
accept_connection
(
accept_handle
hdl
);
...
...
@@ -157,6 +157,7 @@ private:
intrusive_ptr
<
doorman
>
ptr
;
};
// guards resumables_ and scribes_
std
::
mutex
mx_
;
std
::
condition_variable
cv_
;
std
::
list
<
resumable_ptr
>
resumables_
;
...
...
libcaf_io/src/test_multiplexer.cpp
View file @
9ed4db36
...
...
@@ -40,6 +40,7 @@ test_multiplexer::~test_multiplexer() {
connection_handle
test_multiplexer
::
new_tcp_scribe
(
const
std
::
string
&
host
,
uint16_t
port_hint
)
{
guard_type
guard
{
mx_
};
connection_handle
result
;
auto
i
=
scribes_
.
find
(
std
::
make_pair
(
host
,
port_hint
));
if
(
i
!=
scribes_
.
end
())
{
...
...
@@ -199,6 +200,7 @@ void test_multiplexer::run() {
void
test_multiplexer
::
provide_scribe
(
std
::
string
host
,
uint16_t
desired_port
,
connection_handle
hdl
)
{
guard_type
guard
{
mx_
};
scribes_
.
emplace
(
std
::
make_pair
(
std
::
move
(
host
),
desired_port
),
hdl
);
}
...
...
@@ -262,8 +264,9 @@ test_multiplexer::pending_connects_map& test_multiplexer::pending_connects() {
return
pending_connects_
;
}
test_multiplexer
::
pending_scribes_map
&
test_multiplexer
::
pending_scribes
()
{
return
scribes_
;
bool
test_multiplexer
::
has_pending_scribe
(
std
::
string
x
,
uint16_t
y
)
{
guard_type
guard
{
mx_
};
return
scribes_
.
count
(
std
::
make_pair
(
std
::
move
(
x
),
y
))
>
0
;
}
void
test_multiplexer
::
accept_connection
(
accept_handle
hdl
)
{
...
...
libcaf_io/test/basp.cpp
View file @
9ed4db36
...
...
@@ -579,7 +579,7 @@ CAF_TEST(remote_actor_and_send) {
constexpr
const
char
*
lo
=
"localhost"
;
CAF_MESSAGE
(
"self: "
<<
to_string
(
self
()
->
address
()));
mpx
()
->
provide_scribe
(
lo
,
4242
,
remote_hdl
(
0
));
CAF_REQUIRE
(
mpx
()
->
pending_scribes
().
count
(
make_pair
(
lo
,
4242
))
==
1
);
CAF_REQUIRE
(
mpx
()
->
has_pending_scribe
(
lo
,
4242
)
);
auto
mm1
=
system
.
middleman
().
actor_handle
();
actor
result
{
unsafe_actor_handle_init
};
auto
f
=
self
()
->
request
(
mm1
,
infinite
,
...
...
@@ -587,7 +587,7 @@ CAF_TEST(remote_actor_and_send) {
// wait until BASP broker has received and processed the connect message
while
(
!
aut
()
->
valid
(
remote_hdl
(
0
)))
mpx
()
->
exec_runnable
();
CAF_REQUIRE
(
mpx
()
->
pending_scribes
().
count
(
make_pair
(
lo
,
4242
))
==
0
);
CAF_REQUIRE
(
!
mpx
()
->
has_pending_scribe
(
lo
,
4242
)
);
// build a fake server handshake containing the id of our first pseudo actor
CAF_MESSAGE
(
"server handshake => client handshake + proxy announcement"
);
auto
na
=
registry
()
->
named_actors
();
...
...
@@ -760,8 +760,7 @@ CAF_TEST(automatic_connection) {
// (this node receives a message from jupiter via mars and responds via mars,
// but then also establishes a connection to jupiter directly)
mpx
()
->
provide_scribe
(
"jupiter"
,
8080
,
remote_hdl
(
0
));
CAF_CHECK_EQUAL
(
mpx
()
->
pending_scribes
().
count
(
make_pair
(
"jupiter"
,
8080
)),
1u
);
CAF_CHECK
(
mpx
()
->
has_pending_scribe
(
"jupiter"
,
8080
));
CAF_MESSAGE
(
"self: "
<<
to_string
(
self
()
->
address
()));
auto
ax
=
accept_handle
::
from_int
(
4242
);
mpx
()
->
provide_acceptor
(
4242
,
ax
);
...
...
@@ -816,7 +815,7 @@ CAF_TEST(automatic_connection) {
make_message
(
uint16_t
{
8080
},
std
::
move
(
res
))));
// our connection helper should now connect to jupiter and
// send the scribe handle over to the BASP broker
while
(
mpx
()
->
pending_scribes
().
count
(
make_pair
(
"jupiter"
,
8080
))
!=
0
)
while
(
mpx
()
->
has_pending_scribe
(
"jupiter"
,
8080
)
)
mpx
()
->
flush_runnables
();
CAF_REQUIRE
(
mpx
()
->
output_buffer
(
remote_hdl
(
1
)).
size
()
==
0
);
// send handshake from jupiter
...
...
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