Commit fddf45e0 authored by chenhuaqing's avatar chenhuaqing

fixed close opcode

parent 886f5e78
...@@ -102,7 +102,8 @@ public: ...@@ -102,7 +102,8 @@ public:
} }
void shutdown() { void shutdown() {
mask_ = operation::shutdown; mask_del(operation::read);
mask_add(operation::shutdown);
} }
// -- factories -------------------------------------------------------------- // -- factories --------------------------------------------------------------
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "caf/span.hpp" #include "caf/span.hpp"
#include "caf/tag/io_event_oriented.hpp" #include "caf/tag/io_event_oriented.hpp"
#include "caf/tag/stream_oriented.hpp" #include "caf/tag/stream_oriented.hpp"
#include "operation.hpp"
namespace caf::net { namespace caf::net {
...@@ -267,7 +268,12 @@ public: ...@@ -267,7 +268,12 @@ public:
auto written = write(parent->handle(), write_buf_); auto written = write(parent->handle(), write_buf_);
if (written > 0) { if (written > 0) {
write_buf_.erase(write_buf_.begin(), write_buf_.begin() + written); write_buf_.erase(write_buf_.begin(), write_buf_.begin() + written);
return !write_buf_.empty() || !upper_layer_.done_sending(this_layer_ptr); bool empty = write_buf_.empty();
if (write_buf_.empty()
&& (parent->mask() & operation::shutdown) == operation::shutdown) {
return false;
}
return !empty || !upper_layer_.done_sending(this_layer_ptr);
} else if (written < 0) { } else if (written < 0) {
// Try again later on temporary errors such as EWOULDBLOCK and // Try again later on temporary errors such as EWOULDBLOCK and
// stop writing to the socket on hard errors. // stop writing to the socket on hard errors.
......
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