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
ca325fea
Commit
ca325fea
authored
Jun 16, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
cabb2d83
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
81 additions
and
75 deletions
+81
-75
libcaf_core/caf/actor_system_config.hpp
libcaf_core/caf/actor_system_config.hpp
+0
-5
libcaf_core/caf/defaults.hpp
libcaf_core/caf/defaults.hpp
+0
-3
libcaf_core/caf/proxy_registry.hpp
libcaf_core/caf/proxy_registry.hpp
+6
-0
libcaf_core/src/actor_system_config.cpp
libcaf_core/src/actor_system_config.cpp
+9
-16
libcaf_core/src/defaults.cpp
libcaf_core/src/defaults.cpp
+0
-5
libcaf_core/test/typed_spawn.cpp
libcaf_core/test/typed_spawn.cpp
+4
-4
libcaf_io/caf/io/basp/instance.hpp
libcaf_io/caf/io/basp/instance.hpp
+6
-0
libcaf_io/caf/io/basp_broker.hpp
libcaf_io/caf/io/basp_broker.hpp
+9
-6
libcaf_io/caf/io/middleman.hpp
libcaf_io/caf/io/middleman.hpp
+5
-0
libcaf_io/src/basp_broker.cpp
libcaf_io/src/basp_broker.cpp
+15
-15
libcaf_io/src/connection_helper.cpp
libcaf_io/src/connection_helper.cpp
+5
-5
libcaf_io/src/middleman.cpp
libcaf_io/src/middleman.cpp
+4
-4
libcaf_io/src/middleman_actor.cpp
libcaf_io/src/middleman_actor.cpp
+3
-3
libcaf_io/src/middleman_actor_impl.cpp
libcaf_io/src/middleman_actor_impl.cpp
+11
-5
libcaf_io/test/basp.cpp
libcaf_io/test/basp.cpp
+1
-1
libcaf_io/test/basp_udp.cpp
libcaf_io/test/basp_udp.cpp
+3
-3
No files found.
libcaf_core/caf/actor_system_config.hpp
View file @
ca325fea
...
@@ -356,13 +356,8 @@ public:
...
@@ -356,13 +356,8 @@ public:
atom_value
middleman_network_backend
;
atom_value
middleman_network_backend
;
std
::
string
middleman_app_identifier
;
std
::
string
middleman_app_identifier
;
bool
middleman_enable_automatic_connections
;
size_t
middleman_max_consecutive_reads
;
size_t
middleman_max_consecutive_reads
;
size_t
middleman_heartbeat_interval
;
size_t
middleman_heartbeat_interval
;
bool
middleman_detach_utility_actors
;
bool
middleman_detach_multiplexer
;
bool
middleman_enable_tcp
;
bool
middleman_enable_udp
;
size_t
middleman_cached_udp_buffers
;
size_t
middleman_cached_udp_buffers
;
size_t
middleman_max_pending_msgs
;
size_t
middleman_max_pending_msgs
;
...
...
libcaf_core/caf/defaults.hpp
View file @
ca325fea
...
@@ -73,13 +73,10 @@ extern const bool inline_output;
...
@@ -73,13 +73,10 @@ extern const bool inline_output;
namespace
middleman
{
namespace
middleman
{
extern
const
atom_value
network_backend
;
extern
const
atom_value
network_backend
;
extern
const
bool
enable_automatic_connections
;
extern
const
size_t
max_consecutive_reads
;
extern
const
size_t
max_consecutive_reads
;
extern
const
size_t
heartbeat_interval
;
extern
const
size_t
heartbeat_interval
;
extern
const
bool
detach_utility_actors
;
extern
const
bool
detach_utility_actors
;
extern
const
bool
detach_multiplexer
;
extern
const
bool
detach_multiplexer
;
extern
const
bool
enable_tcp
;
extern
const
bool
enable_udp
;
extern
const
size_t
cached_udp_buffers
;
extern
const
size_t
cached_udp_buffers
;
extern
const
size_t
max_pending_msgs
;
extern
const
size_t
max_pending_msgs
;
...
...
libcaf_core/caf/proxy_registry.hpp
View file @
ca325fea
...
@@ -94,10 +94,16 @@ public:
...
@@ -94,10 +94,16 @@ public:
/// Deletes all proxies.
/// Deletes all proxies.
void
clear
();
void
clear
();
/// Returns the hosting actor system.
inline
actor_system
&
system
()
{
inline
actor_system
&
system
()
{
return
system_
;
return
system_
;
}
}
/// Returns the hosting actor system.
inline
const
actor_system
&
system
()
const
{
return
system_
;
}
inline
size_t
size
()
const
{
inline
size_t
size
()
const
{
return
proxies_
.
size
();
return
proxies_
.
size
();
}
}
...
...
libcaf_core/src/actor_system_config.cpp
View file @
ca325fea
...
@@ -84,13 +84,8 @@ actor_system_config::actor_system_config()
...
@@ -84,13 +84,8 @@ actor_system_config::actor_system_config()
logger_verbosity
=
atom
(
"trace"
);
logger_verbosity
=
atom
(
"trace"
);
logger_inline_output
=
false
;
logger_inline_output
=
false
;
middleman_network_backend
=
atom
(
"default"
);
middleman_network_backend
=
atom
(
"default"
);
middleman_enable_automatic_connections
=
false
;
middleman_max_consecutive_reads
=
50
;
middleman_max_consecutive_reads
=
50
;
middleman_heartbeat_interval
=
0
;
middleman_heartbeat_interval
=
0
;
middleman_detach_utility_actors
=
true
;
middleman_detach_multiplexer
=
true
;
middleman_enable_tcp
=
true
;
middleman_enable_udp
=
false
;
middleman_cached_udp_buffers
=
10
;
middleman_cached_udp_buffers
=
10
;
middleman_max_pending_msgs
=
10
;
middleman_max_pending_msgs
=
10
;
// fill our options vector for creating INI and CLI parsers
// fill our options vector for creating INI and CLI parsers
...
@@ -154,24 +149,22 @@ actor_system_config::actor_system_config()
...
@@ -154,24 +149,22 @@ actor_system_config::actor_system_config()
.
add
(
logger_component_filter
,
"filter"
,
.
add
(
logger_component_filter
,
"filter"
,
"deprecated (use console-component-filter instead)"
);
"deprecated (use console-component-filter instead)"
);
opt_group
{
custom_options_
,
"middleman"
}
opt_group
{
custom_options_
,
"middleman"
}
.
add
<
bool
>
(
"enable-automatic-connections"
,
"enables automatic connection management"
)
.
add
<
bool
>
(
"attach-utility-actors"
,
"schedule utility actors instead of dedicating individual threads"
)
.
add
<
bool
>
(
"manual-multiplexing"
,
"disables background activity of the multiplexer"
)
.
add
<
bool
>
(
"disable-tcp"
,
"disables communication via TCP"
)
.
add
<
bool
>
(
"enable-udp"
,
"enable communication via UDP"
)
.
add
(
middleman_network_backend
,
"network-backend"
,
.
add
(
middleman_network_backend
,
"network-backend"
,
"sets the network backend to either 'default' or 'asio' (if available)"
)
"sets the network backend to either 'default' or 'asio' (if available)"
)
.
add
(
middleman_app_identifier
,
"app-identifier"
,
.
add
(
middleman_app_identifier
,
"app-identifier"
,
"sets the application identifier of this node"
)
"sets the application identifier of this node"
)
.
add
(
middleman_enable_automatic_connections
,
"enable-automatic-connections"
,
"enables or disables automatic connection management (off per default)"
)
.
add
(
middleman_max_consecutive_reads
,
"max-consecutive-reads"
,
.
add
(
middleman_max_consecutive_reads
,
"max-consecutive-reads"
,
"sets the maximum number of consecutive I/O reads per broker"
)
"sets the maximum number of consecutive I/O reads per broker"
)
.
add
(
middleman_heartbeat_interval
,
"heartbeat-interval"
,
.
add
(
middleman_heartbeat_interval
,
"heartbeat-interval"
,
"sets the interval (ms) of heartbeat, 0 (default) means disabling it"
)
"sets the interval (ms) of heartbeat, 0 (default) means disabling it"
)
.
add
(
middleman_detach_utility_actors
,
"detach-utility-actors"
,
"enables or disables detaching of utility actors"
)
.
add
(
middleman_detach_multiplexer
,
"detach-multiplexer"
,
"enables or disables background activity of the multiplexer"
)
.
add
(
middleman_enable_tcp
,
"enable-tcp"
,
"enable communication via TCP (on by default)"
)
.
add
(
middleman_enable_udp
,
"enable-udp"
,
"enable communication via UDP (off by default)"
)
.
add
(
middleman_cached_udp_buffers
,
"cached-udp-buffers"
,
.
add
(
middleman_cached_udp_buffers
,
"cached-udp-buffers"
,
"sets the max number of UDP send buffers that will be cached for reuse "
"sets the max number of UDP send buffers that will be cached for reuse "
"(default: 10)"
)
"(default: 10)"
)
...
@@ -377,7 +370,7 @@ actor_system_config& actor_system_config::set_impl(const char* name,
...
@@ -377,7 +370,7 @@ actor_system_config& actor_system_config::set_impl(const char* name,
auto
opt
=
custom_options_
.
qualified_name_lookup
(
name
);
auto
opt
=
custom_options_
.
qualified_name_lookup
(
name
);
if
(
opt
!=
nullptr
&&
opt
->
check
(
value
)
==
none
)
{
if
(
opt
!=
nullptr
&&
opt
->
check
(
value
)
==
none
)
{
opt
->
store
(
value
);
opt
->
store
(
value
);
content
[
opt
->
category
()][
name
]
=
std
::
move
(
value
);
content
[
opt
->
category
()][
opt
->
long_name
()
]
=
std
::
move
(
value
);
}
}
return
*
this
;
return
*
this
;
}
}
...
...
libcaf_core/src/defaults.cpp
View file @
ca325fea
...
@@ -85,13 +85,8 @@ const bool inline_output = false;
...
@@ -85,13 +85,8 @@ const bool inline_output = false;
namespace
middleman
{
namespace
middleman
{
const
atom_value
network_backend
=
atom
(
"default"
);
const
atom_value
network_backend
=
atom
(
"default"
);
const
bool
enable_automatic_connections
=
false
;
const
size_t
max_consecutive_reads
=
50
;
const
size_t
max_consecutive_reads
=
50
;
const
size_t
heartbeat_interval
=
0
;
const
size_t
heartbeat_interval
=
0
;
const
bool
detach_utility_actors
=
true
;
const
bool
detach_multiplexer
=
true
;
const
bool
enable_tcp
=
true
;
const
bool
enable_udp
=
false
;
const
size_t
cached_udp_buffers
=
10
;
const
size_t
cached_udp_buffers
=
10
;
const
size_t
max_pending_msgs
=
10
;
const
size_t
max_pending_msgs
=
10
;
...
...
libcaf_core/test/typed_spawn.cpp
View file @
ca325fea
...
@@ -410,10 +410,10 @@ CAF_TEST(event_testee_series) {
...
@@ -410,10 +410,10 @@ CAF_TEST(event_testee_series) {
self
->
send
(
et
,
"hello again event testee!"
);
self
->
send
(
et
,
"hello again event testee!"
);
self
->
send
(
et
,
"goodbye event testee!"
);
self
->
send
(
et
,
"goodbye event testee!"
);
typed_actor
<
replies_to
<
get_state_msg
>::
with
<
string
>>
sub_et
=
et
;
typed_actor
<
replies_to
<
get_state_msg
>::
with
<
string
>>
sub_et
=
et
;
set
<
string
>
iface
{
"caf::replies_to<get_state_msg>::with<@str>"
,
s
td
::
s
et
<
string
>
iface
{
"caf::replies_to<get_state_msg>::with<@str>"
,
"caf::replies_to<@str>::with<void>"
,
"caf::replies_to<@str>::with<void>"
,
"caf::replies_to<float>::with<void>"
,
"caf::replies_to<float>::with<void>"
,
"caf::replies_to<@i32>::with<@i32>"
};
"caf::replies_to<@i32>::with<@i32>"
};
CAF_CHECK_EQUAL
(
join
(
sub_et
->
message_types
(),
","
),
join
(
iface
,
","
));
CAF_CHECK_EQUAL
(
join
(
sub_et
->
message_types
(),
","
),
join
(
iface
,
","
));
self
->
send
(
sub_et
,
get_state_msg
{});
self
->
send
(
sub_et
,
get_state_msg
{});
// we expect three 42s
// we expect three 42s
...
...
libcaf_io/caf/io/basp/instance.hpp
View file @
ca325fea
...
@@ -99,10 +99,16 @@ public:
...
@@ -99,10 +99,16 @@ public:
return
namespace_
;
return
namespace_
;
}
}
/// Returns the hosting actor system.
inline
actor_system
&
system
()
{
inline
actor_system
&
system
()
{
return
namespace_
.
system
();
return
namespace_
.
system
();
}
}
/// Returns the system-wide configuration.
inline
const
actor_system_config
&
config
()
const
{
return
namespace_
.
system
().
config
();
}
/// Returns the next outgoing sequence number for a connection.
/// Returns the next outgoing sequence number for a connection.
virtual
sequence_type
next_sequence_number
(
connection_handle
hdl
)
=
0
;
virtual
sequence_type
next_sequence_number
(
connection_handle
hdl
)
=
0
;
...
...
libcaf_io/caf/io/basp_broker.hpp
View file @
ca325fea
...
@@ -163,12 +163,15 @@ struct basp_broker_state : proxy_registry::backend, basp::instance::callee {
...
@@ -163,12 +163,15 @@ struct basp_broker_state : proxy_registry::backend, basp::instance::callee {
// get a 'SpawnServ' instance on the remote side
// get a 'SpawnServ' instance on the remote side
std
::
unordered_map
<
node_id
,
actor
>
spawn_servers
;
std
::
unordered_map
<
node_id
,
actor
>
spawn_servers
;
// can be enabled by the user to let CAF automatically try
/// Configures whether BASP automatically open new connections to optimize
// to establish new connections at runtime to optimize
/// routing paths by forming a mesh between all nodes.
// routing paths by forming a mesh between all nodes
bool
automatic_connections
=
false
;
bool
enable_automatic_connections
=
false
;
bool
enable_tcp
=
true
;
/// Configures whether BASP allows TCP connections.
bool
enable_udp
=
false
;
bool
allow_tcp
=
true
;
/// Configures whether BASP allows UDP connections.
bool
allow_udp
=
false
;
// reusable send buffers for UDP communication
// reusable send buffers for UDP communication
const
size_t
max_buffers
;
const
size_t
max_buffers
;
...
...
libcaf_io/caf/io/middleman.hpp
View file @
ca325fea
...
@@ -156,6 +156,11 @@ public:
...
@@ -156,6 +156,11 @@ public:
return
system_
;
return
system_
;
}
}
/// Returns the systemw-wide configuration.
inline
const
actor_system_config
&
config
()
const
{
return
system_
.
config
();
}
/// Returns a handle to the actor managing the middleman singleton.
/// Returns a handle to the actor managing the middleman singleton.
middleman_actor
actor_handle
();
middleman_actor
actor_handle
();
...
...
libcaf_io/src/basp_broker.cpp
View file @
ca325fea
...
@@ -77,8 +77,8 @@ basp_broker_state::basp_broker_state(broker* selfptr)
...
@@ -77,8 +77,8 @@ basp_broker_state::basp_broker_state(broker* selfptr)
static_cast
<
proxy_registry
::
backend
&>
(
*
this
)),
static_cast
<
proxy_registry
::
backend
&>
(
*
this
)),
self
(
selfptr
),
self
(
selfptr
),
instance
(
selfptr
,
*
this
),
instance
(
selfptr
,
*
this
),
max_buffers
(
self
->
system
().
config
().
middleman_cached_udp_buffers
),
max_buffers
(
self
->
config
().
middleman_cached_udp_buffers
),
max_pending_messages
(
self
->
system
().
config
().
middleman_max_pending_msgs
)
{
max_pending_messages
(
self
->
config
().
middleman_max_pending_msgs
)
{
CAF_ASSERT
(
this_node
()
!=
none
);
CAF_ASSERT
(
this_node
()
!=
none
);
}
}
...
@@ -395,7 +395,7 @@ void basp_broker_state::learned_new_node_indirectly(const node_id& nid) {
...
@@ -395,7 +395,7 @@ void basp_broker_state::learned_new_node_indirectly(const node_id& nid) {
CAF_ASSERT
(
this_context
!=
nullptr
);
CAF_ASSERT
(
this_context
!=
nullptr
);
CAF_LOG_TRACE
(
CAF_ARG
(
nid
));
CAF_LOG_TRACE
(
CAF_ARG
(
nid
));
learned_new_node
(
nid
);
learned_new_node
(
nid
);
if
(
!
enable_
automatic_connections
)
if
(
!
automatic_connections
)
return
;
return
;
// this member function gets only called once, after adding a new
// this member function gets only called once, after adding a new
// indirect connection to the routing table; hence, spawning
// indirect connection to the routing table; hence, spawning
...
@@ -412,9 +412,9 @@ void basp_broker_state::learned_new_node_indirectly(const node_id& nid) {
...
@@ -412,9 +412,9 @@ void basp_broker_state::learned_new_node_indirectly(const node_id& nid) {
}
}
using
namespace
detail
;
using
namespace
detail
;
auto
try_connect
=
[
&
](
std
::
string
item
)
{
auto
try_connect
=
[
&
](
std
::
string
item
)
{
auto
tmp
=
system
().
config
().
middleman_detach_utility_actors
auto
tmp
=
get_or
(
config
(),
"middleman.attach-utility-actors"
,
false
)
?
system
().
spawn
<
detached
+
hidden
>
(
connection_helper
,
self
)
?
system
().
spawn
<
hidden
>
(
connection_helper
,
self
)
:
system
().
spawn
<
hidden
>
(
connection_helper
,
self
);
:
system
().
spawn
<
detached
+
hidden
>
(
connection_helper
,
self
);
system
().
registry
().
put
(
tmp
.
id
(),
actor_cast
<
strong_actor_ptr
>
(
tmp
));
system
().
registry
().
put
(
tmp
.
id
(),
actor_cast
<
strong_actor_ptr
>
(
tmp
));
auto
writer
=
make_callback
([
&
item
](
serializer
&
sink
)
->
error
{
auto
writer
=
make_callback
([
&
item
](
serializer
&
sink
)
->
error
{
auto
name_atm
=
atom
(
"ConfigServ"
);
auto
name_atm
=
atom
(
"ConfigServ"
);
...
@@ -430,9 +430,9 @@ void basp_broker_state::learned_new_node_indirectly(const node_id& nid) {
...
@@ -430,9 +430,9 @@ void basp_broker_state::learned_new_node_indirectly(const node_id& nid) {
hdr
,
&
writer
);
hdr
,
&
writer
);
instance
.
flush
(
*
path
);
instance
.
flush
(
*
path
);
};
};
if
(
enable
_tcp
)
if
(
allow
_tcp
)
try_connect
(
"basp.default-connectivity-tcp"
);
try_connect
(
"basp.default-connectivity-tcp"
);
if
(
enable
_udp
)
if
(
allow
_udp
)
try_connect
(
"basp.default-connectivity-udp"
);
try_connect
(
"basp.default-connectivity-udp"
);
}
}
...
@@ -640,13 +640,13 @@ basp_broker::basp_broker(actor_config& cfg)
...
@@ -640,13 +640,13 @@ basp_broker::basp_broker(actor_config& cfg)
behavior
basp_broker
::
make_behavior
()
{
behavior
basp_broker
::
make_behavior
()
{
CAF_LOG_TRACE
(
CAF_ARG
(
system
().
node
()));
CAF_LOG_TRACE
(
CAF_ARG
(
system
().
node
()));
state
.
enable_tcp
=
system
().
config
().
middleman_enable_tcp
;
state
.
allow_tcp
=
!
get_or
(
config
(),
"middleman.disable-tcp"
,
false
)
;
state
.
enable_udp
=
system
().
config
().
middleman_enable_udp
;
state
.
allow_udp
=
get_or
(
config
(),
"middleman.enable-udp"
,
false
)
;
if
(
system
().
config
().
middleman_enable_automatic_connections
)
{
if
(
get_or
(
config
(),
"middleman.enable-automatic-connections"
,
false
)
)
{
CAF_LOG_INFO
(
"enable automatic connections"
);
CAF_LOG_INFO
(
"enable automatic connections"
);
// open a random port and store a record for our peers how to
// open a random port and store a record for our peers how to
// connect to this broker directly in the configuration server
// connect to this broker directly in the configuration server
if
(
state
.
enable
_tcp
)
{
if
(
state
.
allow
_tcp
)
{
auto
res
=
add_tcp_doorman
(
uint16_t
{
0
});
auto
res
=
add_tcp_doorman
(
uint16_t
{
0
});
if
(
res
)
{
if
(
res
)
{
auto
port
=
res
->
second
;
auto
port
=
res
->
second
;
...
@@ -657,7 +657,7 @@ behavior basp_broker::make_behavior() {
...
@@ -657,7 +657,7 @@ behavior basp_broker::make_behavior() {
make_message
(
port
,
std
::
move
(
addrs
)));
make_message
(
port
,
std
::
move
(
addrs
)));
}
}
}
}
if
(
state
.
enable
_udp
)
{
if
(
state
.
allow
_udp
)
{
auto
res
=
add_udp_datagram_servant
(
uint16_t
{
0
});
auto
res
=
add_udp_datagram_servant
(
uint16_t
{
0
});
if
(
res
)
{
if
(
res
)
{
auto
port
=
res
->
second
;
auto
port
=
res
->
second
;
...
@@ -668,9 +668,9 @@ behavior basp_broker::make_behavior() {
...
@@ -668,9 +668,9 @@ behavior basp_broker::make_behavior() {
make_message
(
port
,
std
::
move
(
addrs
)));
make_message
(
port
,
std
::
move
(
addrs
)));
}
}
}
}
state
.
enable_
automatic_connections
=
true
;
state
.
automatic_connections
=
true
;
}
}
auto
heartbeat_interval
=
system
().
config
().
middleman_heartbeat_interval
;
auto
heartbeat_interval
=
config
().
middleman_heartbeat_interval
;
if
(
heartbeat_interval
>
0
)
{
if
(
heartbeat_interval
>
0
)
{
CAF_LOG_INFO
(
"enable heartbeat"
<<
CAF_ARG
(
heartbeat_interval
));
CAF_LOG_INFO
(
"enable heartbeat"
<<
CAF_ARG
(
heartbeat_interval
));
send
(
this
,
tick_atom
::
value
,
heartbeat_interval
);
send
(
this
,
tick_atom
::
value
,
heartbeat_interval
);
...
...
libcaf_io/src/connection_helper.cpp
View file @
ca325fea
...
@@ -99,16 +99,16 @@ behavior connection_helper(stateful_actor<connection_helper_state>* self,
...
@@ -99,16 +99,16 @@ behavior connection_helper(stateful_actor<connection_helper_state>* self,
}
}
CAF_LOG_INFO
(
"could not connect to node directly"
);
CAF_LOG_INFO
(
"could not connect to node directly"
);
}
else
if
(
item
==
"basp.default-connectivity-udp"
)
{
}
else
if
(
item
==
"basp.default-connectivity-udp"
)
{
auto
&
sys
=
self
->
system
();
// create new broker to try addresses for communication via UDP
// create new broker to try addresses for communication via UDP
if
(
self
->
system
().
config
().
middleman_detach_utility_actors
)
{
if
(
get_or
(
sys
.
config
(),
"middleman.attach-utility-actors"
,
false
))
self
->
system
().
middleman
().
spawn_broker
<
detached
+
hidden
>
(
self
->
system
().
middleman
().
spawn_broker
<
hidden
>
(
datagram_connection_broker
,
port
,
std
::
move
(
addresses
),
b
datagram_connection_broker
,
port
,
std
::
move
(
addresses
),
b
);
);
}
else
{
else
self
->
system
().
middleman
().
spawn_broker
<
hidden
>
(
self
->
system
().
middleman
().
spawn_broker
<
detached
+
hidden
>
(
datagram_connection_broker
,
port
,
std
::
move
(
addresses
),
b
datagram_connection_broker
,
port
,
std
::
move
(
addresses
),
b
);
);
}
}
else
{
}
else
{
CAF_LOG_INFO
(
"aborted direct connection attempt, unknown item: "
CAF_LOG_INFO
(
"aborted direct connection attempt, unknown item: "
<<
CAF_ARG
(
item
));
<<
CAF_ARG
(
item
));
...
...
libcaf_io/src/middleman.cpp
View file @
ca325fea
...
@@ -292,7 +292,7 @@ void middleman::start() {
...
@@ -292,7 +292,7 @@ void middleman::start() {
for
(
auto
&
f
:
system
().
config
().
hook_factories
)
for
(
auto
&
f
:
system
().
config
().
hook_factories
)
hooks_
.
emplace_back
(
f
(
system_
));
hooks_
.
emplace_back
(
f
(
system_
));
// Launch backend.
// Launch backend.
if
(
system_
.
config
().
middleman_detach_multiplexer
)
if
(
!
get_or
(
config
(),
"middleman.manual-multiplexing"
,
false
)
)
backend_supervisor_
=
backend
().
make_supervisor
();
backend_supervisor_
=
backend
().
make_supervisor
();
// The only backend that returns a `nullptr` by default is the
// The only backend that returns a `nullptr` by default is the
// `test_multiplexer` which does not have its own thread but uses the main
// `test_multiplexer` which does not have its own thread but uses the main
...
@@ -342,7 +342,7 @@ void middleman::stop() {
...
@@ -342,7 +342,7 @@ void middleman::stop() {
}
}
}
}
});
});
if
(
system_
.
config
().
middleman_detach_multiplexer
)
{
if
(
!
get_or
(
config
(),
"middleman.manual-multiplexing"
,
false
)
)
{
backend_supervisor_
.
reset
();
backend_supervisor_
.
reset
();
if
(
thread_
.
joinable
())
if
(
thread_
.
joinable
())
thread_
.
join
();
thread_
.
join
();
...
@@ -354,7 +354,7 @@ void middleman::stop() {
...
@@ -354,7 +354,7 @@ void middleman::stop() {
named_brokers_
.
clear
();
named_brokers_
.
clear
();
scoped_actor
self
{
system
(),
true
};
scoped_actor
self
{
system
(),
true
};
self
->
send_exit
(
manager_
,
exit_reason
::
kill
);
self
->
send_exit
(
manager_
,
exit_reason
::
kill
);
if
(
system
().
config
().
middleman_detach_utility_actors
)
if
(
!
get_or
(
config
(),
"middleman.attach-utility-actors"
,
false
)
)
self
->
wait_for
(
manager_
);
self
->
wait_for
(
manager_
);
destroy
(
manager_
);
destroy
(
manager_
);
}
}
...
@@ -362,7 +362,7 @@ void middleman::stop() {
...
@@ -362,7 +362,7 @@ void middleman::stop() {
void
middleman
::
init
(
actor_system_config
&
cfg
)
{
void
middleman
::
init
(
actor_system_config
&
cfg
)
{
// never detach actors when using the testing multiplexer
// never detach actors when using the testing multiplexer
if
(
cfg
.
middleman_network_backend
==
atom
(
"testing"
))
if
(
cfg
.
middleman_network_backend
==
atom
(
"testing"
))
cfg
.
middleman_detach_utility_actors
=
false
;
cfg
.
set
(
"middleman.attach-utility-actors"
,
true
)
;
// add remote group module to config
// add remote group module to config
struct
remote_groups
:
group_module
{
struct
remote_groups
:
group_module
{
public:
public:
...
...
libcaf_io/src/middleman_actor.cpp
View file @
ca325fea
...
@@ -32,9 +32,9 @@ namespace caf {
...
@@ -32,9 +32,9 @@ namespace caf {
namespace
io
{
namespace
io
{
middleman_actor
make_middleman_actor
(
actor_system
&
sys
,
actor
db
)
{
middleman_actor
make_middleman_actor
(
actor_system
&
sys
,
actor
db
)
{
return
sys
.
config
().
middleman_detach_utility_actors
return
get_or
(
sys
.
config
(),
"middleman.attach-utility-actors"
,
false
)
?
sys
.
spawn
<
middleman_actor_impl
,
detached
+
hidden
>
(
std
::
move
(
db
))
?
sys
.
spawn
<
middleman_actor_impl
,
hidden
>
(
std
::
move
(
db
))
:
sys
.
spawn
<
middleman_actor_impl
,
hidden
>
(
std
::
move
(
db
));
:
sys
.
spawn
<
middleman_actor_impl
,
detached
+
hidden
>
(
std
::
move
(
db
));
}
}
}
// namespace io
}
// namespace io
...
...
libcaf_io/src/middleman_actor_impl.cpp
View file @
ca325fea
...
@@ -79,17 +79,23 @@ const char* middleman_actor_impl::name() const {
...
@@ -79,17 +79,23 @@ const char* middleman_actor_impl::name() const {
auto
middleman_actor_impl
::
make_behavior
()
->
behavior_type
{
auto
middleman_actor_impl
::
make_behavior
()
->
behavior_type
{
CAF_LOG_TRACE
(
""
);
CAF_LOG_TRACE
(
""
);
auto
tcp_disabled
=
[
=
]
{
return
get_or
(
config
(),
"middleman.disable-tcp"
,
false
);
};
auto
udp_disabled
=
[
=
]
{
return
!
get_or
(
config
(),
"middleman.enable-udp"
,
false
);
};
return
{
return
{
[
=
](
publish_atom
,
uint16_t
port
,
strong_actor_ptr
&
whom
,
mpi_set
&
sigs
,
[
=
](
publish_atom
,
uint16_t
port
,
strong_actor_ptr
&
whom
,
mpi_set
&
sigs
,
std
::
string
&
addr
,
bool
reuse
)
->
put_res
{
std
::
string
&
addr
,
bool
reuse
)
->
put_res
{
CAF_LOG_TRACE
(
""
);
CAF_LOG_TRACE
(
""
);
if
(
!
system
().
config
().
middleman_enable_tcp
)
if
(
tcp_disabled
()
)
return
make_error
(
sec
::
feature_disabled
);
return
make_error
(
sec
::
feature_disabled
);
return
put
(
port
,
whom
,
sigs
,
addr
.
c_str
(),
reuse
);
return
put
(
port
,
whom
,
sigs
,
addr
.
c_str
(),
reuse
);
},
},
[
=
](
open_atom
,
uint16_t
port
,
std
::
string
&
addr
,
bool
reuse
)
->
put_res
{
[
=
](
open_atom
,
uint16_t
port
,
std
::
string
&
addr
,
bool
reuse
)
->
put_res
{
CAF_LOG_TRACE
(
""
);
CAF_LOG_TRACE
(
""
);
if
(
!
system
().
config
().
middleman_enable_tcp
)
if
(
tcp_disabled
()
)
return
make_error
(
sec
::
feature_disabled
);
return
make_error
(
sec
::
feature_disabled
);
strong_actor_ptr
whom
;
strong_actor_ptr
whom
;
mpi_set
sigs
;
mpi_set
sigs
;
...
@@ -97,7 +103,7 @@ auto middleman_actor_impl::make_behavior() -> behavior_type {
...
@@ -97,7 +103,7 @@ auto middleman_actor_impl::make_behavior() -> behavior_type {
},
},
[
=
](
connect_atom
,
std
::
string
&
hostname
,
uint16_t
port
)
->
get_res
{
[
=
](
connect_atom
,
std
::
string
&
hostname
,
uint16_t
port
)
->
get_res
{
CAF_LOG_TRACE
(
CAF_ARG
(
hostname
)
<<
CAF_ARG
(
port
));
CAF_LOG_TRACE
(
CAF_ARG
(
hostname
)
<<
CAF_ARG
(
port
));
if
(
!
system
().
config
().
middleman_enable_tcp
)
if
(
tcp_disabled
()
)
return
make_error
(
sec
::
feature_disabled
);
return
make_error
(
sec
::
feature_disabled
);
auto
rp
=
make_response_promise
();
auto
rp
=
make_response_promise
();
endpoint
key
{
std
::
move
(
hostname
),
port
};
endpoint
key
{
std
::
move
(
hostname
),
port
};
...
@@ -153,13 +159,13 @@ auto middleman_actor_impl::make_behavior() -> behavior_type {
...
@@ -153,13 +159,13 @@ auto middleman_actor_impl::make_behavior() -> behavior_type {
[
=
](
publish_udp_atom
,
uint16_t
port
,
strong_actor_ptr
&
whom
,
[
=
](
publish_udp_atom
,
uint16_t
port
,
strong_actor_ptr
&
whom
,
mpi_set
&
sigs
,
std
::
string
&
addr
,
bool
reuse
)
->
put_res
{
mpi_set
&
sigs
,
std
::
string
&
addr
,
bool
reuse
)
->
put_res
{
CAF_LOG_TRACE
(
""
);
CAF_LOG_TRACE
(
""
);
if
(
!
system
().
config
().
middleman_enable_udp
)
if
(
udp_disabled
()
)
return
make_error
(
sec
::
feature_disabled
);
return
make_error
(
sec
::
feature_disabled
);
return
put_udp
(
port
,
whom
,
sigs
,
addr
.
c_str
(),
reuse
);
return
put_udp
(
port
,
whom
,
sigs
,
addr
.
c_str
(),
reuse
);
},
},
[
=
](
contact_atom
,
std
::
string
&
hostname
,
uint16_t
port
)
->
get_res
{
[
=
](
contact_atom
,
std
::
string
&
hostname
,
uint16_t
port
)
->
get_res
{
CAF_LOG_TRACE
(
CAF_ARG
(
hostname
)
<<
CAF_ARG
(
port
));
CAF_LOG_TRACE
(
CAF_ARG
(
hostname
)
<<
CAF_ARG
(
port
));
if
(
!
system
().
config
().
middleman_enable_udp
)
if
(
udp_disabled
()
)
return
make_error
(
sec
::
feature_disabled
);
return
make_error
(
sec
::
feature_disabled
);
auto
rp
=
make_response_promise
();
auto
rp
=
make_response_promise
();
endpoint
key
{
std
::
move
(
hostname
),
port
};
endpoint
key
{
std
::
move
(
hostname
),
port
};
...
...
libcaf_io/test/basp.cpp
View file @
ca325fea
...
@@ -129,7 +129,7 @@ public:
...
@@ -129,7 +129,7 @@ public:
.
set
(
"middleman.enable-automatic-connections"
,
autoconn
)
.
set
(
"middleman.enable-automatic-connections"
,
autoconn
)
.
set
(
"scheduler.policy"
,
autoconn
?
caf
::
atom
(
"testing"
)
.
set
(
"scheduler.policy"
,
autoconn
?
caf
::
atom
(
"testing"
)
:
caf
::
atom
(
"stealing"
))
:
caf
::
atom
(
"stealing"
))
.
set
(
"middleman.
detach-utility-actors"
,
!
autoconn
))
{
.
set
(
"middleman.
attach-utility-actors"
,
autoconn
))
{
auto
&
mm
=
sys
.
middleman
();
auto
&
mm
=
sys
.
middleman
();
mpx_
=
dynamic_cast
<
network
::
test_multiplexer
*>
(
&
mm
.
backend
());
mpx_
=
dynamic_cast
<
network
::
test_multiplexer
*>
(
&
mm
.
backend
());
CAF_REQUIRE
(
mpx_
!=
nullptr
);
CAF_REQUIRE
(
mpx_
!=
nullptr
);
...
...
libcaf_io/test/basp_udp.cpp
View file @
ca325fea
...
@@ -114,12 +114,12 @@ public:
...
@@ -114,12 +114,12 @@ public:
:
sys
(
cfg
.
load
<
io
::
middleman
,
network
::
test_multiplexer
>
()
:
sys
(
cfg
.
load
<
io
::
middleman
,
network
::
test_multiplexer
>
()
.
set
(
"middleman.enable-automatic-connections"
,
autoconn
)
.
set
(
"middleman.enable-automatic-connections"
,
autoconn
)
.
set
(
"middleman.enable-udp"
,
true
)
.
set
(
"middleman.enable-udp"
,
true
)
.
set
(
"middleman.
enable-tcp"
,
fals
e
)
.
set
(
"middleman.
disable-tcp"
,
tru
e
)
.
set
(
"scheduler.policy"
,
autoconn
||
use_test_coordinator
.
set
(
"scheduler.policy"
,
autoconn
||
use_test_coordinator
?
caf
::
atom
(
"testing"
)
?
caf
::
atom
(
"testing"
)
:
caf
::
atom
(
"stealing"
))
:
caf
::
atom
(
"stealing"
))
.
set
(
"middleman.
de
tach-utility-actors"
,
.
set
(
"middleman.
at
tach-utility-actors"
,
!
(
autoconn
||
use_test_coordinator
)
))
{
autoconn
||
use_test_coordinator
))
{
auto
&
mm
=
sys
.
middleman
();
auto
&
mm
=
sys
.
middleman
();
mpx_
=
dynamic_cast
<
network
::
test_multiplexer
*>
(
&
mm
.
backend
());
mpx_
=
dynamic_cast
<
network
::
test_multiplexer
*>
(
&
mm
.
backend
());
CAF_REQUIRE
(
mpx_
!=
nullptr
);
CAF_REQUIRE
(
mpx_
!=
nullptr
);
...
...
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