Skip to content

Commit

Permalink
wasm: fix network leak (envoyproxy#13836)
Browse files Browse the repository at this point in the history
Signed-off-by: Kuat Yessenov <kuat@google.com>
  • Loading branch information
kyessenov authored and andreyprezotto committed Nov 24, 2020
1 parent a52935a commit 0026696
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
6 changes: 1 addition & 5 deletions source/extensions/common/wasm/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -858,11 +858,7 @@ BufferInterface* Context::getBuffer(WasmBufferType type) {
void Context::onDownstreamConnectionClose(CloseType close_type) {
ContextBase::onDownstreamConnectionClose(close_type);
downstream_closed_ = true;
// Call close on TCP connection, if upstream connection closed or there was a failure seen in
// this connection.
if (upstream_closed_ || getRequestStreamInfo()->hasAnyResponseFlag()) {
onCloseTCP();
}
onCloseTCP();
}

void Context::onUpstreamConnectionClose(CloseType close_type) {
Expand Down
4 changes: 0 additions & 4 deletions test/extensions/filters/network/wasm/wasm_filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,11 @@ TEST_P(WasmNetworkFilterTest, CloseStream) {
// Create context.
EXPECT_CALL(filter(), log_(spdlog::level::trace, Eq(absl::string_view("onNewConnection 2"))));
EXPECT_EQ(Network::FilterStatus::Continue, filter().onNewConnection());
EXPECT_CALL(filter(),
log_(spdlog::level::trace, Eq(absl::string_view("onDownstreamConnectionClose 2 1"))));
EXPECT_CALL(filter(),
log_(spdlog::level::trace, Eq(absl::string_view("onDownstreamConnectionClose 2 2"))));

filter().onEvent(static_cast<Network::ConnectionEvent>(9999)); // Does nothing.
filter().onEvent(Network::ConnectionEvent::RemoteClose);
filter().closeStream(proxy_wasm::WasmStreamType::Downstream);
filter().closeStream(proxy_wasm::WasmStreamType::Upstream);
}

TEST_P(WasmNetworkFilterTest, SegvFailOpen) {
Expand Down

0 comments on commit 0026696

Please sign in to comment.