Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
f860594
format
lambdai Oct 6, 2020
d90cbea
amend
lambdai Oct 6, 2020
80a9178
Merge remote-tracking branch 'origin/master' into bsock
lambdai Oct 6, 2020
622ab92
clean up and add impl ::read()
lambdai Oct 7, 2020
420e498
clang tidy
lambdai Oct 8, 2020
d9ef28f
Merge remote-tracking branch 'origin/master' into bsock
lambdai Oct 8, 2020
4c53d54
impl BufferedIoSocketHandleImpl:write
lambdai Oct 8, 2020
812a288
comment
lambdai Oct 8, 2020
273447d
remove posix header file
lambdai Oct 8, 2020
9f810f2
fix error code on read EOS
lambdai Oct 9, 2020
6422a4f
address comments
lambdai Oct 13, 2020
a978ced
fix TestShutdown and close
lambdai Oct 13, 2020
0cf62b4
fix
lambdai Oct 13, 2020
09c1adf
fix log and comments
lambdai Oct 14, 2020
b73ced3
addressing comment
lambdai Oct 14, 2020
49bd8d6
remove event counter
lambdai Oct 14, 2020
55b9acc
more test and event counter fix
lambdai Oct 14, 2020
a1e0b2b
Merge branch 'bsock' of github.com:lambdai/envoy-dai into bsock
lambdai Oct 14, 2020
fb32d30
format
lambdai Oct 14, 2020
9361c49
add missing
lambdai Oct 15, 2020
baf755a
ASSERT_DEBUG_DEATH
lambdai Oct 15, 2020
a6686b4
coverage
lambdai Oct 15, 2020
2d93b61
coverage, cont
lambdai Oct 15, 2020
992c377
coverage, cont
lambdai Oct 15, 2020
d1a695d
more
lambdai Oct 15, 2020
683ad7f
split userspacefileeventimpl
lambdai Oct 21, 2020
673bca0
add missing files forgot to add to git
lambdai Oct 21, 2020
e59fa57
add scaffold of user space event test
lambdai Oct 22, 2020
b65e540
various fix: file event test not ready yet
lambdai Oct 22, 2020
9291161
Merge branch 'master' into bsock
lambdai Oct 22, 2020
437eb9b
complete user space file event test
lambdai Oct 22, 2020
9299130
fix destroy order in test
lambdai Oct 22, 2020
1b4a204
address comment: no schedule next, typo
lambdai Oct 27, 2020
e3d2839
Merge branch 'master' into bsock
lambdai Oct 28, 2020
58971d9
file event owned by io handle
lambdai Oct 28, 2020
119a9cb
fix format
lambdai Oct 28, 2020
f18fb59
address comment: also add fails_on_windows to track
lambdai Oct 28, 2020
b3e1264
fix cc format
lambdai Oct 28, 2020
7fb8f79
declare UserSpaceFileEventImpl final
lambdai Oct 28, 2020
1af2888
remove onEvents
lambdai Oct 29, 2020
9cdfd1b
fix user space event test
lambdai Oct 29, 2020
6ca32cf
fix buffer io socket handle test
lambdai Oct 29, 2020
fd7e7ea
clang tidy
lambdai Oct 29, 2020
bd745ab
clang tidy and test coverage
lambdai Oct 29, 2020
2e80156
ct
lambdai Oct 30, 2020
089526f
address comments
lambdai Oct 30, 2020
f203b6e
simplify test on new dtor
lambdai Oct 30, 2020
34b18ed
erase triggered events
lambdai Oct 30, 2020
83bd452
final and remove EventListener interface
lambdai Nov 2, 2020
c98c4f9
move to test extensions
lambdai Nov 2, 2020
8d87a54
ns Extensions::IoSocket::BufferedIoSocket
lambdai Nov 2, 2020
a876244
test: ns Extensions::IoSocket::BufferedIoSocket
lambdai Nov 2, 2020
f780926
codeformat and owners
lambdai Nov 2, 2020
aefff6a
moving peer buffer to extension
lambdai Nov 2, 2020
47cf2a8
save file
lambdai Nov 2, 2020
c4a336e
Merge remote-tracking branch 'origin/master' into bsock
lambdai Nov 2, 2020
6244c65
clangtidy wellknown names
lambdai Nov 3, 2020
a58a712
dup counter
lambdai Nov 3, 2020
1269e1e
extension and LT
lambdai Nov 5, 2020
c7ffacc
add staging
lambdai Nov 5, 2020
f2633f4
revert
lambdai Nov 5, 2020
2c7820a
Merge remote-tracking branch 'origin/master' into bsock
lambdai Nov 5, 2020
7c81f18
revert cont
lambdai Nov 5, 2020
9e1744a
destroy cluster info on main thread
lambdai Nov 14, 2020
7c419d1
close test
lambdai Nov 16, 2020
1993def
rewrite recv
lambdai Nov 17, 2020
bfb6911
flow control test
lambdai Nov 17, 2020
92cebbf
Events test
lambdai Nov 17, 2020
c4b1276
move close
lambdai Nov 17, 2020
9484dc8
shutdown test
lambdai Nov 17, 2020
ecb54c8
move writev
lambdai Nov 17, 2020
968e09e
user space event test
lambdai Nov 17, 2020
04ae3ac
typo
lambdai Nov 17, 2020
dfc457d
watermark func, inlineNewDataAvailable, split userspace event file
lambdai Nov 18, 2020
042f44d
more events test
lambdai Nov 18, 2020
c5e7aba
lint
lambdai Nov 19, 2020
82dc3f1
Merge branch 'master' into bsock
lambdai Dec 21, 2020
d2aa295
move test to cc_extension_test
lambdai Dec 21, 2020
faf8dc5
typo and remove Test prefix at test case name
lambdai Dec 21, 2020
f589a4c
renaming and format fix
lambdai Dec 21, 2020
5407f4b
impl partial write in userspace io socket
lambdai Dec 21, 2020
cc4f7f6
typo extension
lambdai Dec 21, 2020
d87f6b1
mark io_socket extension undocumented
lambdai Dec 22, 2020
03aa2c3
fix OwnedBufferFragmentImpl usage in asan test
lambdai Dec 22, 2020
6ad181c
add specialized file covr and fix mac build
lambdai Dec 22, 2020
f69ba83
parent lcov annotation
lambdai Dec 23, 2020
c1290a8
Merge branch 'master' into bsock
lambdai Dec 23, 2020
6eaff67
add ReadyType::Closed support and
lambdai Jan 11, 2021
21cc67a
optimization: add poll method to deliver enabled events unless explic…
lambdai Jan 11, 2021
29c1bea
massage merge master
lambdai Jan 13, 2021
51db809
add coverage by adding more Closed ready type
lambdai Jan 14, 2021
38822f9
massage CI
lambdai Jan 14, 2021
7333584
Merge branch 'main' into bsock
lambdai Feb 2, 2021
726e3e9
fixing build
lambdai Feb 2, 2021
4adf60c
fix test build
lambdai Feb 2, 2021
1f91272
fix build
lambdai Feb 2, 2021
65b590e
fix tests
lambdai Feb 2, 2021
8087b0d
cover read(buf, 0)
lambdai Feb 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions source/common/event/file_event_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include "common/event/event_impl_base.h"

