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
35737b2f
Commit
35737b2f
authored
Jun 16, 2021
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1276
Closes #1060.
parents
41abdfbc
9ed75df6
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
6 deletions
+29
-6
CHANGELOG.md
CHANGELOG.md
+5
-0
libcaf_io/caf/io/network/rw_state.hpp
libcaf_io/caf/io/network/rw_state.hpp
+3
-1
libcaf_io/caf/io/network/stream.hpp
libcaf_io/caf/io/network/stream.hpp
+1
-0
libcaf_io/src/io/network/stream.cpp
libcaf_io/src/io/network/stream.cpp
+19
-1
libcaf_openssl/src/openssl/session.cpp
libcaf_openssl/src/openssl/session.cpp
+1
-4
No files found.
CHANGELOG.md
View file @
35737b2f
...
...
@@ -15,6 +15,11 @@ is based on [Keep a Changelog](https://keepachangelog.com).
-
Blocking actors now release their private thread before decrementing the
running-actors count to resolve a race condition during system shutdown that
could result in the system hanging (#1266).
-
When using the OpenSSL module, CAF could run into a state where the SSL layer
wants to read data while CAF is trying to send data. In this case, CAF did not
properly back off, causing high CPU load due to spinning and in some scenarios
never recovering. This issue has been resolved by properly handling
`SSL_ERROR_WANT_READ`
on the transport (#1060).
### Removed
...
...
libcaf_io/caf/io/network/rw_state.hpp
View file @
35737b2f
...
...
@@ -13,7 +13,9 @@ enum class rw_state {
/// Reports that the socket is closed or faulty.
failure
,
/// Reports that an empty buffer is in use and no operation was performed.
indeterminate
indeterminate
,
/// Reports that the transport wants to read data before it can write again.
want_read
};
}
// namespace caf::io::network
libcaf_io/caf/io/network/stream.hpp
View file @
35737b2f
...
...
@@ -136,6 +136,7 @@ private:
size_t
written_
;
byte_buffer
wr_buf_
;
byte_buffer
wr_offline_buf_
;
bool
wr_op_backoff_
;
};
}
// namespace caf::io::network
libcaf_io/src/io/network/stream.cpp
View file @
35737b2f
...
...
@@ -21,7 +21,8 @@ stream::stream(default_multiplexer& backend_ref, native_socket sockfd)
defaults
::
middleman
::
max_consecutive_reads
)),
read_threshold_
(
1
),
collected_
(
0
),
written_
(
0
)
{
written_
(
0
),
wr_op_backoff_
(
false
)
{
configure_read
(
receive_policy
::
at_most
(
1024
));
}
...
...
@@ -143,6 +144,14 @@ bool stream::handle_read_result(rw_state read_result, size_t rb) {
case
rw_state
:
:
indeterminate
:
return
false
;
case
rw_state
:
:
success
:
// Recover previous pending write if it is the first successful read after
// want_read was reported.
if
(
wr_op_backoff_
)
{
backend
().
add
(
operation
::
write
,
fd
(),
this
);
wr_op_backoff_
=
false
;
}
[[
fallthrough
]];
case
rw_state
:
:
want_read
:
if
(
rb
==
0
)
return
false
;
collected_
+=
rb
;
...
...
@@ -168,6 +177,15 @@ void stream::handle_write_result(rw_state write_result, size_t wb) {
case
rw_state
:
:
indeterminate
:
prepare_next_write
();
break
;
case
rw_state
:
:
want_read
:
// If the write operation returns want_read, we need to suspend writing to
// the socket until the next successful read. Otherwise, we may cause
// spinning and high CPU usage.
backend
().
del
(
operation
::
write
,
fd
(),
this
);
wr_op_backoff_
=
true
;
if
(
wb
==
0
)
break
;
[[
fallthrough
]];
case
rw_state
:
:
success
:
written_
+=
wb
;
CAF_ASSERT
(
written_
<=
wr_buf_
.
size
());
...
...
libcaf_openssl/src/openssl/session.cpp
View file @
35737b2f
...
...
@@ -94,10 +94,7 @@ rw_state session::do_some(int (*f)(SSL*, void*, int), size_t& result, void* buf,
return
rw_state
::
failure
;
case
SSL_ERROR_WANT_READ
:
CAF_LOG_DEBUG
(
"SSL_ERROR_WANT_READ reported"
);
// Report success to poll on this socket.
if
(
len
==
0
&&
strcmp
(
debug_name
,
"write_some"
)
==
0
)
return
rw_state
::
indeterminate
;
return
rw_state
::
success
;
return
rw_state
::
want_read
;
case
SSL_ERROR_WANT_WRITE
:
CAF_LOG_DEBUG
(
"SSL_ERROR_WANT_WRITE reported"
);
// Report success to poll on this 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