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
38892b14
Commit
38892b14
authored
Nov 22, 2016
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix UDP actor handshake & buffer handling
parent
bd9f84ce
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
407 deletions
+53
-407
libcaf_io/caf/io/basp/instance.hpp
libcaf_io/caf/io/basp/instance.hpp
+6
-17
libcaf_io/caf/io/network/default_multiplexer.hpp
libcaf_io/caf/io/network/default_multiplexer.hpp
+1
-0
libcaf_io/src/basp_broker.cpp
libcaf_io/src/basp_broker.cpp
+3
-13
libcaf_io/src/default_multiplexer.cpp
libcaf_io/src/default_multiplexer.cpp
+39
-13
libcaf_io/src/instance.cpp
libcaf_io/src/instance.cpp
+4
-364
No files found.
libcaf_io/caf/io/basp/instance.hpp
View file @
38892b14
...
...
@@ -22,7 +22,7 @@
#include "caf/error.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/binary_deserializer.hpp"
// ---
#include "caf/binary_deserializer.hpp"
#include "caf/io/hook.hpp"
#include "caf/io/middleman.hpp"
...
...
@@ -200,14 +200,6 @@ public:
void
write_client_handshake
(
execution_unit
*
ctx
,
buffer_type
&
buf
,
const
node_id
&
remote_side
);
/// Start handshake ... TODO
//void write_udp_client_handshake(execution_unit* ctx, buffer_type& buf);
/// Answer client handshake ... TODO
//void write_udp_server_handshake(execution_unit* ctx, buffer_type& buf,
// const node_id& remote_side,
// optional<uint16_t> port);
/// Writes an `announce_proxy` to `buf`.
void
write_announce_proxy
(
execution_unit
*
ctx
,
buffer_type
&
buf
,
const
node_id
&
dest_node
,
actor_id
aid
);
...
...
@@ -239,7 +231,8 @@ public:
bool
handle_msg
(
execution_unit
*
ctx
,
const
Handle
&
hdl
,
header
&
hdr
,
std
::
vector
<
char
>*
payload
,
bool
tcp_based
,
optional
<
uint16_t
>
port
)
{
std
::
cerr
<<
"Handling "
<<
to_string
(
hdr
.
operation
)
<<
" msg"
<<
std
::
endl
;
// std::cerr << "[MSG] From " << hdl.id() << " (" << to_string(hdr.operation)
// << ")" << std::endl;
auto
payload_valid
=
[
&
]()
->
bool
{
return
payload
!=
nullptr
&&
payload
->
size
()
==
hdr
.
payload_len
;
};
...
...
@@ -321,18 +314,14 @@ public:
CAF_LOG_INFO
(
"new direct connection:"
<<
CAF_ARG
(
hdr
.
source_node
));
tbl_
.
add
(
hdl
,
hdr
.
source_node
);
}
auto
path
=
tbl_
.
lookup
(
hdr
.
source_node
);
if
(
!
path
)
{
CAF_LOG_ERROR
(
"no route to host after server handshake"
);
return
false
;
if
(
!
tcp_based
)
{
write_server_handshake
(
ctx
,
wr_buf_
.
ptr
->
wr_buf
(
hdl
),
port
);
wr_buf_
.
ptr
->
flush
(
hdl
);
}
if
(
!
tcp_based
)
write_server_handshake
(
ctx
,
path
->
wr_buf
,
port
);
if
(
!
is_known_node
)
{
//auto was_indirect = tbl_.erase_indirect(hdr.source_node);
callee_
.
learned_new_node_directly
(
hdr
.
source_node
);
}
flush
(
*
path
);
break
;
}
case
message_type
:
:
dispatch_message
:
{
...
...
libcaf_io/caf/io/network/default_multiplexer.hpp
View file @
38892b14
...
...
@@ -652,6 +652,7 @@ private:
// state for writing
manager_ptr
writer_
;
bool
ack_writes_
;
bool
writing_
;
buffer_type
wr_buf_
;
buffer_type
wr_offline_buf_
;
...
...
libcaf_io/src/basp_broker.cpp
View file @
38892b14
...
...
@@ -127,8 +127,9 @@ void basp_broker_state::finalize_handshake(const node_id& nid, actor_id aid,
CAF_ASSERT
(
this_context
!=
nullptr
);
this_context
->
id
=
nid
;
auto
&
cb
=
this_context
->
callback
;
if
(
!
cb
)
if
(
!
cb
)
{
return
;
}
auto
cleanup
=
detail
::
make_scope_guard
([
&
]
{
cb
=
none
;
});
...
...
@@ -155,17 +156,6 @@ void basp_broker_state::purge_state(const node_id& nid) {
auto
hdl
=
instance
.
tbl
().
lookup_hdl
(
nid
);
if
(
!
hdl
)
return
;
/*
auto i = tcp_ctx.find(hdl);
if (i != tcp_ctx.end()) {
auto& ref = i->second;
if (ref.callback) {
CAF_LOG_DEBUG("connection closed during handshake");
ref.callback->deliver(sec::disconnect_during_handshake);
}
tcp_ctx.erase(i);
}
*/
apply_visitor
(
purge_state_vis
,
*
hdl
);
proxies
().
erase
(
nid
);
}
...
...
@@ -487,7 +477,7 @@ void basp_broker_state::set_context(dgram_scribe_handle hdl) {
hdl
,
endpoint_context
{
basp
::
await_header
,
basp
::
header
{
basp
::
message_type
::
client
_handshake
,
basp
::
header
{
basp
::
message_type
::
server
_handshake
,
0
,
0
,
0
,
none
,
none
,
invalid_actor_id
,
invalid_actor_id
},
hdl
,
none
,
0
,
none
...
...
libcaf_io/src/default_multiplexer.cpp
View file @
38892b14
...
...
@@ -1008,14 +1008,24 @@ default_multiplexer::add_dgram_doorman(abstract_broker* self,
// further activities for the broker
return
false
;
auto
&
dm
=
acceptor_
.
backend
();
auto
endpoint_info
=
acceptor_
.
last_sender
();
auto
fd
=
new_dgram_scribe_impl
(
acceptor_
.
host
(),
acceptor_
.
port
());
{
std
::
string
host
;
uint16_t
port
;
std
::
tie
(
host
,
port
)
=
sender_from_sockaddr
(
endpoint_info
.
first
,
endpoint_info
.
second
);
// std::cerr << "[DDM] New scribe with " << fd << " for " << host << ":" << port
// << "(or " << acceptor_.host() << ":" << acceptor_.port() << ")"
// << std::endl;
}
if
(
!
fd
)
{
CAF_LOG_ERROR
(
CAF_ARG
(
fd
.
error
()));
return
false
;
// return std::move(fd.error());
}
auto
endpoint_info
=
acceptor_
.
last_sender
();
//
auto endpoint_info = acceptor_.last_sender();
auto
hdl
=
dm
.
add_dgram_scribe
(
parent
(),
*
fd
,
endpoint_info
.
first
,
endpoint_info
.
second
,
false
);
...
...
@@ -1605,6 +1615,7 @@ dgram_communicator::dgram_communicator(default_multiplexer& backend_ref,
:
event_handler
(
backend_ref
,
sockfd
),
dgram_size_
(
0
),
ack_writes_
(
false
),
writing_
(
false
),
waiting_for_remote_endpoint
(
true
)
{
// TODO: Set some reasonable default.
configure_datagram_size
(
1500
);
...
...
@@ -1641,9 +1652,10 @@ void dgram_communicator::write(const void* buf, size_t num_bytes) {
void
dgram_communicator
::
flush
(
const
manager_ptr
&
mgr
)
{
CAF_ASSERT
(
mgr
!=
nullptr
);
CAF_LOG_TRACE
(
CAF_ARG
(
wr_offline_buf_
.
size
()));
if
(
!
wr_offline_buf_
.
empty
())
{
if
(
!
wr_offline_buf_
.
empty
()
&&
!
writing_
)
{
backend
().
add
(
operation
::
write
,
fd
(),
this
);
writer_
=
mgr
;
writing_
=
true
;
prepare_next_write
();
}
}
...
...
@@ -1675,7 +1687,13 @@ void dgram_communicator::handle_event(operation op) {
passivate
();
return
;
}
//std::cerr << "[C] Received " << rb << " bytes" << std::endl;
// {
// std::string host;
// uint16_t port;
// std::tie(host, port) = sender_from_sockaddr(sockaddr_, sockaddr_len_);
// std::cerr << "[COM] " << fd() << " received " << rb << " bytes from "
// << host << ":" << port << std::endl;
// }
// currently handles the change from acceptor
// to communicator, TODO: Find a better solution
// Either keep sending to the same endpoint,
...
...
@@ -1686,8 +1704,8 @@ void dgram_communicator::handle_event(operation op) {
remote_endpoint_addr_
=
std
::
move
(
sockaddr_
);
remote_endpoint_addr_len_
=
sockaddr_len_
;
sockaddr_len_
=
0
;
//std::cerr << "[C
] Adapted new endpoint: " << host_ << ":" << port_
//
<< std::endl;
// std::cerr << "[COM
] Adapted new endpoint: " << host_ << ":" << port_
//
<< std::endl;
}
if
(
rb
>
0
)
{
auto
res
=
reader_
->
consume
(
&
backend
(),
rd_buf_
.
data
(),
rb
);
...
...
@@ -1707,8 +1725,8 @@ void dgram_communicator::handle_event(operation op) {
writer_
->
io_failure
(
&
backend
(),
operation
::
write
);
backend
().
del
(
operation
::
write
,
fd
(),
this
);
}
else
if
(
wb
>
0
)
{
//std::cerr << "[C] Sent " << wb << " bytes to "
//
<< host_ << ":" << port_ << std::endl;
// std::cerr << "[COM] " << fd() << " sent " << wb << " bytes to "
//
<< host_ << ":" << port_ << std::endl;
CAF_ASSERT
(
wb
==
wr_buf_
.
size
());
if
(
ack_writes_
)
writer_
->
datagram_sent
(
&
backend
(),
wb
);
...
...
@@ -1716,8 +1734,8 @@ void dgram_communicator::handle_event(operation op) {
}
else
{
// TODO: remove this if sure that datagrams are either written
// as a whole or not at all
std
::
cerr
<<
"[DC] Partial datagram wrtten: "
<<
wb
<<
" of "
<<
wr_buf_
.
size
()
<<
std
::
endl
;
//
std::cerr << "[DC] Partial datagram wrtten: " << wb
//
<< " of " << wr_buf_.size() << std::endl;
if
(
writer_
)
writer_
->
io_failure
(
&
backend
(),
operation
::
write
);
}
...
...
@@ -1736,6 +1754,7 @@ void dgram_communicator::prepare_next_write() {
CAF_LOG_TRACE
(
CAF_ARG
(
wr_buf_
.
size
())
<<
CAF_ARG
(
wr_offline_buf_
.
size
()));
wr_buf_
.
clear
();
if
(
wr_offline_buf_
.
empty
())
{
writing_
=
false
;
backend
().
del
(
operation
::
write
,
fd
(),
this
);
}
else
{
wr_buf_
.
swap
(
wr_offline_buf_
);
...
...
@@ -1809,7 +1828,14 @@ void dgram_acceptor::handle_event(operation op) {
passivate
();
return
;
}
//std::cerr << "[A] Received message with " << rb << " bytes" << std::endl;
{
std
::
string
host
;
uint16_t
port
;
std
::
tie
(
host
,
port
)
=
sender_from_sockaddr
(
sockaddr_
,
sockaddr_len_
);
// std::cerr << "[ACC] " << fd() << " received message with " << rb
// << " bytes from " << host << ":" << port << std::endl;
}
bytes_read_
=
rb
;
if
(
rb
>
0
)
{
std
::
tie
(
host_
,
port_
)
=
sender_from_sockaddr
(
sockaddr_
,
sockaddr_len_
);
...
...
@@ -1818,8 +1844,8 @@ void dgram_acceptor::handle_event(operation op) {
if
(
!
res
)
{
// What is the right way to propagate this?
CAF_LOG_DEBUG
(
"Failure during creation of new udp endpoint"
);
std
::
cerr
<<
"[DA] Failure during creation of new udp endpoint"
<<
std
::
endl
;;
//
std::cerr << "[DA] Failure during creation of new udp endpoint"
//
<< std::endl;;
}
}
prepare_next_read
();
...
...
libcaf_io/src/instance.cpp
View file @
38892b14
...
...
@@ -115,150 +115,6 @@ connection_state instance::handle(execution_unit* ctx,
}
if
(
!
handle_msg
(
ctx
,
dm
.
handle
,
hdr
,
payload
,
true
,
none
))
return
err
();
/*
// function object for checking payload validity
auto payload_valid = [&]() -> bool {
return payload != nullptr && payload->size() == hdr.payload_len;
};
// handle message to ourselves
switch (hdr.operation) {
case message_type::server_handshake: {
actor_id aid = invalid_actor_id;
std::set<std::string> sigs;
if (payload_valid()) {
binary_deserializer bd{ctx, *payload};
std::string remote_appid;
auto e = bd(remote_appid);
if (e)
return err();
if (remote_appid != callee_.system().config().middleman_app_identifier) {
CAF_LOG_ERROR("app identifier mismatch");
return err();
}
e = bd(aid, sigs);
if (e)
return err();
} else {
CAF_LOG_ERROR("fail to receive the app identifier");
return err();
}
// close self connection after handshake is done
if (hdr.source_node == this_node_) {
CAF_LOG_INFO("close connection to self immediately");
callee_.finalize_handshake(hdr.source_node, aid, sigs);
return err();
}
// close this connection if we already have a direct connection
if (tbl_.lookup_hdl(hdr.source_node)) {
CAF_LOG_INFO("close connection since we already have a "
"direct connection: " << CAF_ARG(hdr.source_node));
callee_.finalize_handshake(hdr.source_node, aid, sigs);
return err();
}
// add direct route to this node and remove any indirect entry
CAF_LOG_INFO("new direct connection:" << CAF_ARG(hdr.source_node));
tbl_.add(dm.handle, hdr.source_node);
// auto was_indirect = tbl_.erase_indirect(hdr.source_node);
// write handshake as client in response
auto path = tbl_.lookup(hdr.source_node);
if (!path) {
CAF_LOG_ERROR("no route to host after server handshake");
return err();
}
write_client_handshake(ctx, path->wr_buf, hdr.source_node);
callee_.learned_new_node_directly(hdr.source_node);
callee_.finalize_handshake(hdr.source_node, aid, sigs);
flush(*path);
break;
}
case message_type::client_handshake: {
if (tbl_.lookup_hdl(hdr.source_node)) {
CAF_LOG_INFO("received second client handshake:"
<< CAF_ARG(hdr.source_node));
break;
}
if (payload_valid()) {
binary_deserializer bd{ctx, *payload};
std::string remote_appid;
auto e = bd(remote_appid);
if (e)
return err();
if (remote_appid != callee_.system().config().middleman_app_identifier) {
CAF_LOG_ERROR("app identifier mismatch");
return err();
}
} else {
CAF_LOG_ERROR("fail to receive the app identifier");
return err();
}
// add direct route to this node and remove any indirect entry
CAF_LOG_INFO("new direct connection:" << CAF_ARG(hdr.source_node));
tbl_.add(dm.handle, hdr.source_node);
// auto was_indirect = tbl_.erase_indirect(hdr.source_node);
callee_.learned_new_node_directly(hdr.source_node);
break;
}
case message_type::dispatch_message: {
if (!payload_valid())
return err();
// in case the sender of this message was received via a third node,
// we assume that that node to offers a route to the original source
//auto last_hop = tbl_.lookup_node(dm.handle);
// TODO: if we don't need this anymore, what does the rest do here?
//if (hdr.source_node != none
// && hdr.source_node != this_node_
// && last_hop != hdr.source_node
// && tbl_.lookup_hdl(hdr.source_node))
// && tbl_.add_indirect(last_hop, hdr.source_node))
// callee_.learned_new_node_indirectly(hdr.source_node);
binary_deserializer bd{ctx, *payload};
auto receiver_name = static_cast<atom_value>(0);
std::vector<strong_actor_ptr> forwarding_stack;
message msg;
if (hdr.has(header::named_receiver_flag)) {
auto e = bd(receiver_name);
if (e)
return err();
}
auto e = bd(forwarding_stack, msg);
if (e)
return err();
CAF_LOG_DEBUG(CAF_ARG(forwarding_stack) << CAF_ARG(msg));
if (hdr.has(header::named_receiver_flag))
callee_.deliver(hdr.source_node, hdr.source_actor, receiver_name,
message_id::from_integer_value(hdr.operation_data),
forwarding_stack, msg);
else
callee_.deliver(hdr.source_node, hdr.source_actor, hdr.dest_actor,
message_id::from_integer_value(hdr.operation_data),
forwarding_stack, msg);
break;
}
case message_type::announce_proxy:
callee_.proxy_announced(hdr.source_node, hdr.dest_actor);
break;
case message_type::kill_proxy: {
if (!payload_valid())
return err();
binary_deserializer bd{ctx, *payload};
error fail_state;
auto e = bd(fail_state);
if (e)
return err();
callee_.kill_proxy(hdr.source_node, hdr.source_actor, fail_state);
break;
}
case message_type::heartbeat: {
CAF_LOG_TRACE("received heartbeat: " << CAF_ARG(hdr.source_node));
callee_.handle_heartbeat(hdr.source_node);
break;
}
default:
CAF_LOG_ERROR("invalid operation");
std::cerr << "[I] Invalid message type" << std::endl;
return err();
}
*/
return
await_header
;
}
...
...
@@ -309,177 +165,6 @@ bool instance::handle(execution_unit* ctx, new_datagram_msg& dm, header& hdr) {
}
if
(
!
handle_msg
(
ctx
,
dm
.
handle
,
hdr
,
payload
,
false
,
dm
.
port
))
return
err
();
/*
// function object for checking payload validity
auto payload_valid = [&]() -> bool {
return payload != nullptr && payload->size() == hdr.payload_len;
};
// handle message ourselves
switch (hdr.operation) {
case message_type::server_handshake: {
std::cerr << "[I] Received UDP server handshake" << std::endl;
// TODO: test if this is the second time the handshake takes place ...
//if (tbl_.lookup(hdr.source_node)) {
// std::cerr << "[I] Second handshake received from node" << std::endl;
// break;
//}
actor_id aid = invalid_actor_id;
std::set<std::string> sigs;
if (payload_valid()) {
binary_deserializer bd{ctx, *payload};
std::string remote_appid;
auto e = bd(remote_appid);
if (e)
return err();
if (remote_appid !=
callee_.system().config().middleman_app_identifier) {
CAF_LOG_ERROR("app identifier mismatch");
return err();
}
e = bd(aid, sigs);
if (e)
return err();
} else {
CAF_LOG_ERROR("fail to receive the app identifier");
return err();
}
// close self connection after handshake is done
if (hdr.source_node == this_node_) {
CAF_LOG_INFO("close connection to self immediately");
callee_.finalize_handshake(hdr.source_node, aid, sigs);
return err();
}
// close this connection if we already have a direct connection
if (tbl_.lookup_hdl(hdr.source_node)) {
CAF_LOG_INFO("close connection since we already have a "
"direct connection: " << CAF_ARG(hdr.source_node));
callee_.finalize_handshake(hdr.source_node, aid, sigs);
return err();
}
// add direct route to this node and remove any indirect entry
CAF_LOG_INFO("new direct connection:" << CAF_ARG(hdr.source_node));
tbl_.add(dm.handle, hdr.source_node);
// auto was_indirect = tbl_.erase_indirect(hdr.source_node);
// write handshake as client in response
auto path = tbl_.lookup(hdr.source_node);
if (!path) {
CAF_LOG_ERROR("no route to host after server handshake");
return err();
}
callee_.learned_new_node_directly(hdr.source_node);
callee_.finalize_handshake(hdr.source_node, aid, sigs);
flush(*path);
break;
}
case message_type::client_handshake: {
std::cerr << "[I] Received UDP client handshake" << std::endl;
if (!tbl_.lookup_hdl(hdr.source_node)) {
std::cerr << "[I] Node not found, is a new client" << std::endl;
if (payload_valid()) {
std::cerr << "[I] Has valid payload of " << hdr.payload_len
<< " bytes" << std::endl;
binary_deserializer bd{ctx, *payload};
std::string remote_appid;
auto e = bd(remote_appid);
if (e)
return err();
if (remote_appid !=
callee_.system().config().middleman_app_identifier) {
CAF_LOG_ERROR("app identifier mismatch");
std::cerr << "[I] App identifier mismatch" << std::endl;
return err();
}
} else {
CAF_LOG_ERROR("failed to receive the app identifier");
std::cerr << "[I] Failed to receive the app identifier" << std::endl;
return err();
}
// add direct route to this node and remove any indirect entry
CAF_LOG_INFO("new direct connection:" << CAF_ARG(hdr.source_node));
tbl_.add(dm.handle, hdr.source_node);
// auto was_indirect = tbl_.erase_indirect(hdr.source_node);
callee_.learned_new_node_directly(hdr.source_node);
}
// write handshake as server in response
auto path = tbl_.lookup(hdr.source_node);
if (!path) {
CAF_LOG_ERROR("no route to host after server handshake");
return err();
}
write_server_handshake(ctx, path->wr_buf, dm.port);
break;
}
case message_type::dispatch_message: {
std::cerr << "[I] Received dispatch message" << std::endl;
if (!payload_valid())
return err();
// in case the sender of this message was received via a third node,
// we assume that that node to offers a route to the original source
//auto last_hop = tbl_.lookup_node(dm.handle);
// TODO: if we don't need this anymore, what does the rest do here?
//if (hdr.source_node != none
// && hdr.source_node != this_node_
// && last_hop != hdr.source_node
// && tbl_.lookup_hdl(hdr.source_node))
// && tbl_.add_indirect(last_hop, hdr.source_node))
// callee_.learned_new_node_indirectly(hdr.source_node);
binary_deserializer bd{ctx, *payload};
auto receiver_name = static_cast<atom_value>(0);
std::vector<strong_actor_ptr> forwarding_stack;
message msg;
if (hdr.has(header::named_receiver_flag)) {
auto e = bd(receiver_name);
if (e)
return err();
}
auto e = bd(forwarding_stack, msg);
if (e)
return err();
CAF_LOG_DEBUG(CAF_ARG(forwarding_stack) << CAF_ARG(msg));
if (hdr.has(header::named_receiver_flag)) {
callee_.deliver(hdr.source_node, hdr.source_actor, receiver_name,
message_id::from_integer_value(hdr.operation_data),
forwarding_stack, msg);
} else {
callee_.deliver(hdr.source_node, hdr.source_actor, hdr.dest_actor,
message_id::from_integer_value(hdr.operation_data),
forwarding_stack, msg);
}
break;
}
case message_type::announce_proxy:
std::cerr << "[I] Received announce proxy message" << std::endl;
callee_.proxy_announced(hdr.source_node, hdr.dest_actor);
break;
case message_type::kill_proxy: {
std::cerr << "[I] message_type::kill_proxy" << std::endl;
if (!payload_valid())
return err();
binary_deserializer bd{ctx, *payload};
error fail_state;
auto e = bd(fail_state);
if (e)
return err();
callee_.kill_proxy(hdr.source_node, hdr.source_actor, fail_state);
break;
}
case message_type::heartbeat: {
std::cerr << "[I] Received heartbeat message" << std::endl;
CAF_LOG_TRACE("received heartbeat: " << CAF_ARG(hdr.source_node));
std::cerr << "[I] Received hearbeat: " << to_string(hdr.source_node)
<< std::endl;
callee_.handle_heartbeat(hdr.source_node);
break;
}
default:
CAF_LOG_ERROR("invalid operation");
std::cerr << "[I] Invalid operation" << std::endl;
return err();
}
*/
}
while
(
dgram_itr
!=
dm
.
buf
.
end
());
return
true
;
};
...
...
@@ -605,7 +290,6 @@ void instance::write(execution_unit* ctx, buffer_type& buf,
// << to_string(hdr.operation) << " message" << std::endl;
error
err
;
if
(
pw
)
{
//std::cerr << "[W] Has payload writer" << std::endl;
auto
pos
=
buf
.
size
();
// write payload first (skip first 72 bytes and write header later)
char
placeholder
[
basp
::
header_size
];
...
...
@@ -617,6 +301,8 @@ void instance::write(execution_unit* ctx, buffer_type& buf,
hdr
.
payload_len
=
static_cast
<
uint32_t
>
(
plen
);
stream_serializer
<
charbuf
>
out
{
ctx
,
buf
.
data
()
+
pos
,
basp
::
header_size
};
err
=
out
(
hdr
);
// std::cerr << "Wrote " << to_string(hdr.operation) << " with " << basp::header_size
// << " + " << hdr.payload_len << " bytes" << std::endl;
}
else
{
binary_serializer
bs
{
ctx
,
buf
};
err
=
bs
(
hdr
);
...
...
@@ -656,6 +342,8 @@ void instance::write_server_handshake(execution_unit* ctx, buffer_type& buf,
this_node_
,
none
,
pa
&&
pa
->
first
?
pa
->
first
->
id
()
:
invalid_actor_id
,
invalid_actor_id
};
// std::cerr << "Writing server handshake, published actor "
// << (pa ? "found" : "unknwon") << std::endl;
write
(
ctx
,
buf
,
hdr
,
&
writer
);
}
...
...
@@ -671,54 +359,6 @@ void instance::write_client_handshake(execution_unit* ctx, buffer_type& buf,
write
(
ctx
,
buf
,
hdr
,
&
writer
);
}
/*
void instance::write_udp_client_handshake(execution_unit* ctx,
buffer_type& buf) {
CAF_LOG_TRACE("");
auto writer = make_callback([&](serializer& sink) -> error {
auto& str = callee_.system().config().middleman_app_identifier;
return sink(const_cast<std::string&>(str));
});
header hdr{message_type::udp_client_handshake, 0, 0, version,
this_node_, none, invalid_actor_id, invalid_actor_id};
write(ctx, buf, hdr, &writer);
}
void instance::write_udp_server_handshake(execution_unit* ctx,
buffer_type& buf,
const node_id& remote_side,
optional<uint16_t> port) {
CAF_LOG_TRACE(CAF_ARG(port));
using namespace detail;
published_actor* pa = nullptr;
if (port) {
auto i = published_actors_.find(*port);
if (i != published_actors_.end())
pa = &i->second;
}
CAF_LOG_DEBUG_IF(!pa && port, "no actor published");
auto writer = make_callback([&](serializer& sink) -> error {
auto& ref = callee_.system().config().middleman_app_identifier;
auto e = sink(const_cast<std::string&>(ref));
if (e)
return e;
if (pa) {
auto i = pa->first ? pa->first->id() : invalid_actor_id;
return sink(i, pa->second);
} else {
auto aid = invalid_actor_id;
std::set<std::string> tmp;
return sink(aid, tmp);
}
});
header hdr{message_type::udp_server_handshake, 0, 0, version,
this_node_, remote_side,
pa && pa->first ? pa->first->id() : invalid_actor_id,
invalid_actor_id};
write(ctx, buf, hdr, &writer);
}
*/
void
instance
::
write_announce_proxy
(
execution_unit
*
ctx
,
buffer_type
&
buf
,
const
node_id
&
dest_node
,
actor_id
aid
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
dest_node
)
<<
CAF_ARG
(
aid
));
...
...
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