namespace Envoy {

namespace Network {
class BufferedIoSocketHandleImpl;
}
namespace Event {

/**
Expand Down Expand Up @@ -41,5 +45,119 @@ class FileEventImpl : public FileEvent, ImplBase {
// polling and activating new fd events.
const bool activate_fd_events_next_event_loop_;
};

// Forward declare for friend class.
class UserSpaceFileEventFactory;
Comment thread
lambdai marked this conversation as resolved.
Outdated

// The interface of populating event watcher and obtaining the active events. The events includes
// Read, Write and Closed.
Comment thread
lambdai marked this conversation as resolved.
Outdated
class EventListener {
public:
virtual ~EventListener() = default;

// Provide the activated events.
Comment thread
lambdai marked this conversation as resolved.
Outdated
virtual uint32_t triggeredEvents() PURE;
virtual uint32_t getAndClearEphemeralEvents() PURE;

// Callbacks of the event operation.
virtual void onEventEnabled(uint32_t enabled_events) PURE;
virtual void onEventActivated(uint32_t activated_events) PURE;
};

// Return the enabled events except EV_CLOSED. This implementation is generally good since only
// epoll supports EV_CLOSED but the entire envoy code base supports another poller. The event owner
// must assume EV_CLOSED is never activated. Also event owner must tolerate that OS could notify
Comment thread
lambdai marked this conversation as resolved.
Outdated
// events which are not actually triggered.
class DefaultEventListener : public EventListener {
Comment thread
lambdai marked this conversation as resolved.
Outdated
public:
~DefaultEventListener() override = default;

// Return both read and write.
uint32_t triggeredEvents() override { return pending_events_ & (~Event::FileReadyType::Closed); }
Comment thread
lambdai marked this conversation as resolved.
Outdated

void onEventEnabled(uint32_t enabled_events) override { pending_events_ = enabled_events; }

void onEventActivated(uint32_t activated_events) override {
ephermal_events_ |= activated_events;
}

uint32_t getAndClearEphemeralEvents() override {
auto res = ephermal_events_;
Comment thread
lambdai marked this conversation as resolved.
Outdated
ephermal_events_ = 0;
return res;
}

private:
// The persisted interested events and ready events.
uint32_t pending_events_{};
Comment thread
lambdai marked this conversation as resolved.
Outdated
// The events set by activate() and will be cleared after the io callback.
uint32_t ephermal_events_{};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not clear from here why we have persistent and ephemeral events. maybe the comments will clear up?

In general, the setEnabled filters which events can be triggered on activate. So if you're listening for data to read and there's new data, you get informed but if you're not, those events are never propagated. I'm not clear by naming if that's what you're trying to do here?

};

// A FileEvent implementation which is
Comment thread
lambdai marked this conversation as resolved.
Outdated
class UserSpaceFileEventImpl : public FileEvent, Logger::Loggable<Logger::Id::io> {
public:
~UserSpaceFileEventImpl() override {
if (schedulable_.enabled()) {
schedulable_.cancel();
}
ASSERT(event_counter_ == 1);
--event_counter_;
}

// Event::FileEvent
void activate(uint32_t events) override {
event_listener_.onEventActivated(events);
Comment thread
lambdai marked this conversation as resolved.
Outdated
if (!schedulable_.enabled()) {
schedulable_.scheduleCallbackNextIteration();
Comment thread
lambdai marked this conversation as resolved.
Outdated
}
}

void setEnabled(uint32_t events) override {
event_listener_.onEventEnabled(events);
bool was_enabled = schedulable_.enabled();
if (!was_enabled) {
schedulable_.scheduleCallbackNextIteration();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again enabled just indicates what events to watch out for. If there's no pending data to read or write it generally doesn't trigger.

}
ENVOY_LOG(trace, "User space file event {} setEnabled {} on {}. Will {} reschedule.",
Comment thread
lambdai marked this conversation as resolved.
Outdated
static_cast<void*>(this), was_enabled ? "not " : "");
}

EventListener& getEventListener() { return event_listener_; }
void onEvents() { cb_(); }
friend class UserSpaceFileEventFactory;
friend class Network::BufferedIoSocketHandleImpl;

private:
UserSpaceFileEventImpl(Event::FileReadyCb cb, uint32_t events,
SchedulableCallback& schedulable_cb, int& event_counter)
: schedulable_(schedulable_cb), cb_([this, cb]() {
auto all_events = getEventListener().triggeredEvents();
Comment thread
lambdai marked this conversation as resolved.
Outdated
auto ephemeral_events = getEventListener().getAndClearEphemeralEvents();
ENVOY_LOG(trace,
"User space event {} invokes callbacks on allevents = {}, ephermal events = {}",
static_cast<void*>(this), all_events, ephemeral_events);
cb(all_events | ephemeral_events);
}),
event_counter_(event_counter) {
event_listener_.onEventEnabled(events);
}
DefaultEventListener event_listener_;
SchedulableCallback& schedulable_;
std::function<void()> cb_;
int& event_counter_;
Comment thread
lambdai marked this conversation as resolved.
Outdated
};

class UserSpaceFileEventFactory {
public:
static std::unique_ptr<UserSpaceFileEventImpl>
createUserSpaceFileEventImpl(Event::Dispatcher&, Event::FileReadyCb cb, Event::FileTriggerType,
uint32_t events, SchedulableCallback& scheduable_cb,
int& event_counter) {
return std::unique_ptr<UserSpaceFileEventImpl>(
new UserSpaceFileEventImpl(cb, events, scheduable_cb, event_counter));
}
};

} // namespace Event
} // namespace Envoy
21 changes: 21 additions & 0 deletions source/common/network/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ envoy_cc_library(
hdrs = ["io_socket_error_impl.h"],
deps = [
"//include/envoy/api:io_error_interface",
"//include/envoy/api:os_sys_calls_interface",
"//source/common/common:assert_lib",
"//source/common/common:utility_lib",
],
Expand Down Expand Up @@ -469,3 +470,23 @@ envoy_cc_library(
"//source/common/common:macros",
],
)

envoy_cc_library(
name = "peer_buffer_lib",
hdrs = ["peer_buffer.h"],
deps = [
"//source/common/buffer:buffer_lib",
"//source/common/buffer:watermark_buffer_lib",
"//source/common/common:empty_string",
],
)
Comment thread
lambdai marked this conversation as resolved.
Outdated

envoy_cc_library(
name = "buffered_io_socket_handle_lib",
srcs = ["buffered_io_socket_handle_impl.cc"],
hdrs = ["buffered_io_socket_handle_impl.h"],
deps = [
"default_socket_interface_lib",
":peer_buffer_lib",
],
)
228 changes: 228 additions & 0 deletions source/common/network/buffered_io_socket_handle_impl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
#include "common/network/buffered_io_socket_handle_impl.h"

#include "envoy/buffer/buffer.h"
#include "envoy/common/platform.h"

#include "common/api/os_sys_calls_impl.h"
#include "common/common/assert.h"
#include "common/common/utility.h"
#include "common/event/file_event_impl.h"
#include "common/network/address_impl.h"

#include "absl/container/fixed_array.h"
#include "absl/types/optional.h"

namespace Envoy {
namespace Network {

Api::IoCallUint64Result BufferedIoSocketHandleImpl::close() {
ASSERT(!closed_);
if (!write_shutdown_) {
Comment thread
lambdai marked this conversation as resolved.
Outdated
ASSERT(writable_peer_);
// Notify the peer we won't write more data. shutdown(WRITE).
writable_peer_->setWriteEnd();
// Notify the peer that we no longer accept data. shutdown(RD).
writable_peer_->onPeerDestroy();
writable_peer_->maybeSetNewData();
writable_peer_ = nullptr;
write_shutdown_ = true;
}
closed_ = true;
return Api::ioCallUint64ResultNoError();
}

bool BufferedIoSocketHandleImpl::isOpen() const { return !closed_; }

Api::IoCallUint64Result BufferedIoSocketHandleImpl::readv(uint64_t max_length,
Comment thread
lambdai marked this conversation as resolved.
Outdated
Buffer::RawSlice* slices,
uint64_t num_slice) {
if (owned_buffer_.length() == 0) {
Comment thread
lambdai marked this conversation as resolved.
Outdated
if (read_end_stream_) {
return {0, Api::IoErrorPtr(nullptr, [](Api::IoError*) {})};
} else {
return {0, Api::IoErrorPtr(IoSocketError::getIoSocketEagainInstance(),
IoSocketError::deleteIoError)};
}
} else {
Comment thread
lambdai marked this conversation as resolved.
Outdated
absl::FixedArray<iovec> iov(num_slice);
uint64_t num_slices_to_read = 0;
Comment thread
lambdai marked this conversation as resolved.
Outdated
uint64_t num_bytes_to_read = 0;
for (; num_slices_to_read < num_slice && num_bytes_to_read < max_length; num_slices_to_read++) {
auto min_len = std::min(std::min(owned_buffer_.length(), max_length) - num_bytes_to_read,
Comment thread
lambdai marked this conversation as resolved.
Outdated
uint64_t(slices[num_slices_to_read].len_));
owned_buffer_.copyOut(num_bytes_to_read, min_len, slices[num_slices_to_read].mem_);
Comment thread
lambdai marked this conversation as resolved.
Outdated
Comment thread
lambdai marked this conversation as resolved.
Outdated
num_bytes_to_read += min_len;
}
ASSERT(num_bytes_to_read <= max_length);
owned_buffer_.drain(num_bytes_to_read);
ENVOY_LOG(trace, "socket {} readv {} bytes", static_cast<void*>(this), num_bytes_to_read);
return {num_bytes_to_read, Api::IoErrorPtr(nullptr, [](Api::IoError*) {})};
}
}

Api::IoCallUint64Result BufferedIoSocketHandleImpl::read(Buffer::Instance& buffer,
uint64_t max_length) {
if (owned_buffer_.length() == 0) {
if (read_end_stream_) {
return {0, Api::IoErrorPtr(nullptr, [](Api::IoError*) {})};
} else {
return {0, Api::IoErrorPtr(IoSocketError::getIoSocketEagainInstance(),
IoSocketError::deleteIoError)};
}
} else {
// TODO(lambdai): Move at slice boundary to move to reduce the copy.
uint64_t min_len = std::min(max_length, owned_buffer_.length());
buffer.move(owned_buffer_, min_len);
return {min_len, Api::IoErrorPtr(nullptr, [](Api::IoError*) {})};
}
}

Api::IoCallUint64Result BufferedIoSocketHandleImpl::writev(const Buffer::RawSlice* slices,
uint64_t num_slice) {
if (!writable_peer_) {
return sysCallResultToIoCallResult(Api::SysCallSizeResult{-1, SOCKET_ERROR_INTR});
}
if (writable_peer_->isWriteEndSet() || !writable_peer_->isWritable()) {
Comment thread
lambdai marked this conversation as resolved.
Outdated
return {0, Api::IoErrorPtr(IoSocketError::getIoSocketEagainInstance(),
IoSocketError::deleteIoError)};
}
// Write along with iteration. Buffer guarantee the fragment is always append-able.
uint64_t num_bytes_to_write = 0;
for (uint64_t i = 0; i < num_slice; i++) {
if (slices[i].mem_ != nullptr && slices[i].len_ != 0) {
writable_peer_->getWriteBuffer()->add(slices[i].mem_, slices[i].len_);
Comment thread
lambdai marked this conversation as resolved.
Outdated
num_bytes_to_write += slices[i].len_;
}
}
writable_peer_->maybeSetNewData();
Comment thread
lambdai marked this conversation as resolved.
Outdated
ENVOY_LOG(trace, "socket {} writev {} bytes", static_cast<void*>(this), num_bytes_to_write);
return {num_bytes_to_write, Api::IoErrorPtr(nullptr, [](Api::IoError*) {})};
}

Api::IoCallUint64Result BufferedIoSocketHandleImpl::write(Buffer::Instance& buffer) {
if (!writable_peer_) {
return sysCallResultToIoCallResult(Api::SysCallSizeResult{-1, SOCKET_ERROR_INTR});
}
if (writable_peer_->isWriteEndSet() || !writable_peer_->isWritable()) {
return {0, Api::IoErrorPtr(IoSocketError::getIoSocketEagainInstance(),
IoSocketError::deleteIoError)};
}
uint64_t num_bytes_to_write = buffer.length();
writable_peer_->getWriteBuffer()->move(buffer);
writable_peer_->maybeSetNewData();
ENVOY_LOG(trace, "socket {} writev {} bytes", static_cast<void*>(this), num_bytes_to_write);
return {num_bytes_to_write, Api::IoErrorPtr(nullptr, [](Api::IoError*) {})};
}

Api::IoCallUint64Result BufferedIoSocketHandleImpl::sendmsg(const Buffer::RawSlice*, uint64_t, int,
const Address::Ip*,
const Address::Instance&) {
return IoSocketError::ioResultSocketInvalidAddress();
}

Api::IoCallUint64Result BufferedIoSocketHandleImpl::recvmsg(Buffer::RawSlice*, const uint64_t,
uint32_t, RecvMsgOutput&) {
return IoSocketError::ioResultSocketInvalidAddress();
}

Api::IoCallUint64Result BufferedIoSocketHandleImpl::recvmmsg(RawSliceArrays&, uint32_t,
RecvMsgOutput&) {
return IoSocketError::ioResultSocketInvalidAddress();
}

Api::IoCallUint64Result BufferedIoSocketHandleImpl::recv(void* buffer, size_t length, int flags) {
Comment thread
lambdai marked this conversation as resolved.
Outdated
// No data and the writer closed.
if (owned_buffer_.length() == 0) {
if (read_end_stream_) {
return sysCallResultToIoCallResult(Api::SysCallSizeResult{-1, SOCKET_ERROR_INTR});
} else {
return {0, Api::IoErrorPtr(IoSocketError::getIoSocketEagainInstance(),
IoSocketError::deleteIoError)};
}
} else {
auto min_len = std::min(owned_buffer_.length(), length);
owned_buffer_.copyOut(0, min_len, buffer);
if (!(flags & MSG_PEEK)) {
owned_buffer_.drain(min_len);
}
return {min_len, Api::IoErrorPtr(nullptr, [](Api::IoError*) {})};
}
}

bool BufferedIoSocketHandleImpl::supportsMmsg() const { return false; }

bool BufferedIoSocketHandleImpl::supportsUdpGro() const { return false; }

Api::SysCallIntResult makeInvalidSyscall() {
return Api::SysCallIntResult{-1, SOCKET_ERROR_NOT_SUP /*SOCKET_ERROR_NOT_SUP*/};
Comment thread
lambdai marked this conversation as resolved.
Outdated
}

