Automated g4 rollback of changelist 443207602. *** Reason for rollback *** Breaks Envoy tests. *** Original change description *** Use QUICHE platform in //third_party/epoll_server *** PiperOrigin-RevId: 443282045
diff --git a/quiche/epoll_server/platform/api/epoll_address_test_utils.h b/quiche/epoll_server/platform/api/epoll_address_test_utils.h new file mode 100644 index 0000000..883d510 --- /dev/null +++ b/quiche/epoll_server/platform/api/epoll_address_test_utils.h
@@ -0,0 +1,16 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_ADDRESS_TEST_UTILS_H_ +#define QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_ADDRESS_TEST_UTILS_H_ + +#include "quiche_platform_impl/epoll_address_test_utils_impl.h" + +namespace epoll_server { + +inline int AddressFamilyUnderTest() { return AddressFamilyUnderTestImpl(); } + +} // namespace epoll_server + +#endif // QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_ADDRESS_TEST_UTILS_H_
diff --git a/quiche/epoll_server/platform/api/epoll_bug.h b/quiche/epoll_server/platform/api/epoll_bug.h new file mode 100644 index 0000000..eeb707a --- /dev/null +++ b/quiche/epoll_server/platform/api/epoll_bug.h
@@ -0,0 +1,12 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_BUG_H_ +#define QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_BUG_H_ + +#include "quiche_platform_impl/epoll_bug_impl.h" + +#define EPOLL_BUG EPOLL_BUG_IMPL + +#endif // QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_BUG_H_
diff --git a/quiche/epoll_server/platform/api/epoll_expect_bug.h b/quiche/epoll_server/platform/api/epoll_expect_bug.h new file mode 100644 index 0000000..36ebd97 --- /dev/null +++ b/quiche/epoll_server/platform/api/epoll_expect_bug.h
@@ -0,0 +1,12 @@ +// Copyright (c) 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_EXPECT_BUG_H_ +#define QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_EXPECT_BUG_H_ + +#include "quiche_platform_impl/epoll_expect_bug_impl.h" + +#define EXPECT_EPOLL_BUG EXPECT_EPOLL_BUG_IMPL + +#endif // QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_EXPECT_BUG_H_
diff --git a/quiche/epoll_server/platform/api/epoll_logging.h b/quiche/epoll_server/platform/api/epoll_logging.h new file mode 100644 index 0000000..2d5a0f4 --- /dev/null +++ b/quiche/epoll_server/platform/api/epoll_logging.h
@@ -0,0 +1,19 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_LOGGING_H_ +#define QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_LOGGING_H_ + +#include "quiche_platform_impl/epoll_logging_impl.h" + +namespace epoll_server { + +#define EPOLL_LOG(severity) EPOLL_LOG_IMPL(severity) +#define EPOLL_VLOG(verbosity) EPOLL_VLOG_IMPL(verbosity) +#define EPOLL_DVLOG(verbosity) EPOLL_DVLOG_IMPL(verbosity) +#define EPOLL_PLOG(severity) EPOLL_PLOG_IMPL(severity) + +} // namespace epoll_server + +#endif // QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_LOGGING_H_
diff --git a/quiche/epoll_server/platform/api/epoll_test.h b/quiche/epoll_server/platform/api/epoll_test.h new file mode 100644 index 0000000..c7f0eea --- /dev/null +++ b/quiche/epoll_server/platform/api/epoll_test.h
@@ -0,0 +1,11 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_TEST_H_ +#define QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_TEST_H_ + +#include "quiche_platform_impl/epoll_test_impl.h" +#define EpollTest EpollTestImpl + +#endif // QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_TEST_H_
diff --git a/quiche/epoll_server/platform/api/epoll_thread.h b/quiche/epoll_server/platform/api/epoll_thread.h new file mode 100644 index 0000000..5b159cb --- /dev/null +++ b/quiche/epoll_server/platform/api/epoll_thread.h
@@ -0,0 +1,27 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_THREAD_H_ +#define QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_THREAD_H_ + +#include <string> + +#include "quiche_platform_impl/epoll_thread_impl.h" + +namespace epoll_server { + +// A class representing a thread of execution in QUIC. +class EpollThread : public EpollThreadImpl { + public: + EpollThread(const std::string& string) : EpollThreadImpl(string) {} + EpollThread(const EpollThread&) = delete; + EpollThread& operator=(const EpollThread&) = delete; + + // Impl defines a virtual void Run() method which subclasses + // must implement. +}; + +} // namespace epoll_server + +#endif // QUICHE_EPOLL_SERVER_PLATFORM_API_EPOLL_THREAD_H_
diff --git a/quiche/epoll_server/simple_epoll_server.cc b/quiche/epoll_server/simple_epoll_server.cc index cd70fb3..eb9d6c4 100644 --- a/quiche/epoll_server/simple_epoll_server.cc +++ b/quiche/epoll_server/simple_epoll_server.cc
@@ -13,7 +13,7 @@ #include <utility> #include "absl/time/clock.h" -#include "quiche/common/platform/api/quiche_bug_tracker.h" +#include "quiche/epoll_server/platform/api/epoll_bug.h" // Design notes: An efficient implementation of ready list has the following // desirable properties: @@ -122,8 +122,8 @@ // call... int saved_errno = errno; char buf[kErrorBufferSize]; - QUICHE_LOG(FATAL) << "Error " << saved_errno << " in pipe(): " - << strerror_r(saved_errno, buf, sizeof(buf)); + EPOLL_LOG(FATAL) << "Error " << saved_errno << " in pipe(): " + << strerror_r(saved_errno, buf, sizeof(buf)); } read_fd_ = pipe_fds[0]; write_fd_ = pipe_fds[1]; @@ -166,9 +166,9 @@ DCHECK_EQ(in_shutdown_, false); in_shutdown_ = true; #ifdef EPOLL_SERVER_EVENT_TRACING - QUICHE_LOG(INFO) << "\n" << event_recorder_; + EPOLL_LOG(INFO) << "\n" << event_recorder_; #endif - QUICHE_VLOG(2) << "Shutting down epoll server "; + EPOLL_VLOG(2) << "Shutting down epoll server "; CleanupFDToCBMap(); LIST_INIT(&ready_list_); @@ -208,7 +208,7 @@ void SimpleEpollServer::RegisterFD(int fd, CB* cb, int event_mask) { CHECK(cb); - QUICHE_VLOG(3) << "RegisterFD fd=" << fd << " event_mask=" << event_mask; + EPOLL_VLOG(3) << "RegisterFD fd=" << fd << " event_mask=" << event_mask; auto fd_i = cb_map_.find(CBAndEventMask(NULL, 0, fd)); if (cb_map_.end() != fd_i) { // do we just abort, or do we just unregister the other callback? @@ -244,9 +244,9 @@ if (flags == -1) { int saved_errno = errno; char buf[kErrorBufferSize]; - QUICHE_LOG(FATAL) << "Error " << saved_errno << " doing fcntl(" << fd - << ", F_GETFL, 0): " - << strerror_r(saved_errno, buf, sizeof(buf)); + EPOLL_LOG(FATAL) << "Error " << saved_errno << " doing fcntl(" << fd + << ", F_GETFL, 0): " + << strerror_r(saved_errno, buf, sizeof(buf)); } if (!(flags & O_NONBLOCK)) { int saved_flags = flags; @@ -255,9 +255,9 @@ // bad. int saved_errno = errno; char buf[kErrorBufferSize]; - QUICHE_LOG(FATAL) << "Error " << saved_errno << " doing fcntl(" << fd - << ", F_SETFL, " << saved_flags - << "): " << strerror_r(saved_errno, buf, sizeof(buf)); + EPOLL_LOG(FATAL) << "Error " << saved_errno << " doing fcntl(" << fd + << ", F_SETFL, " << saved_flags + << "): " << strerror_r(saved_errno, buf, sizeof(buf)); } } } @@ -344,9 +344,9 @@ void SimpleEpollServer::WaitForEventsAndExecuteCallbacks() { if (in_wait_for_events_and_execute_callbacks_) { - QUICHE_LOG(DFATAL) << "Attempting to call WaitForEventsAndExecuteCallbacks" - " when an ancestor to the current function is already" - " WaitForEventsAndExecuteCallbacks!"; + EPOLL_LOG(DFATAL) << "Attempting to call WaitForEventsAndExecuteCallbacks" + " when an ancestor to the current function is already" + " WaitForEventsAndExecuteCallbacks!"; // The line below is actually tested, but in coverage mode, // we never see it. return; // COV_NF_LINE @@ -370,9 +370,9 @@ // Get the first timeout from the alarm_map where it is // stored in absolute time. int64_t next_alarm_time_in_us = alarm_map_.begin()->first; - QUICHE_VLOG(4) << "next_alarm_time = " << next_alarm_time_in_us - << " now = " << now_in_us - << " timeout_in_us = " << timeout_in_us_; + EPOLL_VLOG(4) << "next_alarm_time = " << next_alarm_time_in_us + << " now = " << now_in_us + << " timeout_in_us = " << timeout_in_us_; int64_t wait_time_in_us; int64_t alarm_timeout_in_us = next_alarm_time_in_us - now_in_us; @@ -386,7 +386,7 @@ wait_time_in_us = timeout_in_us_; } - QUICHE_VLOG(4) << "wait_time_in_us = " << wait_time_in_us; + EPOLL_VLOG(4) << "wait_time_in_us = " << wait_time_in_us; // wait for events. @@ -442,10 +442,10 @@ } void SimpleEpollServer::RegisterAlarm(int64_t timeout_time_in_us, AlarmCB* ac) { - QUICHE_VLOG(4) << "RegisteringAlarm " << ac << " at : " << timeout_time_in_us; + EPOLL_VLOG(4) << "RegisteringAlarm " << ac << " at : " << timeout_time_in_us; CHECK(ac); if (all_alarms_.find(ac) != all_alarms_.end()) { - QUICHE_BUG(epoll_bug_1_1) << "Alarm already exists"; + EPOLL_BUG(epoll_bug_1_1) << "Alarm already exists"; } auto alarm_iter = alarm_map_.insert(std::make_pair(timeout_time_in_us, ac)); @@ -459,7 +459,7 @@ // valid iterator. The caller must ensure the validity of the iterator. void SimpleEpollServer::UnregisterAlarm(const AlarmRegToken& iterator_token) { AlarmCB* cb = iterator_token->second; - QUICHE_VLOG(4) << "UnregisteringAlarm " << cb; + EPOLL_VLOG(4) << "UnregisteringAlarm " << cb; alarm_map_.erase(iterator_token); all_alarms_.erase(cb); cb->OnUnregistration(); @@ -514,28 +514,27 @@ } void SimpleEpollServer::LogStateOnCrash() { - QUICHE_LOG(ERROR) + EPOLL_LOG(ERROR) << "-------------------Epoll Server-------------------------"; - QUICHE_LOG(ERROR) << "Epoll server " << this << " polling on fd " - << epoll_fd_; - QUICHE_LOG(ERROR) << "timeout_in_us_: " << timeout_in_us_; + EPOLL_LOG(ERROR) << "Epoll server " << this << " polling on fd " << epoll_fd_; + EPOLL_LOG(ERROR) << "timeout_in_us_: " << timeout_in_us_; // Log sessions with alarms. - QUICHE_LOG(ERROR) << alarm_map_.size() << " alarms registered."; + EPOLL_LOG(ERROR) << alarm_map_.size() << " alarms registered."; for (auto it = alarm_map_.begin(); it != alarm_map_.end(); ++it) { const bool skipped = alarms_reregistered_and_should_be_skipped_.find(it->second) != alarms_reregistered_and_should_be_skipped_.end(); - QUICHE_LOG(ERROR) << "Alarm " << it->second << " registered at time " - << it->first << " and should be skipped = " << skipped; + EPOLL_LOG(ERROR) << "Alarm " << it->second << " registered at time " + << it->first << " and should be skipped = " << skipped; } - QUICHE_LOG(ERROR) << cb_map_.size() << " fd callbacks registered."; + EPOLL_LOG(ERROR) << cb_map_.size() << " fd callbacks registered."; for (auto it = cb_map_.begin(); it != cb_map_.end(); ++it) { - QUICHE_LOG(ERROR) << "fd: " << it->fd << " with mask " << it->event_mask - << " registered with cb: " << it->cb; + EPOLL_LOG(ERROR) << "fd: " << it->fd << " with mask " << it->event_mask + << " registered with cb: " << it->cb; } - QUICHE_LOG(ERROR) + EPOLL_LOG(ERROR) << "-------------------/Epoll Server------------------------"; } @@ -551,8 +550,8 @@ if (epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, fd, &ee)) { int saved_errno = errno; char buf[kErrorBufferSize]; - QUICHE_LOG(FATAL) << "Epoll set removal error for fd " << fd << ": " - << strerror_r(saved_errno, buf, sizeof(buf)); + EPOLL_LOG(FATAL) << "Epoll set removal error for fd " << fd << ": " + << strerror_r(saved_errno, buf, sizeof(buf)); } } @@ -569,8 +568,8 @@ if (epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, fd, &ee)) { int saved_errno = errno; char buf[kErrorBufferSize]; - QUICHE_LOG(FATAL) << "Epoll set insertion error for fd " << fd << ": " - << strerror_r(saved_errno, buf, sizeof(buf)); + EPOLL_LOG(FATAL) << "Epoll set insertion error for fd " << fd << ": " + << strerror_r(saved_errno, buf, sizeof(buf)); } } @@ -584,13 +583,13 @@ #ifdef EPOLL_SERVER_EVENT_TRACING event_recorder_.RecordFDMaskEvent(fd, ee.events, "ModFD"); #endif - QUICHE_VLOG(3) << "modifying fd= " << fd << " " - << EventMaskToString(ee.events); + EPOLL_VLOG(3) << "modifying fd= " << fd << " " + << EventMaskToString(ee.events); if (epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, fd, &ee)) { int saved_errno = errno; char buf[kErrorBufferSize]; - QUICHE_LOG(FATAL) << "Epoll set modification error for fd " << fd << ": " - << strerror_r(saved_errno, buf, sizeof(buf)); + EPOLL_LOG(FATAL) << "Epoll set modification error for fd " << fd << ": " + << strerror_r(saved_errno, buf, sizeof(buf)); } } @@ -599,18 +598,18 @@ void SimpleEpollServer::ModifyFD(int fd, int remove_event, int add_event) { auto fd_i = cb_map_.find(CBAndEventMask(NULL, 0, fd)); if (cb_map_.end() == fd_i) { - QUICHE_VLOG(2) << "Didn't find the fd " << fd << "in internal structures"; + EPOLL_VLOG(2) << "Didn't find the fd " << fd << "in internal structures"; return; } if (fd_i->cb != NULL) { int& event_mask = fd_i->event_mask; - QUICHE_VLOG(3) << "fd= " << fd - << " event_mask before: " << EventMaskToString(event_mask); + EPOLL_VLOG(3) << "fd= " << fd + << " event_mask before: " << EventMaskToString(event_mask); event_mask &= ~remove_event; event_mask |= add_event; - QUICHE_VLOG(3) << " event_mask after: " << EventMaskToString(event_mask); + EPOLL_VLOG(3) << " event_mask after: " << EventMaskToString(event_mask); ModFD(fd, event_mask); @@ -624,8 +623,8 @@ // If ready list is not empty, then don't sleep at all. timeout_in_us = 0; } else if (timeout_in_us < 0) { - QUICHE_LOG(INFO) << "Negative epoll timeout: " << timeout_in_us - << "us; epoll will wait forever for events."; + EPOLL_LOG(INFO) << "Negative epoll timeout: " << timeout_in_us + << "us; epoll will wait forever for events."; // If timeout_in_us is < 0 we are supposed to Wait forever. This means we // should set timeout_in_us to -1000 so we will // Wait(-1000/1000) == Wait(-1) == Wait forever. @@ -640,7 +639,7 @@ int64_t expected_wakeup_us = NowInUsec() + timeout_in_us; int nfds = epoll_wait_impl(epoll_fd_, events, events_size, timeout_in_ms); - QUICHE_VLOG(3) << "nfds=" << nfds; + EPOLL_VLOG(3) << "nfds=" << nfds; #ifdef EPOLL_SERVER_EVENT_TRACING event_recorder_.RecordEpollWaitEvent(timeout_in_ms, nfds); @@ -675,8 +674,8 @@ if (errno != EINTR && errno != 0) { int saved_errno = errno; char buf[kErrorBufferSize]; - QUICHE_LOG(FATAL) << "Error " << saved_errno << " in epoll_wait: " - << strerror_r(saved_errno, buf, sizeof(buf)); + EPOLL_LOG(FATAL) << "Error " << saved_errno << " in epoll_wait: " + << strerror_r(saved_errno, buf, sizeof(buf)); } } @@ -762,9 +761,9 @@ // if timeout is > now_in_us then we have no fear that this alarm // can be reexecuted in this loop, and hence we do not need to // worry about a recursive loop. - QUICHE_DVLOG(3) << "Reregistering alarm " - << " " << cb << " " << new_timeout_time_in_us << " " - << now_in_us; + EPOLL_DVLOG(3) << "Reregistering alarm " + << " " << cb << " " << new_timeout_time_in_us << " " + << now_in_us; if (new_timeout_time_in_us <= now_in_us) { alarms_reregistered_and_should_be_skipped_.insert(cb); }
diff --git a/quiche/epoll_server/simple_epoll_server.h b/quiche/epoll_server/simple_epoll_server.h index a04eefc..405e306 100644 --- a/quiche/epoll_server/simple_epoll_server.h +++ b/quiche/epoll_server/simple_epoll_server.h
@@ -37,7 +37,7 @@ #include <sys/epoll.h> -#include "quiche/common/platform/api/quiche_logging.h" +#include "quiche/epoll_server/platform/api/epoll_logging.h" namespace epoll_server { @@ -456,7 +456,7 @@ static std::string EventMaskToString(int event_mask); // Summary: - // Logs the state of the epoll server with QUICHE_LOG(ERROR). + // Logs the state of the epoll server with EPOLL_LOG(ERROR). void LogStateOnCrash(); // Summary: @@ -724,10 +724,10 @@ // When a number of events equals the record threshold, // the collected data summary for all FDs will be written - // to QUICHE_LOG(INFO). Note that this does not include the + // to EPOLL_LOG(INFO). Note that this does not include the // individual events (if you'reinterested in those, you'll // have to get at them programmatically). - // After any such flushing to QUICHE_LOG(INFO) all events will + // After any such flushing to EPOLL_LOG(INFO) all events will // be cleared. // Note that the definition of an 'event' is a bit 'hazy', // as it includes the 'Unregistration' event, and perhaps @@ -748,7 +748,7 @@ void MaybeRecordAndClear() { ++num_records_; if ((num_records_ > record_threshold_) && (record_threshold_ > 0)) { - QUICHE_LOG(INFO) << "\n" << *this; + EPOLL_LOG(INFO) << "\n" << *this; num_records_ = 0; Clear(); }
diff --git a/quiche/epoll_server/simple_epoll_server_test.cc b/quiche/epoll_server/simple_epoll_server_test.cc index dd24c06..ba85038 100644 --- a/quiche/epoll_server/simple_epoll_server_test.cc +++ b/quiche/epoll_server/simple_epoll_server_test.cc
@@ -26,10 +26,10 @@ #include "absl/time/clock.h" #include "quiche/epoll_server/fake_simple_epoll_server.h" -#include "quiche/common/platform/api/quiche_expect_bug.h" -#include "quiche/common/platform/api/quiche_test.h" -#include "quiche/common/platform/api/quiche_test_loopback.h" -#include "quiche/common/platform/api/quiche_thread.h" +#include "quiche/epoll_server/platform/api/epoll_address_test_utils.h" +#include "quiche/epoll_server/platform/api/epoll_expect_bug.h" +#include "quiche/epoll_server/platform/api/epoll_test.h" +#include "quiche/epoll_server/platform/api/epoll_thread.h" namespace epoll_server { @@ -80,23 +80,23 @@ if (instance != entry->instance) { retval = false; - QUICHE_LOG(INFO) << " instance (" << instance << ") != entry->instance(" - << entry->instance << ")"; + EPOLL_LOG(INFO) << " instance (" << instance << ") != entry->instance(" + << entry->instance << ")"; } if (event_type != entry->event_type) { retval = false; - QUICHE_LOG(INFO) << " event_type (" << event_type - << ") != entry->event_type(" << entry->event_type << ")"; + EPOLL_LOG(INFO) << " event_type (" << event_type + << ") != entry->event_type(" << entry->event_type << ")"; } if (fd != entry->fd) { retval = false; - QUICHE_LOG(INFO) << " fd (" << fd << ") != entry->fd (" << entry->fd - << ")"; + EPOLL_LOG(INFO) << " fd (" << fd << ") != entry->fd (" << entry->fd + << ")"; } if (data != entry->data) { retval = false; - QUICHE_LOG(INFO) << " data (" << data << ") != entry->data(" - << entry->data << ")"; + EPOLL_LOG(INFO) << " data (" << data << ") != entry->data(" << entry->data + << ")"; } return retval; } @@ -118,14 +118,13 @@ const std::vector<RecordEntry>* records = recorder->records(); if (records_.size() != records->size()) { - QUICHE_LOG(INFO) << "records_.size() (" << records_.size() - << ") != records->size() (" << records->size() << ")"; + EPOLL_LOG(INFO) << "records_.size() (" << records_.size() + << ") != records->size() (" << records->size() << ")"; return false; } for (size_t i = 0; i < std::min(records_.size(), records->size()); ++i) { if (!records_[i].IsEqual(&(*records)[i])) { - QUICHE_LOG(INFO) << "entry in index: " << i - << " differs from recorder."; + EPOLL_LOG(INFO) << "entry in index: " << i << " differs from recorder."; return false; } } @@ -241,7 +240,7 @@ using SimpleEpollServer::WaitForEventsAndCallHandleEvents; }; -class EpollFunctionTest : public QuicheTest { +class EpollFunctionTest : public EpollTest { public: EpollFunctionTest() : fd_(-1), fd2_(-1), recorder_(nullptr), cb_(nullptr), ep_(nullptr) {} @@ -260,7 +259,7 @@ int pipe_fds[2]; if (pipe(pipe_fds) < 0) { - QUICHE_PLOG(FATAL) << "pipe() failed"; + EPOLL_PLOG(FATAL) << "pipe() failed"; } fd_ = pipe_fds[0]; fd2_ = pipe_fds[1]; @@ -291,11 +290,7 @@ }; TEST_F(EpollFunctionTest, TestUnconnectedSocket) { - int fd = - socket((quiche::AddressFamilyUnderTest() == quic::IpAddressFamily::IP_V6) - ? AF_INET6 - : AF_INET, - SOCK_STREAM, IPPROTO_TCP); + int fd = socket(AddressFamilyUnderTest(), SOCK_STREAM, IPPROTO_TCP); ep()->RegisterFD(fd, cb(), EPOLLIN | EPOLLOUT); ep()->WaitForEventsAndExecuteCallbacks(); @@ -1360,7 +1355,7 @@ int pipe_fds[2]; if (pipe(pipe_fds) < 0) { - QUICHE_PLOG(FATAL) << "pipe() failed"; + EPOLL_PLOG(FATAL) << "pipe() failed"; } int read_fd = pipe_fds[0]; int write_fd = pipe_fds[1]; @@ -1421,7 +1416,7 @@ int pipe_fds[2]; if (pipe(pipe_fds) < 0) { - QUICHE_PLOG(FATAL) << "pipe() failed"; + EPOLL_PLOG(FATAL) << "pipe() failed"; } int read_fd = pipe_fds[0]; int write_fd = pipe_fds[1]; @@ -1453,11 +1448,11 @@ int pipe_one[2]; if (pipe(pipe_one) < 0) { - QUICHE_PLOG(FATAL) << "pipe() failed"; + EPOLL_PLOG(FATAL) << "pipe() failed"; } int pipe_two[2]; if (pipe(pipe_two) < 0) { - QUICHE_PLOG(FATAL) << "pipe() failed"; + EPOLL_PLOG(FATAL) << "pipe() failed"; } RecordingCB recording_cb_one; @@ -1504,7 +1499,7 @@ TEST(SimpleEpollServerTest, TestFDOnShutdown) { int pipe_fds[2]; if (pipe(pipe_fds) < 0) { - QUICHE_PLOG(FATAL) << "pipe() failed"; + EPOLL_PLOG(FATAL) << "pipe() failed"; } int read_fd = pipe_fds[0]; int write_fd = pipe_fds[1]; @@ -1579,7 +1574,7 @@ TEST(SimpleEpollServerTest, TestUnregisteringFDsOnShutdown) { int pipe_fds[2]; if (pipe(pipe_fds) < 0) { - QUICHE_PLOG(FATAL) << "pipe() failed"; + EPOLL_PLOG(FATAL) << "pipe() failed"; } int read_fd = pipe_fds[0]; int write_fd = pipe_fds[1]; @@ -1616,7 +1611,7 @@ int pipe_fds[2]; if (pipe(pipe_fds) < 0) { - QUICHE_PLOG(FATAL) << "pipe() failed"; + EPOLL_PLOG(FATAL) << "pipe() failed"; } RecordingCB recording_cb; @@ -1688,7 +1683,7 @@ void OnShutdown(SimpleEpollServer* /*eps*/, int /*fd*/) override { // None of the current tests involve having active callbacks when the // server shuts down. - QUICHE_LOG(FATAL); + EPOLL_LOG(FATAL); } std::string Name() const override { return "EpollReader"; } @@ -1713,7 +1708,7 @@ void TestPipe(char* test_message, int len) { int pipe_fds[2]; if (pipe(pipe_fds) < 0) { - QUICHE_PLOG(FATAL) << "pipe failed()"; + EPOLL_PLOG(FATAL) << "pipe failed()"; } int reader_pipe = pipe_fds[0]; int writer_pipe = pipe_fds[1]; @@ -1733,14 +1728,14 @@ } } if (len > 0) { - QUICHE_PLOG(FATAL) << "write() failed"; + EPOLL_PLOG(FATAL) << "write() failed"; } close(writer_pipe); _exit(0); } case -1: - QUICHE_PLOG(FATAL) << "fork() failed"; + EPOLL_PLOG(FATAL) << "fork() failed"; break; default: { // Parent will receive message. close(writer_pipe); @@ -1783,7 +1778,7 @@ int pipe_fds[2]; if (pipe(pipe_fds) < 0) { - QUICHE_PLOG(FATAL) << "pipe() failed"; + EPOLL_PLOG(FATAL) << "pipe() failed"; } int read_fd = pipe_fds[0]; int write_fd = pipe_fds[1]; @@ -1880,12 +1875,12 @@ if (len > 0) { bytes_read_ += len; - QUICHE_VLOG(1) << "fd: " << fd << ", read " << len - << ", total: " << bytes_read_; + EPOLL_VLOG(1) << "fd: " << fd << ", read " << len + << ", total: " << bytes_read_; // Now check the bytes read EXPECT_TRUE(CheckReadBuffer(len)); } else if (len < 0) { - QUICHE_VLOG(1) << "fd: " << fd << " read hit EAGAIN"; + EPOLL_VLOG(1) << "fd: " << fd << " read hit EAGAIN"; EXPECT_EQ(EAGAIN, errno) << strerror(errno); can_read_ = false; } else { @@ -1901,10 +1896,10 @@ can_write_ = (len == write_size); if (len > 0) { bytes_written_ += len; - QUICHE_VLOG(1) << "fd: " << fd << ", write " << len - << ", total: " << bytes_written_; + EPOLL_VLOG(1) << "fd: " << fd << ", write " << len + << ", total: " << bytes_written_; } else { - QUICHE_VLOG(1) << "fd: " << fd << " write hit EAGAIN"; + EPOLL_VLOG(1) << "fd: " << fd << " write hit EAGAIN"; EXPECT_EQ(EAGAIN, errno) << strerror(errno); can_write_ = false; } @@ -1926,7 +1921,7 @@ void OnShutdown(SimpleEpollServer* /*eps*/, int /*fd*/) override { // None of the current tests involve having active callbacks when the // server shuts down. - QUICHE_LOG(FATAL); + EPOLL_LOG(FATAL); } std::string Name() const override { return "EdgeTriggerCB"; } @@ -1977,7 +1972,7 @@ SimpleEpollServer ep; int pipe_fds[2]; if (pipe(pipe_fds) < 0) { - QUICHE_PLOG(FATAL) << "pipe() failed"; + EPOLL_PLOG(FATAL) << "pipe() failed"; } // Just use any CB will do, since we never wait on epoll events. @@ -2019,10 +2014,10 @@ close(pipe_fds[1]); } -class EPSWaitThread : public quiche::QuicheThread { +class EPSWaitThread : public EpollThread { public: explicit EPSWaitThread(SimpleEpollServer* eps) - : QuicheThread("EPSWait"), eps_(eps), done_(false) {} + : EpollThread("EPSWait"), eps_(eps), done_(false) {} void Run() override { eps_->WaitForEventsAndExecuteCallbacks(); } @@ -2488,8 +2483,8 @@ TestAlarm alarm; SimpleEpollServer epoll_server; epoll_server.RegisterAlarm(1, &alarm); - EXPECT_QUICHE_BUG(epoll_server.RegisterAlarm(1, &alarm), - "Alarm already exists"); + EXPECT_EPOLL_BUG(epoll_server.RegisterAlarm(1, &alarm), + "Alarm already exists"); } } // namespace