-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
event: assert the case of both read and closed event registered #18265
Changes from all commits
2230a06
6d769f1
e931f3d
488936f
ae5004f
98774b7
1fe505c
481a41c
ca33eef
308ffbb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,9 @@ void FileEventImpl::activate(uint32_t events) { | |
void FileEventImpl::assignEvents(uint32_t events, event_base* base) { | ||
ASSERT(dispatcher_.isThreadSafe()); | ||
ASSERT(base != nullptr); | ||
// TODO(antoniovicente) remove this once ConnectionImpl can | ||
// handle Read and Close events delivered together. | ||
ASSERT(!((events & FileReadyType::Read) && (events & FileReadyType::Closed))); | ||
enabled_events_ = events; | ||
event_assign( | ||
&raw_event_, base, fd_, | ||
|
@@ -120,7 +123,6 @@ void FileEventImpl::unregisterEventIfEmulatedEdge(uint32_t event) { | |
ASSERT(dispatcher_.isThreadSafe()); | ||
// This constexpr if allows the compiler to optimize away the function on POSIX | ||
if constexpr (PlatformDefaultTriggerType == FileTriggerType::EmulatedEdge) { | ||
ASSERT((event & (FileReadyType::Read | FileReadyType::Write)) == event); | ||
if (trigger_ == FileTriggerType::EmulatedEdge) { | ||
auto new_event_mask = enabled_events_ & ~event; | ||
updateEvents(new_event_mask); | ||
|
@@ -156,7 +158,6 @@ void FileEventImpl::mergeInjectedEventsAndRunCb(uint32_t events) { | |
injected_activation_events_ = injected_activation_events_ & ~FileReadyType::Read; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above, this is a change in behavior. Adding an ASSERT is not a guarantee that these cases won't come up while running a real proxy. Also note that injected_activation_events_ may contain events that the connection is not registered for. I don't think it happens often but it is technically allowed. |
||
} | ||
} | ||
|
||
events |= injected_activation_events_; | ||
injected_activation_events_ = 0; | ||
activation_cb_->cancel(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,10 +61,6 @@ Network::FilterStatus Filter::onAccept(Network::ListenerFilterCallbacks& cb) { | |
cb.dispatcher(), | ||
[this](uint32_t events) { | ||
ENVOY_LOG(trace, "http inspector event: {}", events); | ||
// inspector is always peeking and can never determine EOF. | ||
// Use this event type to avoid listener timeout on the OS supporting | ||
// FileReadyType::Closed. | ||
bool end_stream = events & Event::FileReadyType::Closed; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These comments imply that including Closed in the event mask is important. IIRC Closed events are not supported on Mac, so relying on Closed events seems broken. At some point in the future I may try to reduce our reliance on them but that is unlikely to happen anytime soon. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean reduce the reliance on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, stop using Closed events in the envoy implementation. It's not an easy task as it interacts in intrusive ways with the way Connection readDisable is implemented. |
||
|
||
const ParseState parse_state = onRead(); | ||
switch (parse_state) { | ||
|
@@ -78,19 +74,11 @@ Network::FilterStatus Filter::onAccept(Network::ListenerFilterCallbacks& cb) { | |
cb_->continueFilterChain(true); | ||
break; | ||
case ParseState::Continue: | ||
if (end_stream) { | ||
// Parser fails to determine http but the end of stream is reached. Fallback to | ||
// non-http. | ||
done(false); | ||
cb_->socket().ioHandle().resetFileEvents(); | ||
cb_->continueFilterChain(true); | ||
} | ||
// do nothing but wait for the next event | ||
break; | ||
} | ||
}, | ||
Event::PlatformDefaultTriggerType, | ||
Event::FileReadyType::Read | Event::FileReadyType::Closed); | ||
Event::PlatformDefaultTriggerType, Event::FileReadyType::Read); | ||
return Network::FilterStatus::StopIteration; | ||
} | ||
NOT_REACHED_GCOVR_EXCL_LINE; | ||
|
@@ -107,6 +95,11 @@ ParseState Filter::onRead() { | |
return ParseState::Error; | ||
} | ||
|
||
// Remote closed | ||
if (result.return_value_ == 0) { | ||
return ParseState::Error; | ||
} | ||
|
||
const auto parse_state = | ||
parseHttpHeader(absl::string_view(reinterpret_cast<const char*>(buf_), result.return_value_)); | ||
switch (parse_state) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you shed some light as to why this ASSERT was removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we assert the same at
assignEvents
, it will be invoked byupdateEvents
at line 128 also. So I remove this since it is duplicated