Api::SysCallIntResult BufferedIoSocketHandleImpl::bind(Address::InstanceConstSharedPtr) {
return makeInvalidSyscall();
}

Api::SysCallIntResult BufferedIoSocketHandleImpl::listen(int) { return makeInvalidSyscall(); }

IoHandlePtr BufferedIoSocketHandleImpl::accept(struct sockaddr*, socklen_t*) {
NOT_IMPLEMENTED_GCOVR_EXCL_LINE;
}

Api::SysCallIntResult BufferedIoSocketHandleImpl::connect(Address::InstanceConstSharedPtr) {
// Buffered Io handle should always be considered as connected. Use write to determine if peer is
Comment thread
lambdai marked this conversation as resolved.
Outdated
// closed.
return {0, 0};
}

Api::SysCallIntResult BufferedIoSocketHandleImpl::setOption(int, int, const void*, socklen_t) {
return makeInvalidSyscall();
}

Api::SysCallIntResult BufferedIoSocketHandleImpl::getOption(int, int, void*, socklen_t*) {
return makeInvalidSyscall();
}

Api::SysCallIntResult BufferedIoSocketHandleImpl::setBlocking(bool) { return makeInvalidSyscall(); }

absl::optional<int> BufferedIoSocketHandleImpl::domain() { return absl::nullopt; }

