Unverified Commit 76a31e23 authored by Dominik Charousset's avatar Dominik Charousset Committed by GitHub

Merge pull request #1281

Fix a crash related to SSL_ERROR_WANT_READ
parents 2cabff9c 3806b80b
...@@ -3,6 +3,15 @@ ...@@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file. The format All notable changes to this project will be documented in this file. The format
is based on [Keep a Changelog](https://keepachangelog.com). is based on [Keep a Changelog](https://keepachangelog.com).
## Unreleased
### Fixed
- 0.18.4 introduced a potential crash when using the OpenSSL module and
encountering `SSL_ERROR_WANT_READ`. The crash manifested if CAF resumed a
write operation but failed to fully reset its state. The state management (and
consequently the crash) has been fixed.
## [0.18.4] - 2021-07-07 ## [0.18.4] - 2021-07-07
### Added ### Added
......
...@@ -190,7 +190,7 @@ private: ...@@ -190,7 +190,7 @@ private:
auto bf = i->mask; auto bf = i->mask;
i->mask = fun(op, bf); i->mask = fun(op, bf);
if (i->mask == bf) { if (i->mask == bf) {
// didn'""t do a thing // didn't do a thing
CAF_LOG_DEBUG("squashing did not change the event"); CAF_LOG_DEBUG("squashing did not change the event");
} else if (i->mask == old_bf) { } else if (i->mask == old_bf) {
// just turned into a nop // just turned into a nop
......
...@@ -54,7 +54,7 @@ void stream::write(const void* buf, size_t num_bytes) { ...@@ -54,7 +54,7 @@ void stream::write(const void* buf, size_t num_bytes) {
void stream::flush(const manager_ptr& mgr) { void stream::flush(const manager_ptr& mgr) {
CAF_ASSERT(mgr != nullptr); CAF_ASSERT(mgr != nullptr);
CAF_LOG_TRACE(CAF_ARG(wr_offline_buf_.size())); CAF_LOG_TRACE(CAF_ARG(wr_offline_buf_.size()));
if (!wr_offline_buf_.empty() && !state_.writing) { if (!wr_offline_buf_.empty() && !state_.writing && !wr_op_backoff_) {
backend().add(operation::write, fd(), this); backend().add(operation::write, fd(), this);
writer_ = mgr; writer_ = mgr;
state_.writing = true; state_.writing = true;
...@@ -125,7 +125,7 @@ void stream::prepare_next_write() { ...@@ -125,7 +125,7 @@ void stream::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()));
written_ = 0; written_ = 0;
wr_buf_.clear(); wr_buf_.clear();
if (wr_offline_buf_.empty()) { if (wr_offline_buf_.empty() || wr_op_backoff_) {
state_.writing = false; state_.writing = false;
backend().del(operation::write, fd(), this); backend().del(operation::write, fd(), this);
if (state_.shutting_down) if (state_.shutting_down)
...@@ -147,7 +147,10 @@ bool stream::handle_read_result(rw_state read_result, size_t rb) { ...@@ -147,7 +147,10 @@ bool stream::handle_read_result(rw_state read_result, size_t rb) {
// Recover previous pending write if it is the first successful read after // Recover previous pending write if it is the first successful read after
// want_read was reported. // want_read was reported.
if (wr_op_backoff_) { if (wr_op_backoff_) {
CAF_ASSERT(reader_ != nullptr);
backend().add(operation::write, fd(), this); backend().add(operation::write, fd(), this);
writer_ = reader_;
state_.writing = true;
wr_op_backoff_ = false; wr_op_backoff_ = false;
} }
[[fallthrough]]; [[fallthrough]];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment