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
47d0921e
Unverified
Commit
47d0921e
authored
Aug 07, 2018
by
Dominik Charousset
Committed by
GitHub
Aug 07, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #740
Allow policies to signal internal buffering
parents
28e83bbe
0c76c395
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
3 deletions
+37
-3
libcaf_io/caf/io/network/stream.hpp
libcaf_io/caf/io/network/stream.hpp
+9
-3
libcaf_io/caf/policy/tcp.hpp
libcaf_io/caf/policy/tcp.hpp
+6
-0
libcaf_io/caf/policy/udp.hpp
libcaf_io/caf/policy/udp.hpp
+6
-0
libcaf_openssl/caf/openssl/session.hpp
libcaf_openssl/caf/openssl/session.hpp
+3
-0
libcaf_openssl/src/middleman_actor.cpp
libcaf_openssl/src/middleman_actor.cpp
+4
-0
libcaf_openssl/src/session.cpp
libcaf_openssl/src/session.cpp
+4
-0
libcaf_openssl/test/remote_actor.cpp
libcaf_openssl/test/remote_actor.cpp
+5
-0
No files found.
libcaf_io/caf/io/network/stream.hpp
View file @
47d0921e
...
...
@@ -99,17 +99,23 @@ protected:
template
<
class
Policy
>
void
handle_event_impl
(
io
::
network
::
operation
op
,
Policy
&
policy
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
op
));
auto
mcr
=
max_consecutive_reads_
;
switch
(
op
)
{
case
io
:
:
network
::
operation
::
read
:
{
// Loop until an error occurs or we have nothing more to read
// or until we have handled `mcr` reads.
size_t
rb
;
for
(
size_t
i
=
0
;
i
<
mcr
;
++
i
)
{
size_t
rb
=
0
;
auto
threshold
=
[
&
]
{
CAF_ASSERT
(
read_threshold_
>=
collected_
);
return
read_threshold_
-
collected_
;
};
size_t
reads
=
0
;
while
(
reads
<
max_consecutive_reads_
||
policy
.
must_read_more
(
fd
(),
threshold
()))
{
auto
res
=
policy
.
read_some
(
rb
,
fd
(),
rd_buf_
.
data
()
+
collected_
,
rd_buf_
.
size
()
-
collected_
);
if
(
!
handle_read_result
(
res
,
rb
))
return
;
++
reads
;
}
break
;
}
...
...
libcaf_io/caf/policy/tcp.hpp
View file @
47d0921e
...
...
@@ -47,6 +47,12 @@ struct tcp {
/// as long as
static
bool
try_accept
(
io
::
network
::
native_socket
&
result
,
io
::
network
::
native_socket
fd
);
/// Always returns `false`. Native TCP I/O event handlers only rely on the
/// socket buffer.
static
constexpr
bool
must_read_more
(
io
::
network
::
native_socket
,
size_t
)
{
return
false
;
}
};
}
// namespace policy
...
...
libcaf_io/caf/policy/udp.hpp
View file @
47d0921e
...
...
@@ -41,6 +41,12 @@ struct udp {
static
bool
write_datagram
(
size_t
&
result
,
io
::
network
::
native_socket
fd
,
void
*
buf
,
size_t
buf_len
,
const
io
::
network
::
ip_endpoint
&
ep
);
/// Always returns `false`. Native UDP I/O event handlers only rely on the
/// socket buffer.
static
constexpr
bool
must_read_more
(
io
::
network
::
native_socket
,
size_t
)
{
return
false
;
}
};
}
// namespace policy
...
...
libcaf_openssl/caf/openssl/session.hpp
View file @
47d0921e
...
...
@@ -58,6 +58,9 @@ public:
size_t
len
);
bool
try_connect
(
native_socket
fd
);
bool
try_accept
(
native_socket
fd
);
bool
must_read_more
(
native_socket
,
size_t
threshold
);
const
char
*
openssl_passphrase
();
private:
...
...
libcaf_openssl/src/middleman_actor.cpp
View file @
47d0921e
...
...
@@ -89,6 +89,10 @@ struct ssl_policy {
return
session_
->
try_accept
(
result
);
}
bool
must_read_more
(
native_socket
fd
,
size_t
threshold
)
{
return
session_
->
must_read_more
(
fd
,
threshold
);
}
private:
session_ptr
session_
;
};
...
...
libcaf_openssl/src/session.cpp
View file @
47d0921e
...
...
@@ -197,6 +197,10 @@ bool session::try_accept(native_socket fd) {
return
handle_ssl_result
(
ret
);
}
bool
session
::
must_read_more
(
native_socket
,
size_t
threshold
)
{
return
static_cast
<
size_t
>
(
SSL_pending
(
ssl_
))
>=
threshold
;
}
const
char
*
session
::
openssl_passphrase
()
{
return
openssl_passphrase_
.
c_str
();
}
...
...
libcaf_openssl/test/remote_actor.cpp
View file @
47d0921e
...
...
@@ -46,6 +46,11 @@ public:
add_message_type
<
std
::
vector
<
int
>>
(
"std::vector<int>"
);
actor_system_config
::
parse
(
test
::
engine
::
argc
(),
test
::
engine
::
argv
());
// Setting the "max consecutive reads" to 1 is highly likely to cause
// OpenSSL to buffer data internally and report "pending" data after a read
// operation. This will trigger `must_read_more` in the SSL read policy
// with high probability.
set
(
"middleman.max-consecutive-reads"
,
1
);
}
};
...
...
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