Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
actor-incubator
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
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-incubator
Commits
586922e6
Commit
586922e6
authored
Sep 09, 2020
by
Jakob Otto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: stream_transport test
parent
4f70e957
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
160 additions
and
28 deletions
+160
-28
api-redesign.diff
api-redesign.diff
+92
-0
libcaf_net/CMakeLists.txt
libcaf_net/CMakeLists.txt
+12
-12
libcaf_net/caf/net/endpoint_manager_impl.hpp
libcaf_net/caf/net/endpoint_manager_impl.hpp
+2
-2
libcaf_net/caf/net/socket_manager.hpp
libcaf_net/caf/net/socket_manager.hpp
+40
-4
libcaf_net/caf/net/stream_transport.hpp
libcaf_net/caf/net/stream_transport.hpp
+2
-0
libcaf_net/src/net/backend/tcp.cpp
libcaf_net/src/net/backend/tcp.cpp
+1
-0
libcaf_net/src/udp_datagram_socket.cpp
libcaf_net/src/udp_datagram_socket.cpp
+4
-3
libcaf_net/test/stream_transport.cpp
libcaf_net/test/stream_transport.cpp
+7
-7
No files found.
api-redesign.diff
0 → 100644
View file @
586922e6
diff --git a/libcaf_net/CMakeLists.txt b/libcaf_net/CMakeLists.txt
index 8c98f80..be7333c 100644
--- a/libcaf_net/CMakeLists.txt
+++ b/libcaf_net/CMakeLists.txt
@@ -50,8 +50,8 @@
add_library(libcaf_net_obj OBJECT ${CAF_NET_HEADERS}
src/ip.cpp
src/message_queue.cpp
src/multiplexer.cpp
- src/net/backend/test.cpp
- src/net/backend/tcp.cpp
+ #src/net/backend/test.cpp
+ #src/net/backend/tcp.cpp
src/net/endpoint_manager_queue.cpp
src/net/middleman.cpp
src/net/middleman_backend.cpp
@@ -124,28 +124,28 @@
target_link_libraries(caf-net-test PRIVATE CAF::test)
caf_incubator_add_test_suites(caf-net-test
accept_socket
- application
+ #application
convert_ip_endpoint
datagram_socket
- datagram_transport
- doorman
- endpoint_manager
+ #datagram_transport
+ #doorman
+ #endpoint_manager
header
ip
multiplexer
- net.backend.tcp
- net.basp.message_queue
- net.basp.ping_pong
- net.basp.worker
+ #net.backend.tcp
+ #net.basp.message_queue
+ #net.basp.ping_pong
+ #net.basp.worker
net.length_prefix_framing
network_socket
pipe_socket
socket
socket_guard
- stream_application
+ #stream_application
stream_socket
- stream_transport
- string_application
+ #stream_transport
+ #string_application
tcp_sockets
transport_worker
transport_worker_dispatcher
diff --git a/libcaf_net/src/net/backend/tcp.cpp b/libcaf_net/src/net/backend/tcp.cpp
index d1d2bd9..e84b011 100644
--- a/libcaf_net/src/net/backend/tcp.cpp
+++ b/libcaf_net/src/net/backend/tcp.cpp
@@ -25,6 +25,7 @@
#include "caf/net/basp/application.hpp"
#include "caf/net/basp/application_factory.hpp"
#include "caf/net/basp/ec.hpp"
+#include "caf/net/defaults.hpp"
#include "caf/net/doorman.hpp"
#include "caf/net/ip.hpp"
#include "caf/net/make_endpoint_manager.hpp"
diff --git a/libcaf_net/src/udp_datagram_socket.cpp b/libcaf_net/src/udp_datagram_socket.cpp
index d6362f3..58fe231 100644
--- a/libcaf_net/src/udp_datagram_socket.cpp
+++ b/libcaf_net/src/udp_datagram_socket.cpp
@@ -114,8 +114,9 @@
variant<size_t, sec> write(udp_datagram_socket x, span<const byte> buf,
ip_endpoint ep) {
sockaddr_storage addr = {};
detail::convert(ep, addr);
- auto len = ep.address().embeds_v4() ? sizeof(sockaddr_in)
- : sizeof(sockaddr_in6);
+ auto len = static_cast<socklen_t>(ep.address().embeds_v4()
+ ? sizeof(sockaddr_in)
+ : sizeof(sockaddr_in6));
auto res = ::sendto(x.id, reinterpret_cast<socket_send_ptr>(buf.data()),
buf.size(), 0, reinterpret_cast<sockaddr*>(&addr), len);
auto ret = check_udp_datagram_socket_io_res(res);
@@ -172,7 +173,7 @@
variant<size_t, sec> write(udp_datagram_socket x, span<byte_buffer*> bufs,
message.msg_namelen = ep.address().embeds_v4() ? sizeof(sockaddr_in)
: sizeof(sockaddr_in6);
message.msg_iov = buf_array;
- message.msg_iovlen = bufs.size();
+ message.msg_iovlen = static_cast<int>(bufs.size());
auto res = sendmsg(x.id, &message, 0);
return check_udp_datagram_socket_io_res(res);
}
libcaf_net/CMakeLists.txt
View file @
586922e6
...
...
@@ -50,8 +50,8 @@ add_library(libcaf_net_obj OBJECT ${CAF_NET_HEADERS}
src/ip.cpp
src/message_queue.cpp
src/multiplexer.cpp
src/net/backend/test.cpp
src/net/backend/tcp.cpp
#
src/net/backend/test.cpp
#
src/net/backend/tcp.cpp
src/net/endpoint_manager_queue.cpp
src/net/middleman.cpp
src/net/middleman_backend.cpp
...
...
@@ -124,28 +124,28 @@ target_link_libraries(caf-net-test PRIVATE CAF::test)
caf_incubator_add_test_suites
(
caf-net-test
accept_socket
application
#
application
convert_ip_endpoint
datagram_socket
datagram_transport
doorman
endpoint_manager
#
datagram_transport
#
doorman
#
endpoint_manager
header
ip
multiplexer
net.backend.tcp
net.basp.message_queue
net.basp.ping_pong
net.basp.worker
#
net.backend.tcp
#
net.basp.message_queue
#
net.basp.ping_pong
#
net.basp.worker
net.length_prefix_framing
network_socket
pipe_socket
socket
socket_guard
stream_application
#
stream_application
stream_socket
stream_transport
string_application
#
string_application
tcp_sockets
transport_worker
transport_worker_dispatcher
...
...
libcaf_net/caf/net/endpoint_manager_impl.hpp
View file @
586922e6
...
...
@@ -40,8 +40,8 @@ public:
// -- constructors, destructors, and assignment operators --------------------
endpoint_manager_impl
(
const
multiplexer_ptr
&
parent
,
actor_system
&
sys
,
Transport
trans
)
:
super
(
trans
.
handle
()
,
parent
,
sys
),
transport_
(
std
::
move
(
trans
))
{
socket
handle
,
Transport
trans
)
:
super
(
handle
,
parent
,
sys
),
transport_
(
std
::
move
(
trans
))
{
// nop
}
...
...
libcaf_net/caf/net/socket_manager.hpp
View file @
586922e6
...
...
@@ -94,6 +94,8 @@ public:
// -- pure virtual member functions ------------------------------------------
virtual
error
init
(
const
settings
&
config
)
=
0
;
/// Called whenever the socket received new data.
virtual
bool
handle_read_event
()
=
0
;
...
...
@@ -120,10 +122,19 @@ template <class Protocol>
class
socket_manager_impl
:
public
socket_manager
{
public:
template
<
class
...
Ts
>
socket_manager_impl
(
Ts
&&
...
xs
)
:
protocol_
(
std
::
forward
<
Ts
>
(
xs
)...)
{
socket_manager_impl
(
socket
handle
,
const
multiplexer_ptr
&
mpx
,
Ts
&&
...
xs
)
:
socket_manager
{
handle
,
mpx
},
protocol_
(
std
::
forward
<
Ts
>
(
xs
)...)
{
// nop
}
// -- initialization ---------------------------------------------------------
error
init
(
const
settings
&
config
)
override
{
protocol_
.
init
(
*
this
,
config
);
}
// -- event callbacks --------------------------------------------------------
bool
handle_read_event
()
override
{
return
protocol_
.
handle_read_event
(
*
this
);
}
...
...
@@ -152,6 +163,24 @@ private:
/// @relates socket_manager
using
socket_manager_ptr
=
intrusive_ptr
<
socket_manager
>
;
template
<
class
B
,
template
<
class
>
class
...
Layers
>
struct
socket_type_helper
;
template
<
class
B
>
struct
socket_type_helper
<
B
>
{
using
type
=
typename
B
::
socket_type
;
};
template
<
class
B
,
template
<
class
>
class
Layer
,
template
<
class
>
class
...
Layers
>
struct
socket_type_helper
<
B
,
Layer
,
Layers
...
>
:
socket_type_helper
<
Layer
<
B
>
,
Layers
...
>
{
// no content
};
template
<
class
B
,
template
<
class
>
class
...
Layers
>
using
socket_type_t
=
typename
socket_type_helper
<
B
,
Layers
...
>::
type
;
template
<
class
B
,
template
<
class
>
class
...
Layers
>
struct
make_socket_manager_helper
;
...
...
@@ -167,10 +196,17 @@ struct make_socket_manager_helper<B, Layer, Layers...>
// no content
};
template
<
class
B
,
template
<
class
>
class
...
Layers
>
using
make_socket_manager_helper_t
=
typename
make_socket_manager_helper
<
B
,
Layers
...
>::
type
;
template
<
class
App
,
template
<
class
>
class
...
Layers
,
class
...
Ts
>
auto
make_socket_manager
(
Ts
&&
...
xs
)
{
using
impl
=
make_socket_manager_helper
<
App
,
Layers
...,
socket_manager_impl
>
;
return
make_counted
<
impl
>
(
std
::
forward
<
Ts
>
(
xs
)...);
auto
make_socket_manager
(
socket_type_t
<
App
,
Layers
...
>
handle
,
const
multiplexer_ptr
&
mpx
,
Ts
&&
...
xs
)
{
static_assert
(
std
::
is_base_of
<
socket
,
socket_type_t
<
App
,
Layers
...
>>::
value
);
using
impl
=
make_socket_manager_helper_t
<
App
,
Layers
...,
socket_manager_impl
>
;
return
make_counted
<
impl
>
(
std
::
move
(
handle
),
mpx
,
std
::
forward
<
Ts
>
(
xs
)...);
}
}
// namespace caf::net
libcaf_net/caf/net/stream_transport.hpp
View file @
586922e6
...
...
@@ -42,6 +42,8 @@ public:
using
output_tag
=
tag
::
stream_oriented
;
using
socket_type
=
stream_socket
;
// -- constructors, destructors, and assignment operators --------------------
template
<
class
...
Ts
>
...
...
libcaf_net/src/net/backend/tcp.cpp
View file @
586922e6
...
...
@@ -25,6 +25,7 @@
#include "caf/net/basp/application.hpp"
#include "caf/net/basp/application_factory.hpp"
#include "caf/net/basp/ec.hpp"
#include "caf/net/defaults.hpp"
#include "caf/net/doorman.hpp"
#include "caf/net/ip.hpp"
#include "caf/net/make_endpoint_manager.hpp"
...
...
libcaf_net/src/udp_datagram_socket.cpp
View file @
586922e6
...
...
@@ -114,8 +114,9 @@ variant<size_t, sec> write(udp_datagram_socket x, span<const byte> buf,
ip_endpoint
ep
)
{
sockaddr_storage
addr
=
{};
detail
::
convert
(
ep
,
addr
);
auto
len
=
ep
.
address
().
embeds_v4
()
?
sizeof
(
sockaddr_in
)
:
sizeof
(
sockaddr_in6
);
auto
len
=
static_cast
<
socklen_t
>
(
ep
.
address
().
embeds_v4
()
?
sizeof
(
sockaddr_in
)
:
sizeof
(
sockaddr_in6
));
auto
res
=
::
sendto
(
x
.
id
,
reinterpret_cast
<
socket_send_ptr
>
(
buf
.
data
()),
buf
.
size
(),
0
,
reinterpret_cast
<
sockaddr
*>
(
&
addr
),
len
);
auto
ret
=
check_udp_datagram_socket_io_res
(
res
);
...
...
@@ -172,7 +173,7 @@ variant<size_t, sec> write(udp_datagram_socket x, span<byte_buffer*> bufs,
message
.
msg_namelen
=
ep
.
address
().
embeds_v4
()
?
sizeof
(
sockaddr_in
)
:
sizeof
(
sockaddr_in6
);
message
.
msg_iov
=
buf_array
;
message
.
msg_iovlen
=
bufs
.
size
(
);
message
.
msg_iovlen
=
static_cast
<
int
>
(
bufs
.
size
()
);
auto
res
=
sendmsg
(
x
.
id
,
&
message
,
0
);
return
check_udp_datagram_socket_io_res
(
res
);
}
...
...
libcaf_net/test/stream_transport.cpp
View file @
586922e6
...
...
@@ -147,13 +147,13 @@ CAF_TEST_FIXTURE_SCOPE(endpoint_manager_tests, fixture)
CAF_TEST
(
receive
)
{
using
transport_type
=
stream_transport
<
dummy_application
>
;
auto
mgr
=
make_
endpoint_manager
(
mpx
,
sys
,
transport_type
{
recv_socket_guard
.
release
(),
dummy_application
{
shared_buf
}})
;
CAF_CHECK_EQUAL
(
mgr
->
init
(),
none
);
auto
mgr_impl
=
mgr
.
downcast
<
endpoint_manager_impl
<
transport_type
>>
();
CAF_CHECK
(
mgr_impl
!=
nullptr
);
auto
&
transport
=
mgr
_impl
->
transport
();
auto
mgr
=
make_
socket_manager
<
dummy_application
,
stream_transport
>
(
recv_socket_guard
.
release
(),
mpx
,
shared_buf
);
settings
config
;
CAF_CHECK_EQUAL
(
mgr
->
init
(
config
),
none
);
//
auto mgr_impl = mgr.downcast<endpoint_manager_impl<transport_type>>();
//
CAF_CHECK(mgr_impl != nullptr);
auto
&
transport
=
mgr
->
protocol
();
transport
.
configure_read
(
receive_policy
::
exactly
(
hello_manager
.
size
()));
CAF_CHECK_EQUAL
(
mpx
->
num_socket_managers
(),
2u
);
CAF_CHECK_EQUAL
(
write
(
send_socket_guard
.
socket
(),
...
...
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