Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
4 changes: 3 additions & 1 deletion source/extensions/quic_listeners/quiche/platform/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ licenses(["notice"]) # Apache 2
load(
"//bazel:envoy_build_system.bzl",
"envoy_cc_library",
"envoy_cc_platform_dep",
"envoy_cc_test_library",
"envoy_package",
"envoy_select_quiche",
Expand Down Expand Up @@ -79,6 +80,7 @@ envoy_cc_library(

envoy_cc_library(
name = "quic_platform_base_impl_lib",
srcs = ["quic_thread_impl.cc"],
hdrs = [
"quic_aligned_impl.h",
"quic_arraysize_impl.h",
Expand Down Expand Up @@ -124,7 +126,7 @@ envoy_cc_library(
"//source/common/common:assert_lib",
"//source/common/common:byte_order_lib",
"//source/server:backtrace_lib",
]),
]) + envoy_cc_platform_dep("//source/exe:platform_impl_lib"),
)

envoy_cc_library(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace quic {
// A class representing a thread of execution in QUIC.
class QuicThreadImpl {
public:
QuicThreadImpl(const std::string& /*name*/) {}
QuicThreadImpl(const std::string& name);
QuicThreadImpl(const QuicThreadImpl&) = delete;
QuicThreadImpl& operator=(const QuicThreadImpl&) = delete;

Expand Down Expand Up @@ -49,14 +49,6 @@ class QuicThreadImpl {
thread_ = nullptr;
}

// Sets the thread factory to use.
// NOTE: The factory can not be passed via a constructor argument because this class is itself a
// dependency of an external library that derives from it and expects a single argument
// constructor.
void setThreadFactory(Envoy::Thread::ThreadFactory& thread_factory) {
thread_factory_ = &thread_factory;
}

protected:
virtual void Run() {
// We don't want this function to be pure virtual, because it will be called if:
Expand Down
3 changes: 1 addition & 2 deletions test/extensions/quic_listeners/quiche/platform/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ licenses(["notice"]) # Apache 2
load(
"//bazel:envoy_build_system.bzl",
"envoy_cc_fuzz_test",
"envoy_cc_platform_dep",
"envoy_cc_test",
"envoy_cc_test_binary",
"envoy_cc_test_library",
Expand Down Expand Up @@ -41,7 +40,7 @@ envoy_cc_test(
"//test/test_common:utility_lib",
"@com_googlesource_quiche//:quic_platform_port_utils",
"@com_googlesource_quiche//:quic_platform_sleep",
] + envoy_cc_platform_dep("//source/exe:platform_impl_lib"),
],
)

envoy_cc_test(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include "common/memory/stats.h"
#include "common/network/utility.h"

#include "exe/platform_impl.h"

#include "test/common/stats/stat_test_utility.h"
#include "test/extensions/transport_sockets/tls/ssl_test_utility.h"
#include "test/mocks/api/mocks.h"
Expand Down Expand Up @@ -254,14 +252,10 @@ TEST_F(QuicPlatformTest, QuicStringPiece) {
}

TEST_F(QuicPlatformTest, QuicThread) {
Envoy::PlatformImpl platform_impl;

class AdderThread : public QuicThread {
public:
AdderThread(int* value, int increment, Envoy::Thread::ThreadFactory& thread_factory)
: QuicThread("adder_thread"), value_(value), increment_(increment) {
setThreadFactory(thread_factory);
}
AdderThread(int* value, int increment)
: QuicThread("adder_thread"), value_(value), increment_(increment) {}

~AdderThread() override = default;

Expand All @@ -276,19 +270,19 @@ TEST_F(QuicPlatformTest, QuicThread) {
int value = 0;

// A QuicThread that is never started, which is ok.
{ AdderThread t0(&value, 1, platform_impl.threadFactory()); }
{ AdderThread t0(&value, 1); }
EXPECT_EQ(0, value);

// A QuicThread that is started and joined as usual.
{
AdderThread t1(&value, 1, platform_impl.threadFactory());
AdderThread t1(&value, 1);
t1.Start();
t1.Join();
}
EXPECT_EQ(1, value);

// QuicThread will panic if it's started but not joined.
EXPECT_DEATH_LOG_TO_STDERR({ AdderThread(&value, 2, platform_impl.threadFactory()).Start(); },
EXPECT_DEATH_LOG_TO_STDERR({ AdderThread(&value, 2).Start(); },
"QuicThread should be joined before destruction");
}

Expand Down