Address::InstanceConstSharedPtr BufferedIoSocketHandleImpl::localAddress() {
throw EnvoyException(fmt::format("getsockname failed for BufferedIoSocketHandleImpl"));
}

Address::InstanceConstSharedPtr BufferedIoSocketHandleImpl::peerAddress() {

throw EnvoyException(fmt::format("getsockname failed for BufferedIoSocketHandleImpl"));
}

Event::FileEventPtr BufferedIoSocketHandleImpl::createFileEvent(Event::Dispatcher& dispatcher,
Comment thread
lambdai marked this conversation as resolved.
Outdated
Event::FileReadyCb cb,
Event::FileTriggerType trigger_type,
Comment thread
lambdai marked this conversation as resolved.
Outdated
uint32_t events) {
ASSERT(event_counter_ == 0);
++event_counter_;
io_callback_ = dispatcher.createSchedulableCallback([this]() { user_file_event_->onEvents(); });
auto res = Event::UserSpaceFileEventFactory::createUserSpaceFileEventImpl(
dispatcher, cb, trigger_type, events, *io_callback_, event_counter_);
user_file_event_ = res.get();
// Blindly activate the events.
io_callback_->scheduleCallbackNextIteration();
Comment thread
lambdai marked this conversation as resolved.
Outdated
return res;
}

Api::SysCallIntResult BufferedIoSocketHandleImpl::shutdown(int how) {
// Support shutdown write.
Comment thread
lambdai marked this conversation as resolved.
Outdated
if ((how == ENVOY_SHUT_WR) || (how == ENVOY_SHUT_RDWR)) {
ASSERT(!closed_);
if (!write_shutdown_) {
ASSERT(writable_peer_);
// Notify the peer we won't write more data. shutdown(WRITE).
writable_peer_->setWriteEnd();
writable_peer_->maybeSetNewData();
write_shutdown_ = true;
}
}
return {0, 0};
}

} // namespace Network
} // namespace Envoy
Loading