Skip to content
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

network: remove an assert #18201

Merged
merged 2 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
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