Commit 886f5e78 authored by chenhuaqing's avatar chenhuaqing

implement shutdown

parent ebebef9f
......@@ -246,7 +246,7 @@ public:
std::cout << down->handle().id << " receive text: " << text << "\n";
if ("close" == text) {
down->close(1000, "Bye");
down->close(1001, "Bye");
}
return static_cast<ptrdiff_t>(text.size());
}
......
......@@ -7,6 +7,7 @@
#include "caf/error.hpp"
#include "caf/fwd.hpp"
#include "caf/net/fwd.hpp"
#include <caf/sec.hpp>
namespace caf::net {
......@@ -56,7 +57,6 @@ public:
void close(uint16_t code, string_view reason) {
lptr_->close(llptr_, code, reason);
abort_reason();
}
void abort_reason(error reason) {
......
......@@ -101,6 +101,10 @@ public:
return abort_reason_;
}
void shutdown() {
mask_ = operation::shutdown;
}
// -- factories --------------------------------------------------------------
template <class Handle = actor, class LowerLayerPtr, class FallbackHandler>
......
......@@ -51,6 +51,10 @@ public:
return lptr_->abort_reason(llptr_);
}
void shutdown() {
lptr_->shutdown(llptr_);
}
void configure_read(receive_policy policy) {
lptr_->configure_read(llptr_, policy);
}
......
......@@ -84,6 +84,11 @@ public:
return parent->abort_reason();
}
template <class ParentPtr>
static void shutdown(ParentPtr parent) {
parent->shutdown();
}
template <class ParentPtr>
void configure_read(ParentPtr parent, receive_policy policy) {
if (policy.max_size > 0 && max_read_size_ == 0)
......
......@@ -120,6 +120,7 @@ public:
template <class LowerLayerPtr>
void close(LowerLayerPtr down, int code, string_view reason) {
ship_close(down, code, reason);
down->shutdown();
}
template <class LowerLayerPtr>
......
......@@ -278,7 +278,7 @@ void multiplexer::shutdown() {
close_pipe();
} else {
CAF_LOG_DEBUG("push shutdown event to pipe");
write_to_pipe(4, nullptr);
write_to_pipe(pollset_updater::shutdown_code, nullptr);
}
}
......
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