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
a4ad9d7b
Commit
a4ad9d7b
authored
Nov 23, 2016
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add packet queue to datagram communicator
parent
0daae04f
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
29 additions
and
34 deletions
+29
-34
libcaf_io/caf/io/basp/instance.hpp
libcaf_io/caf/io/basp/instance.hpp
+1
-1
libcaf_io/caf/io/basp/routing_table.hpp
libcaf_io/caf/io/basp/routing_table.hpp
+0
-1
libcaf_io/caf/io/basp_broker.hpp
libcaf_io/caf/io/basp_broker.hpp
+1
-0
libcaf_io/caf/io/network/default_multiplexer.hpp
libcaf_io/caf/io/network/default_multiplexer.hpp
+4
-3
libcaf_io/src/basp_broker.cpp
libcaf_io/src/basp_broker.cpp
+9
-5
libcaf_io/src/default_multiplexer.cpp
libcaf_io/src/default_multiplexer.cpp
+9
-18
libcaf_io/src/dgram_scribe.cpp
libcaf_io/src/dgram_scribe.cpp
+1
-1
libcaf_io/src/instance.cpp
libcaf_io/src/instance.cpp
+3
-3
libcaf_io/src/routing_table.cpp
libcaf_io/src/routing_table.cpp
+1
-1
libcaf_io/test/triggering.cpp
libcaf_io/test/triggering.cpp
+0
-1
No files found.
libcaf_io/caf/io/basp/instance.hpp
View file @
a4ad9d7b
...
@@ -285,7 +285,7 @@ public:
...
@@ -285,7 +285,7 @@ public:
return
false
;
return
false
;
}
}
if
(
tcp_based
)
if
(
tcp_based
)
write_client_handshake
(
ctx
,
path
->
wr_buf
,
hdr
.
source_node
);
write_client_handshake
(
ctx
,
apply_visitor
(
wr_buf_
,
path
->
hdl
)
,
hdr
.
source_node
);
callee_
.
learned_new_node_directly
(
hdr
.
source_node
);
callee_
.
learned_new_node_directly
(
hdr
.
source_node
);
callee_
.
finalize_handshake
(
hdr
.
source_node
,
aid
,
sigs
);
callee_
.
finalize_handshake
(
hdr
.
source_node
,
aid
,
sigs
);
flush
(
*
path
);
flush
(
*
path
);
...
...
libcaf_io/caf/io/basp/routing_table.hpp
View file @
a4ad9d7b
...
@@ -81,7 +81,6 @@ public:
...
@@ -81,7 +81,6 @@ public:
/// Describes a routing path to a node.
/// Describes a routing path to a node.
struct
endpoint
{
struct
endpoint
{
buffer_type
&
wr_buf
;
const
node_id
&
next_hop
;
const
node_id
&
next_hop
;
endpoint_handle
hdl
;
endpoint_handle
hdl
;
};
};
...
...
libcaf_io/caf/io/basp_broker.hpp
View file @
a4ad9d7b
...
@@ -174,6 +174,7 @@ private:
...
@@ -174,6 +174,7 @@ private:
// visitors
// visitors
addr_visitor
addr_
;
addr_visitor
addr_
;
port_visitor
port_
;
port_visitor
port_
;
wr_buf_visitor
wr_buf_
;
};
};
}
// namespace io
}
// namespace io
...
...
libcaf_io/caf/io/network/default_multiplexer.hpp
View file @
a4ad9d7b
...
@@ -603,7 +603,8 @@ public:
...
@@ -603,7 +603,8 @@ public:
/// @warning Must not be modified outside the IO multiplexers event loop
/// @warning Must not be modified outside the IO multiplexers event loop
/// once the stream has been started.
/// once the stream has been started.
inline
buffer_type
&
wr_buf
()
{
inline
buffer_type
&
wr_buf
()
{
return
wr_offline_buf_
;
wr_offline_buf_
.
emplace_back
();
return
wr_offline_buf_
.
back
();
}
}
/// Returns the read buffer of this stream.
/// Returns the read buffer of this stream.
...
@@ -653,8 +654,8 @@ private:
...
@@ -653,8 +654,8 @@ private:
manager_ptr
writer_
;
manager_ptr
writer_
;
bool
ack_writes_
;
bool
ack_writes_
;
bool
writing_
;
bool
writing_
;
buffer_type
wr_buf_
;
std
::
vector
<
char
>
wr_buf_
;
buffer_type
wr_offline_buf_
;
std
::
deque
<
std
::
vector
<
char
>>
wr_offline_buf_
;
// general state
// general state
// signifies whether to adapt the sender of the next received messages
// signifies whether to adapt the sender of the next received messages
...
...
libcaf_io/src/basp_broker.cpp
View file @
a4ad9d7b
...
@@ -173,7 +173,8 @@ void basp_broker_state::proxy_announced(const node_id& nid, actor_id aid) {
...
@@ -173,7 +173,8 @@ void basp_broker_state::proxy_announced(const node_id& nid, actor_id aid) {
<<
CAF_ARG
(
nid
));
<<
CAF_ARG
(
nid
));
return
;
return
;
}
}
instance
.
write_kill_proxy
(
self
->
context
(),
path
->
wr_buf
,
instance
.
write_kill_proxy
(
self
->
context
(),
apply_visitor
(
wr_buf_vis
,
path
->
hdl
),
nid
,
aid
,
rsn
);
nid
,
aid
,
rsn
);
instance
.
tbl
().
flush
(
*
path
);
instance
.
tbl
().
flush
(
*
path
);
};
};
...
@@ -355,7 +356,8 @@ void basp_broker_state::learned_new_node(const node_id& nid) {
...
@@ -355,7 +356,8 @@ void basp_broker_state::learned_new_node(const node_id& nid) {
0
,
0
,
this_node
(),
nid
,
tmp
.
id
(),
invalid_actor_id
};
0
,
0
,
this_node
(),
nid
,
tmp
.
id
(),
invalid_actor_id
};
// writing std::numeric_limits<actor_id>::max() is a hack to get
// writing std::numeric_limits<actor_id>::max() is a hack to get
// this send-to-named-actor feature working with older CAF releases
// this send-to-named-actor feature working with older CAF releases
instance
.
write
(
self
->
context
(),
path
->
wr_buf
,
hdr
,
&
writer
);
instance
.
write
(
self
->
context
(),
apply_visitor
(
wr_buf_vis
,
path
->
hdl
),
hdr
,
&
writer
);
instance
.
flush
(
*
path
);
instance
.
flush
(
*
path
);
}
}
...
@@ -521,7 +523,8 @@ basp_broker_state::purge_visitor::operator()(const dgram_scribe_handle& h) {
...
@@ -521,7 +523,8 @@ basp_broker_state::purge_visitor::operator()(const dgram_scribe_handle& h) {
basp_broker
::
basp_broker
(
actor_config
&
cfg
)
basp_broker
::
basp_broker
(
actor_config
&
cfg
)
:
stateful_actor
<
basp_broker_state
,
broker
>
(
cfg
),
:
stateful_actor
<
basp_broker_state
,
broker
>
(
cfg
),
addr_
(
this
),
addr_
(
this
),
port_
(
this
)
{
port_
(
this
),
wr_buf_
(
this
)
{
// nop
// nop
}
}
...
@@ -638,7 +641,8 @@ behavior basp_broker::make_behavior() {
...
@@ -638,7 +641,8 @@ behavior basp_broker::make_behavior() {
basp
::
header
::
named_receiver_flag
,
basp
::
header
::
named_receiver_flag
,
0
,
cme
->
mid
.
integer_value
(),
state
.
this_node
(),
0
,
cme
->
mid
.
integer_value
(),
state
.
this_node
(),
dest_node
,
src
->
id
(),
invalid_actor_id
};
dest_node
,
src
->
id
(),
invalid_actor_id
};
state
.
instance
.
write
(
context
(),
path
->
wr_buf
,
hdr
,
&
writer
);
state
.
instance
.
write
(
context
(),
apply_visitor
(
wr_buf_
,
path
->
hdl
),
hdr
,
&
writer
);
state
.
instance
.
flush
(
*
path
);
state
.
instance
.
flush
(
*
path
);
return
delegated
<
message
>
();
return
delegated
<
message
>
();
},
},
...
...
libcaf_io/src/default_multiplexer.cpp
View file @
a4ad9d7b
...
@@ -1641,7 +1641,7 @@ void dgram_communicator::write(const void* buf, size_t num_bytes) {
...
@@ -1641,7 +1641,7 @@ void dgram_communicator::write(const void* buf, size_t num_bytes) {
CAF_LOG_TRACE
(
CAF_ARG
(
num_bytes
));
CAF_LOG_TRACE
(
CAF_ARG
(
num_bytes
));
auto
first
=
reinterpret_cast
<
const
char
*>
(
buf
);
auto
first
=
reinterpret_cast
<
const
char
*>
(
buf
);
auto
last
=
first
+
num_bytes
;
auto
last
=
first
+
num_bytes
;
wr_offline_buf_
.
insert
(
wr_offline_buf_
.
end
(),
first
,
last
);
wr_offline_buf_
.
insert
(
wr_offline_buf_
.
end
(),
std
::
vector
<
char
>
{
first
,
last
}
);
}
}
void
dgram_communicator
::
flush
(
const
manager_ptr
&
mgr
)
{
void
dgram_communicator
::
flush
(
const
manager_ptr
&
mgr
)
{
...
@@ -1674,7 +1674,6 @@ void dgram_communicator::handle_event(operation op) {
...
@@ -1674,7 +1674,6 @@ void dgram_communicator::handle_event(operation op) {
switch
(
op
)
{
switch
(
op
)
{
case
operation
:
:
read
:
{
case
operation
:
:
read
:
{
// incoming message should signify a new remote enpoint
// incoming message should signify a new remote enpoint
// --> create a new dgram_scribe
size_t
rb
;
size_t
rb
;
if
(
!
receive_datagram
(
rb
,
fd
(),
rd_buf_
.
data
(),
rd_buf_
.
size
(),
if
(
!
receive_datagram
(
rb
,
fd
(),
rd_buf_
.
data
(),
rd_buf_
.
size
(),
sockaddr_
,
sockaddr_len_
))
{
sockaddr_
,
sockaddr_len_
))
{
...
@@ -1682,13 +1681,6 @@ void dgram_communicator::handle_event(operation op) {
...
@@ -1682,13 +1681,6 @@ void dgram_communicator::handle_event(operation op) {
passivate
();
passivate
();
return
;
return
;
}
}
// {
// 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
// currently handles the change from acceptor
// to communicator, TODO: Find a better solution
// to communicator, TODO: Find a better solution
// Either keep sending to the same endpoint,
// Either keep sending to the same endpoint,
...
@@ -1699,8 +1691,6 @@ void dgram_communicator::handle_event(operation op) {
...
@@ -1699,8 +1691,6 @@ void dgram_communicator::handle_event(operation op) {
remote_endpoint_addr_
=
std
::
move
(
sockaddr_
);
remote_endpoint_addr_
=
std
::
move
(
sockaddr_
);
remote_endpoint_addr_len_
=
sockaddr_len_
;
remote_endpoint_addr_len_
=
sockaddr_len_
;
sockaddr_len_
=
0
;
sockaddr_len_
=
0
;
// std::cerr << "[COM] Adapted new endpoint: " << host_ << ":" << port_
// << std::endl;
}
}
if
(
rb
>
0
)
{
if
(
rb
>
0
)
{
auto
res
=
reader_
->
consume
(
&
backend
(),
rd_buf_
.
data
(),
rb
);
auto
res
=
reader_
->
consume
(
&
backend
(),
rd_buf_
.
data
(),
rb
);
...
@@ -1720,17 +1710,11 @@ void dgram_communicator::handle_event(operation op) {
...
@@ -1720,17 +1710,11 @@ void dgram_communicator::handle_event(operation op) {
writer_
->
io_failure
(
&
backend
(),
operation
::
write
);
writer_
->
io_failure
(
&
backend
(),
operation
::
write
);
backend
().
del
(
operation
::
write
,
fd
(),
this
);
backend
().
del
(
operation
::
write
,
fd
(),
this
);
}
else
if
(
wb
>
0
)
{
}
else
if
(
wb
>
0
)
{
// std::cerr << "[COM] " << fd() << " sent " << wb << " bytes to "
// << host_ << ":" << port_ << std::endl;
CAF_ASSERT
(
wb
==
wr_buf_
.
size
());
CAF_ASSERT
(
wb
==
wr_buf_
.
size
());
if
(
ack_writes_
)
if
(
ack_writes_
)
writer_
->
datagram_sent
(
&
backend
(),
wb
);
writer_
->
datagram_sent
(
&
backend
(),
wb
);
prepare_next_write
();
prepare_next_write
();
}
else
{
}
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;
if
(
writer_
)
if
(
writer_
)
writer_
->
io_failure
(
&
backend
(),
operation
::
write
);
writer_
->
io_failure
(
&
backend
(),
operation
::
write
);
}
}
...
@@ -1748,11 +1732,18 @@ void dgram_communicator::handle_event(operation op) {
...
@@ -1748,11 +1732,18 @@ void dgram_communicator::handle_event(operation op) {
void
dgram_communicator
::
prepare_next_write
()
{
void
dgram_communicator
::
prepare_next_write
()
{
CAF_LOG_TRACE
(
CAF_ARG
(
wr_buf_
.
size
())
<<
CAF_ARG
(
wr_offline_buf_
.
size
()));
CAF_LOG_TRACE
(
CAF_ARG
(
wr_buf_
.
size
())
<<
CAF_ARG
(
wr_offline_buf_
.
size
()));
wr_buf_
.
clear
();
wr_buf_
.
clear
();
/*
while (wr_offline_buf_.size() > 0 && wr_offline_buf_.front().size() == 0) {
std::cerr << "Removing empy element from buffer ... " << std::endl;
wr_offline_buf_.pop_front();
}
*/
if
(
wr_offline_buf_
.
empty
())
{
if
(
wr_offline_buf_
.
empty
())
{
writing_
=
false
;
writing_
=
false
;
backend
().
del
(
operation
::
write
,
fd
(),
this
);
backend
().
del
(
operation
::
write
,
fd
(),
this
);
}
else
{
}
else
{
wr_buf_
.
swap
(
wr_offline_buf_
);
wr_buf_
.
swap
(
wr_offline_buf_
.
front
());
wr_offline_buf_
.
pop_front
();
}
}
}
}
...
...
libcaf_io/src/dgram_scribe.cpp
View file @
a4ad9d7b
...
@@ -58,7 +58,7 @@ bool dgram_scribe::consume(execution_unit* ctx, const void*, size_t num_bytes) {
...
@@ -58,7 +58,7 @@ bool dgram_scribe::consume(execution_unit* ctx, const void*, size_t num_bytes) {
auto
result
=
invoke_mailbox_element
(
ctx
);
auto
result
=
invoke_mailbox_element
(
ctx
);
// swap buffer back to stream and implicitly flush wr_buf()
// swap buffer back to stream and implicitly flush wr_buf()
msg_buf
.
swap
(
buf
);
msg_buf
.
swap
(
buf
);
//
flush(); // <-- TODO: here from scribe, not sure why?
flush
();
// <-- TODO: here from scribe, not sure why?
return
result
;
return
result
;
}
}
...
...
libcaf_io/src/instance.cpp
View file @
a4ad9d7b
...
@@ -88,7 +88,7 @@ connection_state instance::handle(execution_unit* ctx,
...
@@ -88,7 +88,7 @@ connection_state instance::handle(execution_unit* ctx,
CAF_LOG_DEBUG
(
"forward message"
);
CAF_LOG_DEBUG
(
"forward message"
);
auto
path
=
lookup
(
hdr
.
dest_node
);
auto
path
=
lookup
(
hdr
.
dest_node
);
if
(
path
)
{
if
(
path
)
{
binary_serializer
bs
{
ctx
,
path
->
wr_buf
};
binary_serializer
bs
{
ctx
,
apply_visitor
(
wr_buf_
,
path
->
hdl
)
};
auto
e
=
bs
(
hdr
);
auto
e
=
bs
(
hdr
);
if
(
e
)
if
(
e
)
return
err
();
return
err
();
...
@@ -242,7 +242,7 @@ void instance::write(execution_unit* ctx, const routing_table::endpoint& r,
...
@@ -242,7 +242,7 @@ void instance::write(execution_unit* ctx, const routing_table::endpoint& r,
header
&
hdr
,
payload_writer
*
writer
)
{
header
&
hdr
,
payload_writer
*
writer
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
hdr
));
CAF_LOG_TRACE
(
CAF_ARG
(
hdr
));
CAF_ASSERT
(
hdr
.
payload_len
==
0
||
writer
!=
nullptr
);
CAF_ASSERT
(
hdr
.
payload_len
==
0
||
writer
!=
nullptr
);
write
(
ctx
,
r
.
wr_buf
,
hdr
,
writer
);
write
(
ctx
,
apply_visitor
(
wr_buf_
,
r
.
hdl
)
,
hdr
,
writer
);
tbl_
.
flush
(
r
);
tbl_
.
flush
(
r
);
}
}
...
@@ -317,7 +317,7 @@ bool instance::dispatch(execution_unit* ctx, const strong_actor_ptr& sender,
...
@@ -317,7 +317,7 @@ bool instance::dispatch(execution_unit* ctx, const strong_actor_ptr& sender,
header
hdr
{
message_type
::
dispatch_message
,
0
,
0
,
mid
.
integer_value
(),
header
hdr
{
message_type
::
dispatch_message
,
0
,
0
,
mid
.
integer_value
(),
sender
?
sender
->
node
()
:
this_node
(),
receiver
->
node
(),
sender
?
sender
->
node
()
:
this_node
(),
receiver
->
node
(),
sender
?
sender
->
id
()
:
invalid_actor_id
,
receiver
->
id
()};
sender
?
sender
->
id
()
:
invalid_actor_id
,
receiver
->
id
()};
write
(
ctx
,
path
->
wr_buf
,
hdr
,
&
writer
);
write
(
ctx
,
apply_visitor
(
wr_buf_
,
path
->
hdl
)
,
hdr
,
&
writer
);
flush
(
*
path
);
flush
(
*
path
);
notify
<
hook
::
message_sent
>
(
sender
,
path
->
next_hop
,
receiver
,
mid
,
msg
);
notify
<
hook
::
message_sent
>
(
sender
,
path
->
next_hop
,
receiver
,
mid
,
msg
);
return
true
;
return
true
;
...
...
libcaf_io/src/routing_table.cpp
View file @
a4ad9d7b
...
@@ -39,7 +39,7 @@ routing_table::~routing_table() {
...
@@ -39,7 +39,7 @@ routing_table::~routing_table() {
optional
<
routing_table
::
endpoint
>
routing_table
::
lookup
(
const
node_id
&
target
)
{
optional
<
routing_table
::
endpoint
>
routing_table
::
lookup
(
const
node_id
&
target
)
{
auto
hdl
=
lookup_hdl
(
target
);
auto
hdl
=
lookup_hdl
(
target
);
if
(
hdl
)
if
(
hdl
)
return
endpoint
{
apply_visitor
(
wr_buf_
,
*
hdl
),
target
,
*
hdl
};
return
endpoint
{
/*apply_visitor(wr_buf_, *hdl),*/
target
,
*
hdl
};
// pick first available indirect route
// pick first available indirect route
/*
/*
auto i = indirect_.find(target);
auto i = indirect_.find(target);
...
...
libcaf_io/test/triggering.cpp
View file @
a4ad9d7b
...
@@ -41,7 +41,6 @@ behavior client(broker* self, connection_handle hdl) {
...
@@ -41,7 +41,6 @@ behavior client(broker* self, connection_handle hdl) {
buf
.
resize
(
200
);
buf
.
resize
(
200
);
std
::
iota
(
buf
.
begin
(),
buf
.
end
(),
0
);
std
::
iota
(
buf
.
begin
(),
buf
.
end
(),
0
);
self
->
write
(
hdl
,
buf
.
size
(),
buf
.
data
());
self
->
write
(
hdl
,
buf
.
size
(),
buf
.
data
());
CAF_REQUIRE_EQUAL
(
self
->
wr_buf
(
hdl
).
size
(),
200u
);
self
->
configure_read
(
hdl
,
receive_policy
::
at_least
(
1
));
self
->
configure_read
(
hdl
,
receive_policy
::
at_least
(
1
));
self
->
flush
(
hdl
);
self
->
flush
(
hdl
);
return
{
return
{
...
...
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