Use QUICHE platform in //third_party/epoll_server
PiperOrigin-RevId: 443207602
diff --git a/quiche/epoll_server/platform/api/epoll_address_test_utils.h b/quiche/epoll_server/platform/api/epoll_address_test_utils.h
deleted file mode 100644
index 0693c00..0000000
--- a/quiche/epoll_server/platform/api/epoll_address_test_utils.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// 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 {
-
-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
deleted file mode 100644
index eeb707a..0000000
--- a/quiche/epoll_server/platform/api/epoll_bug.h
+++ /dev/null
@@ -1,12 +0,0 @@
-// 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
deleted file mode 100644
index 36ebd97..0000000
--- a/quiche/epoll_server/platform/api/epoll_expect_bug.h
+++ /dev/null
@@ -1,12 +0,0 @@
-// 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
deleted file mode 100644
index 2d5a0f4..0000000
--- a/quiche/epoll_server/platform/api/epoll_logging.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// 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
deleted file mode 100644
index c7f0eea..0000000
--- a/quiche/epoll_server/platform/api/epoll_test.h
+++ /dev/null
@@ -1,11 +0,0 @@
-// 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
deleted file mode 100644
index 5b159cb..0000000
--- a/quiche/epoll_server/platform/api/epoll_thread.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// 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 eb9d6c4..cd70fb3 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/epoll_server/platform/api/epoll_bug.h"
+#include "quiche/common/platform/api/quiche_bug_tracker.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];
- EPOLL_LOG(FATAL) << "Error " << saved_errno << " in pipe(): "
- << strerror_r(saved_errno, buf, sizeof(buf));
+ QUICHE_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
- EPOLL_LOG(INFO) << "\n" << event_recorder_;
+ QUICHE_LOG(INFO) << "\n" << event_recorder_;
#endif
- EPOLL_VLOG(2) << "Shutting down epoll server ";
+ QUICHE_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);
- EPOLL_VLOG(3) << "RegisterFD fd=" << fd << " event_mask=" << event_mask;
+ QUICHE_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];
- EPOLL_LOG(FATAL) << "Error " << saved_errno << " doing fcntl(" << fd
- << ", F_GETFL, 0): "
- << strerror_r(saved_errno, buf, sizeof(buf));
+ QUICHE_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];
- EPOLL_LOG(FATAL) << "Error " << saved_errno << " doing fcntl(" << fd
- << ", F_SETFL, " << saved_flags
- << "): " << strerror_r(saved_errno, buf, sizeof(buf));
+ QUICHE_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_) {
- EPOLL_LOG(DFATAL) << "Attempting to call WaitForEventsAndExecuteCallbacks"
- " when an ancestor to the current function is already"
- " WaitForEventsAndExecuteCallbacks!";
+ QUICHE_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;
- EPOLL_VLOG(4) << "next_alarm_time = " << next_alarm_time_in_us
- << " now = " << now_in_us
- << " timeout_in_us = " << timeout_in_us_;
+ QUICHE_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_;
}
- EPOLL_VLOG(4) << "wait_time_in_us = " << wait_time_in_us;
+ QUICHE_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) {
- EPOLL_VLOG(4) << "RegisteringAlarm " << ac << " at : " << timeout_time_in_us;
+ QUICHE_VLOG(4) << "RegisteringAlarm " << ac << " at : " << timeout_time_in_us;
CHECK(ac);
if (all_alarms_.find(ac) != all_alarms_.end()) {
- EPOLL_BUG(epoll_bug_1_1) << "Alarm already exists";
+ QUICHE_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;
- EPOLL_VLOG(4) << "UnregisteringAlarm " << cb;
+ QUICHE_VLOG(4) << "UnregisteringAlarm " << cb;
alarm_map_.erase(iterator_token);
all_alarms_.erase(cb);
cb->OnUnregistration();
@@ -514,27 +514,28 @@
}
void SimpleEpollServer::LogStateOnCrash() {
- EPOLL_LOG(ERROR)
+ QUICHE_LOG(ERROR)
<< "-------------------Epoll Server-------------------------";
- EPOLL_LOG(ERROR) << "Epoll server " << this << " polling on fd " << epoll_fd_;
- EPOLL_LOG(ERROR) << "timeout_in_us_: " << timeout_in_us_;
+ QUICHE_LOG(ERROR) << "Epoll server " << this << " polling on fd "
+ << epoll_fd_;
+ QUICHE_LOG(ERROR) << "timeout_in_us_: " << timeout_in_us_;
// Log sessions with alarms.
- EPOLL_LOG(ERROR) << alarm_map_.size() << " alarms registered.";
+ QUICHE_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();
- EPOLL_LOG(ERROR) << "Alarm " << it->second << " registered at time "
- << it->first << " and should be skipped = " << skipped;
+ QUICHE_LOG(ERROR) << "Alarm " << it->second << " registered at time "
+ << it->first << " and should be skipped = " << skipped;
}
- EPOLL_LOG(ERROR) << cb_map_.size() << " fd callbacks registered.";
+ QUICHE_LOG(ERROR) << cb_map_.size() << " fd callbacks registered.";
for (auto it = cb_map_.begin(); it != cb_map_.end(); ++it) {
- EPOLL_LOG(ERROR) << "fd: " << it->fd << " with mask " << it->event_mask
- << " registered with cb: " << it->cb;
+ QUICHE_LOG(ERROR) << "fd: " << it->fd << " with mask " << it->event_mask
+ << " registered with cb: " << it->cb;
}
- EPOLL_LOG(ERROR)
+ QUICHE_LOG(ERROR)
<< "-------------------/Epoll Server------------------------";
}
@@ -550,8 +551,8 @@
if (epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, fd, &ee)) {
int saved_errno = errno;
char buf[kErrorBufferSize];
- EPOLL_LOG(FATAL) << "Epoll set removal error for fd " << fd << ": "
- << strerror_r(saved_errno, buf, sizeof(buf));
+ QUICHE_LOG(FATAL) << "Epoll set removal error for fd " << fd << ": "
+ << strerror_r(saved_errno, buf, sizeof(buf));
}
}
@@ -568,8 +569,8 @@
if (epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, fd, &ee)) {
int saved_errno = errno;
char buf[kErrorBufferSize];
- EPOLL_LOG(FATAL) << "Epoll set insertion error for fd " << fd << ": "
- << strerror_r(saved_errno, buf, sizeof(buf));
+ QUICHE_LOG(FATAL) << "Epoll set insertion error for fd " << fd << ": "
+ << strerror_r(saved_errno, buf, sizeof(buf));
}
}
@@ -583,13 +584,13 @@
#ifdef EPOLL_SERVER_EVENT_TRACING
event_recorder_.RecordFDMaskEvent(fd, ee.events, "ModFD");
#endif
- EPOLL_VLOG(3) << "modifying fd= " << fd << " "
- << EventMaskToString(ee.events);
+ QUICHE_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];
- EPOLL_LOG(FATAL) << "Epoll set modification error for fd " << fd << ": "
- << strerror_r(saved_errno, buf, sizeof(buf));
+ QUICHE_LOG(FATAL) << "Epoll set modification error for fd " << fd << ": "
+ << strerror_r(saved_errno, buf, sizeof(buf));
}
}
@@ -598,18 +599,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) {
- EPOLL_VLOG(2) << "Didn't find the fd " << fd << "in internal structures";
+ QUICHE_VLOG(2) << "Didn't find the fd " << fd << "in internal structures";
return;
}
if (fd_i->cb != NULL) {
int& event_mask = fd_i->event_mask;
- EPOLL_VLOG(3) << "fd= " << fd
- << " event_mask before: " << EventMaskToString(event_mask);
+ QUICHE_VLOG(3) << "fd= " << fd
+ << " event_mask before: " << EventMaskToString(event_mask);
event_mask &= ~remove_event;
event_mask |= add_event;
- EPOLL_VLOG(3) << " event_mask after: " << EventMaskToString(event_mask);
+ QUICHE_VLOG(3) << " event_mask after: " << EventMaskToString(event_mask);
ModFD(fd, event_mask);
@@ -623,8 +624,8 @@
// If ready list is not empty, then don't sleep at all.
timeout_in_us = 0;
} else if (timeout_in_us < 0) {
- EPOLL_LOG(INFO) << "Negative epoll timeout: " << timeout_in_us
- << "us; epoll will wait forever for events.";
+ QUICHE_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.
@@ -639,7 +640,7 @@
int64_t expected_wakeup_us = NowInUsec() + timeout_in_us;
int nfds = epoll_wait_impl(epoll_fd_, events, events_size, timeout_in_ms);
- EPOLL_VLOG(3) << "nfds=" << nfds;
+ QUICHE_VLOG(3) << "nfds=" << nfds;
#ifdef EPOLL_SERVER_EVENT_TRACING
event_recorder_.RecordEpollWaitEvent(timeout_in_ms, nfds);
@@ -674,8 +675,8 @@
if (errno != EINTR && errno != 0) {
int saved_errno = errno;
char buf[kErrorBufferSize];
- EPOLL_LOG(FATAL) << "Error " << saved_errno << " in epoll_wait: "
- << strerror_r(saved_errno, buf, sizeof(buf));
+ QUICHE_LOG(FATAL) << "Error " << saved_errno << " in epoll_wait: "
+ << strerror_r(saved_errno, buf, sizeof(buf));
}
}
@@ -761,9 +762,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.
- EPOLL_DVLOG(3) << "Reregistering alarm "
- << " " << cb << " " << new_timeout_time_in_us << " "
- << now_in_us;
+ QUICHE_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 405e306..a04eefc 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/epoll_server/platform/api/epoll_logging.h"
+#include "quiche/common/platform/api/quiche_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 EPOLL_LOG(ERROR).
+ // Logs the state of the epoll server with QUICHE_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 EPOLL_LOG(INFO). Note that this does not include the
+ // to QUICHE_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 EPOLL_LOG(INFO) all events will
+ // After any such flushing to QUICHE_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)) {
- EPOLL_LOG(INFO) << "\n" << *this;
+ QUICHE_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 ba85038..dd24c06 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/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"
+#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"
namespace epoll_server {
@@ -80,23 +80,23 @@
if (instance != entry->instance) {
retval = false;
- EPOLL_LOG(INFO) << " instance (" << instance << ") != entry->instance("
- << entry->instance << ")";
+ QUICHE_LOG(INFO) << " instance (" << instance << ") != entry->instance("
+ << entry->instance << ")";
}
if (event_type != entry->event_type) {
retval = false;
- EPOLL_LOG(INFO) << " event_type (" << event_type
- << ") != entry->event_type(" << entry->event_type << ")";
+ QUICHE_LOG(INFO) << " event_type (" << event_type
+ << ") != entry->event_type(" << entry->event_type << ")";
}
if (fd != entry->fd) {
retval = false;
- EPOLL_LOG(INFO) << " fd (" << fd << ") != entry->fd (" << entry->fd
- << ")";
+ QUICHE_LOG(INFO) << " fd (" << fd << ") != entry->fd (" << entry->fd
+ << ")";
}
if (data != entry->data) {
retval = false;
- EPOLL_LOG(INFO) << " data (" << data << ") != entry->data(" << entry->data
- << ")";
+ QUICHE_LOG(INFO) << " data (" << data << ") != entry->data("
+ << entry->data << ")";
}
return retval;
}
@@ -118,13 +118,14 @@
const std::vector<RecordEntry>* records = recorder->records();
if (records_.size() != records->size()) {
- EPOLL_LOG(INFO) << "records_.size() (" << records_.size()
- << ") != records->size() (" << records->size() << ")";
+ QUICHE_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])) {
- EPOLL_LOG(INFO) << "entry in index: " << i << " differs from recorder.";
+ QUICHE_LOG(INFO) << "entry in index: " << i
+ << " differs from recorder.";
return false;
}
}
@@ -240,7 +241,7 @@
using SimpleEpollServer::WaitForEventsAndCallHandleEvents;
};
-class EpollFunctionTest : public EpollTest {
+class EpollFunctionTest : public QuicheTest {
public:
EpollFunctionTest()
: fd_(-1), fd2_(-1), recorder_(nullptr), cb_(nullptr), ep_(nullptr) {}
@@ -259,7 +260,7 @@
int pipe_fds[2];
if (pipe(pipe_fds) < 0) {
- EPOLL_PLOG(FATAL) << "pipe() failed";
+ QUICHE_PLOG(FATAL) << "pipe() failed";
}
fd_ = pipe_fds[0];
fd2_ = pipe_fds[1];
@@ -290,7 +291,11 @@
};
TEST_F(EpollFunctionTest, TestUnconnectedSocket) {
- int fd = socket(AddressFamilyUnderTest(), SOCK_STREAM, IPPROTO_TCP);
+ int fd =
+ socket((quiche::AddressFamilyUnderTest() == quic::IpAddressFamily::IP_V6)
+ ? AF_INET6
+ : AF_INET,
+ SOCK_STREAM, IPPROTO_TCP);
ep()->RegisterFD(fd, cb(), EPOLLIN | EPOLLOUT);
ep()->WaitForEventsAndExecuteCallbacks();
@@ -1355,7 +1360,7 @@
int pipe_fds[2];
if (pipe(pipe_fds) < 0) {
- EPOLL_PLOG(FATAL) << "pipe() failed";
+ QUICHE_PLOG(FATAL) << "pipe() failed";
}
int read_fd = pipe_fds[0];
int write_fd = pipe_fds[1];
@@ -1416,7 +1421,7 @@
int pipe_fds[2];
if (pipe(pipe_fds) < 0) {
- EPOLL_PLOG(FATAL) << "pipe() failed";
+ QUICHE_PLOG(FATAL) << "pipe() failed";
}
int read_fd = pipe_fds[0];
int write_fd = pipe_fds[1];
@@ -1448,11 +1453,11 @@
int pipe_one[2];
if (pipe(pipe_one) < 0) {
- EPOLL_PLOG(FATAL) << "pipe() failed";
+ QUICHE_PLOG(FATAL) << "pipe() failed";
}
int pipe_two[2];
if (pipe(pipe_two) < 0) {
- EPOLL_PLOG(FATAL) << "pipe() failed";
+ QUICHE_PLOG(FATAL) << "pipe() failed";
}
RecordingCB recording_cb_one;
@@ -1499,7 +1504,7 @@
TEST(SimpleEpollServerTest, TestFDOnShutdown) {
int pipe_fds[2];
if (pipe(pipe_fds) < 0) {
- EPOLL_PLOG(FATAL) << "pipe() failed";
+ QUICHE_PLOG(FATAL) << "pipe() failed";
}
int read_fd = pipe_fds[0];
int write_fd = pipe_fds[1];
@@ -1574,7 +1579,7 @@
TEST(SimpleEpollServerTest, TestUnregisteringFDsOnShutdown) {
int pipe_fds[2];
if (pipe(pipe_fds) < 0) {
- EPOLL_PLOG(FATAL) << "pipe() failed";
+ QUICHE_PLOG(FATAL) << "pipe() failed";
}
int read_fd = pipe_fds[0];
int write_fd = pipe_fds[1];
@@ -1611,7 +1616,7 @@
int pipe_fds[2];
if (pipe(pipe_fds) < 0) {
- EPOLL_PLOG(FATAL) << "pipe() failed";
+ QUICHE_PLOG(FATAL) << "pipe() failed";
}
RecordingCB recording_cb;
@@ -1683,7 +1688,7 @@
void OnShutdown(SimpleEpollServer* /*eps*/, int /*fd*/) override {
// None of the current tests involve having active callbacks when the
// server shuts down.
- EPOLL_LOG(FATAL);
+ QUICHE_LOG(FATAL);
}
std::string Name() const override { return "EpollReader"; }
@@ -1708,7 +1713,7 @@
void TestPipe(char* test_message, int len) {
int pipe_fds[2];
if (pipe(pipe_fds) < 0) {
- EPOLL_PLOG(FATAL) << "pipe failed()";
+ QUICHE_PLOG(FATAL) << "pipe failed()";
}
int reader_pipe = pipe_fds[0];
int writer_pipe = pipe_fds[1];
@@ -1728,14 +1733,14 @@
}
}
if (len > 0) {
- EPOLL_PLOG(FATAL) << "write() failed";
+ QUICHE_PLOG(FATAL) << "write() failed";
}
close(writer_pipe);
_exit(0);
}
case -1:
- EPOLL_PLOG(FATAL) << "fork() failed";
+ QUICHE_PLOG(FATAL) << "fork() failed";
break;
default: { // Parent will receive message.
close(writer_pipe);
@@ -1778,7 +1783,7 @@
int pipe_fds[2];
if (pipe(pipe_fds) < 0) {
- EPOLL_PLOG(FATAL) << "pipe() failed";
+ QUICHE_PLOG(FATAL) << "pipe() failed";
}
int read_fd = pipe_fds[0];
int write_fd = pipe_fds[1];
@@ -1875,12 +1880,12 @@
if (len > 0) {
bytes_read_ += len;
- EPOLL_VLOG(1) << "fd: " << fd << ", read " << len
- << ", total: " << bytes_read_;
+ QUICHE_VLOG(1) << "fd: " << fd << ", read " << len
+ << ", total: " << bytes_read_;
// Now check the bytes read
EXPECT_TRUE(CheckReadBuffer(len));
} else if (len < 0) {
- EPOLL_VLOG(1) << "fd: " << fd << " read hit EAGAIN";
+ QUICHE_VLOG(1) << "fd: " << fd << " read hit EAGAIN";
EXPECT_EQ(EAGAIN, errno) << strerror(errno);
can_read_ = false;
} else {
@@ -1896,10 +1901,10 @@
can_write_ = (len == write_size);
if (len > 0) {
bytes_written_ += len;
- EPOLL_VLOG(1) << "fd: " << fd << ", write " << len
- << ", total: " << bytes_written_;
+ QUICHE_VLOG(1) << "fd: " << fd << ", write " << len
+ << ", total: " << bytes_written_;
} else {
- EPOLL_VLOG(1) << "fd: " << fd << " write hit EAGAIN";
+ QUICHE_VLOG(1) << "fd: " << fd << " write hit EAGAIN";
EXPECT_EQ(EAGAIN, errno) << strerror(errno);
can_write_ = false;
}
@@ -1921,7 +1926,7 @@
void OnShutdown(SimpleEpollServer* /*eps*/, int /*fd*/) override {
// None of the current tests involve having active callbacks when the
// server shuts down.
- EPOLL_LOG(FATAL);
+ QUICHE_LOG(FATAL);
}
std::string Name() const override { return "EdgeTriggerCB"; }
@@ -1972,7 +1977,7 @@
SimpleEpollServer ep;
int pipe_fds[2];
if (pipe(pipe_fds) < 0) {
- EPOLL_PLOG(FATAL) << "pipe() failed";
+ QUICHE_PLOG(FATAL) << "pipe() failed";
}
// Just use any CB will do, since we never wait on epoll events.
@@ -2014,10 +2019,10 @@
close(pipe_fds[1]);
}
-class EPSWaitThread : public EpollThread {
+class EPSWaitThread : public quiche::QuicheThread {
public:
explicit EPSWaitThread(SimpleEpollServer* eps)
- : EpollThread("EPSWait"), eps_(eps), done_(false) {}
+ : QuicheThread("EPSWait"), eps_(eps), done_(false) {}
void Run() override { eps_->WaitForEventsAndExecuteCallbacks(); }
@@ -2483,8 +2488,8 @@
TestAlarm alarm;
SimpleEpollServer epoll_server;
epoll_server.RegisterAlarm(1, &alarm);
- EXPECT_EPOLL_BUG(epoll_server.RegisterAlarm(1, &alarm),
- "Alarm already exists");
+ EXPECT_QUICHE_BUG(epoll_server.RegisterAlarm(1, &alarm),
+ "Alarm already exists");
}
} // namespace