Skip to content

Commit

Permalink
network: remove an assert (#18201)
Browse files Browse the repository at this point in the history
#16122 added asserts to utilities to make sure they were called from the correct thread.
Over on the Envoy mobile side when we do QUIC we're doing it from the main thread, and failing some of the assert checks.
I think the right thing to do here is just remove the assert

This is the only use of isWorkerThread() so I'm inclined to just remove it.
cc @goaway

Risk Level: n/a
Testing: n/a
Docs Changes: n/a
Release Notes: n/a
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
  • Loading branch information
alyssawilk authored Sep 22, 2021
1 parent b868e15 commit 956d834
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 14 deletions.
10 changes: 0 additions & 10 deletions source/common/common/thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ bool MainThread::isMainThread() {
return main_thread_singleton->inMainThread() || main_thread_singleton->inTestThread();
}

bool MainThread::isWorkerThread() {
auto main_thread_singleton = MainThreadSingleton::getExisting();
// Allow worker thread code to be executed in test thread.
if (main_thread_singleton == nullptr) {
return true;
}
// When threading is on, compare thread id with main thread id.
return !main_thread_singleton->inMainThread();
}

void MainThread::clear() {
delete MainThreadSingleton::getExisting();
MainThreadSingleton::clear();
Expand Down
1 change: 0 additions & 1 deletion source/common/common/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ struct MainThread {
*/
static void clear();
static bool isMainThread();
static bool isWorkerThread();

private:
std::thread::id main_thread_id_;
Expand Down
1 change: 0 additions & 1 deletion source/common/network/address_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ addressFromSockAddrOrDie(const sockaddr_storage& ss, socklen_t ss_len, os_fd_t f
// address and the socket is actually v6 only, the returned address will be
// regarded as a v6 address from dual stack socket. However, this address is not going to be
// used to create socket. Wrong knowledge of dual stack support won't hurt.
ASSERT(Thread::MainThread::isWorkerThread());
StatusOr<Address::InstanceConstSharedPtr> address =
Address::addressFromSockAddr(ss, ss_len, v6only);
if (!address.ok()) {
Expand Down
2 changes: 0 additions & 2 deletions test/common/thread_local/thread_local_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ namespace ThreadLocal {
TEST(MainThreadVerificationTest, All) {
// Before threading is on, assertion on main thread should be true.
EXPECT_TRUE(Thread::MainThread::isMainThread());
EXPECT_TRUE(Thread::MainThread::isWorkerThread());
{
InstanceImpl tls;
// Tls instance has been initialized.
// Call to main thread verification should succeed in main thread.
EXPECT_TRUE(Thread::MainThread::isMainThread());
EXPECT_FALSE(Thread::MainThread::isWorkerThread());
tls.shutdownGlobalThreading();
tls.shutdownThread();
}
Expand Down

0 comments on commit 956d834

Please sign in to comment.