Commit 7f22ad99 authored by Igor Sugak's avatar Igor Sugak Committed by Sara Golemon

Add missing override and remove redundant virtual in folly

Summary: Running clang-tidy to fix this problem, using script D2171334.

I noticed that even without this change clang dev build succeeds for folly and opened a separate task to investigate why.

Reviewed By: @markisaa

Differential Revision: D2179299
parent 61a1244e
...@@ -32,8 +32,7 @@ class ElfTest : public ::testing::Test { ...@@ -32,8 +32,7 @@ class ElfTest : public ::testing::Test {
ElfTest() : elfFile_(binaryPath.c_str()) { ElfTest() : elfFile_(binaryPath.c_str()) {
} }
virtual ~ElfTest() { ~ElfTest() override {}
}
protected: protected:
ElfFile elfFile_; ElfFile elfFile_;
......
...@@ -64,7 +64,7 @@ void bar() { ...@@ -64,7 +64,7 @@ void bar() {
class ElfCacheTest : public testing::Test { class ElfCacheTest : public testing::Test {
protected: protected:
void SetUp(); void SetUp() override;
}; };
// Capture "golden" stack trace with default-configured Symbolizer // Capture "golden" stack trace with default-configured Symbolizer
......
...@@ -31,7 +31,7 @@ class ThreadWheelTimekeeper : public Timekeeper { ...@@ -31,7 +31,7 @@ class ThreadWheelTimekeeper : public Timekeeper {
public: public:
/// But it doesn't *have* to be a singleton. /// But it doesn't *have* to be a singleton.
ThreadWheelTimekeeper(); ThreadWheelTimekeeper();
~ThreadWheelTimekeeper(); ~ThreadWheelTimekeeper() override;
/// Implement the Timekeeper interface /// Implement the Timekeeper interface
/// This future *does* complete on the timer thread. You should almost /// This future *does* complete on the timer thread. You should almost
......
...@@ -23,7 +23,7 @@ using namespace folly; ...@@ -23,7 +23,7 @@ using namespace folly;
class TestData : public RequestData { class TestData : public RequestData {
public: public:
explicit TestData(int data) : data_(data) {} explicit TestData(int data) : data_(data) {}
virtual ~TestData() {} ~TestData() override {}
int data_; int data_;
}; };
......
...@@ -56,7 +56,7 @@ struct ViaFixture : public testing::Test { ...@@ -56,7 +56,7 @@ struct ViaFixture : public testing::Test {
}); });
} }
~ViaFixture() { ~ViaFixture() override {
done = true; done = true;
eastExecutor->add([=]() { }); eastExecutor->add([=]() { });
t.join(); t.join();
...@@ -316,7 +316,7 @@ class ThreadExecutor : public Executor { ...@@ -316,7 +316,7 @@ class ThreadExecutor : public Executor {
worker = std::thread(std::bind(&ThreadExecutor::work, this)); worker = std::thread(std::bind(&ThreadExecutor::work, this));
} }
~ThreadExecutor() { ~ThreadExecutor() override {
done = true; done = true;
funcs.write([]{}); funcs.write([]{});
worker.join(); worker.join();
......
...@@ -84,8 +84,7 @@ class AsyncSSLSocketConnector: public AsyncSocket::ConnectCallback, ...@@ -84,8 +84,7 @@ class AsyncSSLSocketConnector: public AsyncSocket::ConnectCallback,
int64_t startTime_; int64_t startTime_;
protected: protected:
virtual ~AsyncSSLSocketConnector() { ~AsyncSSLSocketConnector() override {}
}
public: public:
AsyncSSLSocketConnector(AsyncSSLSocket *sslSocket, AsyncSSLSocketConnector(AsyncSSLSocket *sslSocket,
...@@ -98,7 +97,7 @@ class AsyncSSLSocketConnector: public AsyncSocket::ConnectCallback, ...@@ -98,7 +97,7 @@ class AsyncSSLSocketConnector: public AsyncSocket::ConnectCallback,
std::chrono::steady_clock::now().time_since_epoch()).count()) { std::chrono::steady_clock::now().time_since_epoch()).count()) {
} }
virtual void connectSuccess() noexcept { void connectSuccess() noexcept override {
VLOG(7) << "client socket connected"; VLOG(7) << "client socket connected";
int64_t timeoutLeft = 0; int64_t timeoutLeft = 0;
...@@ -118,13 +117,13 @@ class AsyncSSLSocketConnector: public AsyncSocket::ConnectCallback, ...@@ -118,13 +117,13 @@ class AsyncSSLSocketConnector: public AsyncSocket::ConnectCallback,
sslSocket_->sslConn(this, timeoutLeft); sslSocket_->sslConn(this, timeoutLeft);
} }
virtual void connectErr(const AsyncSocketException& ex) noexcept { void connectErr(const AsyncSocketException& ex) noexcept override {
LOG(ERROR) << "TCP connect failed: " << ex.what(); LOG(ERROR) << "TCP connect failed: " << ex.what();
fail(ex); fail(ex);
delete this; delete this;
} }
virtual void handshakeSuc(AsyncSSLSocket *sock) noexcept { void handshakeSuc(AsyncSSLSocket* sock) noexcept override {
VLOG(7) << "client handshake success"; VLOG(7) << "client handshake success";
if (callback_) { if (callback_) {
callback_->connectSuccess(); callback_->connectSuccess();
...@@ -132,8 +131,8 @@ class AsyncSSLSocketConnector: public AsyncSocket::ConnectCallback, ...@@ -132,8 +131,8 @@ class AsyncSSLSocketConnector: public AsyncSocket::ConnectCallback,
delete this; delete this;
} }
virtual void handshakeErr(AsyncSSLSocket *socket, void handshakeErr(AsyncSSLSocket* socket,
const AsyncSocketException& ex) noexcept { const AsyncSocketException& ex) noexcept override {
LOG(ERROR) << "client handshakeErr: " << ex.what(); LOG(ERROR) << "client handshakeErr: " << ex.what();
fail(ex); fail(ex);
delete this; delete this;
......
...@@ -121,9 +121,7 @@ class AsyncServerSocket::BackoffTimeout : public AsyncTimeout { ...@@ -121,9 +121,7 @@ class AsyncServerSocket::BackoffTimeout : public AsyncTimeout {
BackoffTimeout(AsyncServerSocket* socket) BackoffTimeout(AsyncServerSocket* socket)
: AsyncTimeout(socket->getEventBase()), socket_(socket) {} : AsyncTimeout(socket->getEventBase()), socket_(socket) {}
virtual void timeoutExpired() noexcept { void timeoutExpired() noexcept override { socket_->backoffTimeoutExpired(); }
socket_->backoffTimeoutExpired();
}
private: private:
AsyncServerSocket* socket_; AsyncServerSocket* socket_;
......
...@@ -148,7 +148,7 @@ class AsyncSocket::BytesWriteRequest : public AsyncSocket::WriteRequest { ...@@ -148,7 +148,7 @@ class AsyncSocket::BytesWriteRequest : public AsyncSocket::WriteRequest {
} }
// private destructor, to ensure callers use destroy() // private destructor, to ensure callers use destroy()
virtual ~BytesWriteRequest() = default; ~BytesWriteRequest() override = default;
const struct iovec* getOps() const { const struct iovec* getOps() const {
assert(opCount_ > opIndex_); assert(opCount_ > opIndex_);
......
...@@ -44,7 +44,7 @@ class FunctionLoopCallback : public EventBase::LoopCallback { ...@@ -44,7 +44,7 @@ class FunctionLoopCallback : public EventBase::LoopCallback {
explicit FunctionLoopCallback(const Cob& function) explicit FunctionLoopCallback(const Cob& function)
: function_(function) {} : function_(function) {}
virtual void runLoopCallback() noexcept { void runLoopCallback() noexcept override {
function_(); function_();
delete this; delete this;
} }
...@@ -66,7 +66,7 @@ const int kNoFD = -1; ...@@ -66,7 +66,7 @@ const int kNoFD = -1;
class EventBase::FunctionRunner class EventBase::FunctionRunner
: public NotificationQueue<std::pair<void (*)(void*), void*>>::Consumer { : public NotificationQueue<std::pair<void (*)(void*), void*>>::Consumer {
public: public:
void messageAvailable(std::pair<void (*)(void*), void*>&& msg) { void messageAvailable(std::pair<void (*)(void*), void*>&& msg) override {
// In libevent2, internal events do not break the loop. // In libevent2, internal events do not break the loop.
// Most users would expect loop(), followed by runInEventBaseThread(), // Most users would expect loop(), followed by runInEventBaseThread(),
......
...@@ -1263,7 +1263,7 @@ class AsyncSocketImmediateRead : public folly::AsyncSocket { ...@@ -1263,7 +1263,7 @@ class AsyncSocketImmediateRead : public folly::AsyncSocket {
bool immediateReadCalled = false; bool immediateReadCalled = false;
explicit AsyncSocketImmediateRead(folly::EventBase* evb) : AsyncSocket(evb) {} explicit AsyncSocketImmediateRead(folly::EventBase* evb) : AsyncSocket(evb) {}
protected: protected:
virtual void checkForImmediateRead() noexcept override { void checkForImmediateRead() noexcept override {
immediateReadCalled = true; immediateReadCalled = true;
AsyncSocket::handleRead(); AsyncSocket::handleRead();
} }
...@@ -1441,29 +1441,29 @@ class TestAcceptCallback : public AsyncServerSocket::AcceptCallback { ...@@ -1441,29 +1441,29 @@ class TestAcceptCallback : public AsyncServerSocket::AcceptCallback {
acceptStoppedFn_ = fn; acceptStoppedFn_ = fn;
} }
void connectionAccepted(int fd, const folly::SocketAddress& clientAddr) void connectionAccepted(
noexcept { int fd, const folly::SocketAddress& clientAddr) noexcept override {
events_.emplace_back(fd, clientAddr); events_.emplace_back(fd, clientAddr);
if (connectionAcceptedFn_) { if (connectionAcceptedFn_) {
connectionAcceptedFn_(fd, clientAddr); connectionAcceptedFn_(fd, clientAddr);
} }
} }
void acceptError(const std::exception& ex) noexcept { void acceptError(const std::exception& ex) noexcept override {
events_.emplace_back(ex.what()); events_.emplace_back(ex.what());
if (acceptErrorFn_) { if (acceptErrorFn_) {
acceptErrorFn_(ex); acceptErrorFn_(ex);
} }
} }
void acceptStarted() noexcept { void acceptStarted() noexcept override {
events_.emplace_back(TYPE_START); events_.emplace_back(TYPE_START);
if (acceptStartedFn_) { if (acceptStartedFn_) {
acceptStartedFn_(); acceptStartedFn_();
} }
} }
void acceptStopped() noexcept { void acceptStopped() noexcept override {
events_.emplace_back(TYPE_STOP); events_.emplace_back(TYPE_STOP);
if (acceptStoppedFn_) { if (acceptStoppedFn_) {
......
...@@ -41,16 +41,14 @@ class UDPAcceptor ...@@ -41,16 +41,14 @@ class UDPAcceptor
UDPAcceptor(EventBase* evb, int n): evb_(evb), n_(n) { UDPAcceptor(EventBase* evb, int n): evb_(evb), n_(n) {
} }
void onListenStarted() noexcept { void onListenStarted() noexcept override {}
}
void onListenStopped() noexcept { void onListenStopped() noexcept override {}
}
void onDataAvailable(std::shared_ptr<folly::AsyncUDPSocket> socket, void onDataAvailable(std::shared_ptr<folly::AsyncUDPSocket> socket,
const folly::SocketAddress& client, const folly::SocketAddress& client,
std::unique_ptr<folly::IOBuf> data, std::unique_ptr<folly::IOBuf> data,
bool truncated) noexcept { bool truncated) noexcept override {
lastClient_ = client; lastClient_ = client;
lastMsg_ = data->moveToFbString().toStdString(); lastMsg_ = data->moveToFbString().toStdString();
...@@ -206,14 +204,14 @@ class UDPClient ...@@ -206,14 +204,14 @@ class UDPClient
folly::IOBuf::copyBuffer(folly::to<std::string>("PING ", n_))); folly::IOBuf::copyBuffer(folly::to<std::string>("PING ", n_)));
} }
void getReadBuffer(void** buf, size_t* len) noexcept { void getReadBuffer(void** buf, size_t* len) noexcept override {
*buf = buf_; *buf = buf_;
*len = 1024; *len = 1024;
} }
void onDataAvailable(const folly::SocketAddress& client, void onDataAvailable(const folly::SocketAddress& client,
size_t len, size_t len,
bool truncated) noexcept { bool truncated) noexcept override {
VLOG(4) << "Read " << len << " bytes (trun:" << truncated << ") from " VLOG(4) << "Read " << len << " bytes (trun:" << truncated << ") from "
<< client.describe() << " - " << std::string(buf_, len); << client.describe() << " - " << std::string(buf_, len);
VLOG(4) << n_ << " left"; VLOG(4) << n_ << " left";
...@@ -223,18 +221,18 @@ class UDPClient ...@@ -223,18 +221,18 @@ class UDPClient
sendPing(); sendPing();
} }
void onReadError(const folly::AsyncSocketException& ex) noexcept { void onReadError(const folly::AsyncSocketException& ex) noexcept override {
VLOG(4) << ex.what(); VLOG(4) << ex.what();
// Start listening for next PONG // Start listening for next PONG
socket_->resumeRead(this); socket_->resumeRead(this);
} }
void onReadClosed() noexcept { void onReadClosed() noexcept override {
CHECK(false) << "We unregister reads before closing"; CHECK(false) << "We unregister reads before closing";
} }
void timeoutExpired() noexcept { void timeoutExpired() noexcept override {
VLOG(4) << "Timeout expired"; VLOG(4) << "Timeout expired";
sendPing(); sendPing();
} }
......
...@@ -27,7 +27,7 @@ class CountedLoopCallback : public EventBase::LoopCallback { ...@@ -27,7 +27,7 @@ class CountedLoopCallback : public EventBase::LoopCallback {
: eventBase_(eventBase) : eventBase_(eventBase)
, count_(count) {} , count_(count) {}
virtual void runLoopCallback() noexcept { void runLoopCallback() noexcept override {
--count_; --count_;
if (count_ > 0) { if (count_ > 0) {
eventBase_->runInLoop(this); eventBase_->runInLoop(this);
......
...@@ -141,7 +141,7 @@ class TestHandler : public EventHandler { ...@@ -141,7 +141,7 @@ class TestHandler : public EventHandler {
TestHandler(EventBase* eventBase, int fd) TestHandler(EventBase* eventBase, int fd)
: EventHandler(eventBase, fd), fd_(fd) {} : EventHandler(eventBase, fd), fd_(fd) {}
virtual void handlerReady(uint16_t events) noexcept { void handlerReady(uint16_t events) noexcept override {
ssize_t bytesRead = 0; ssize_t bytesRead = 0;
ssize_t bytesWritten = 0; ssize_t bytesWritten = 0;
if (events & READ) { if (events & READ) {
...@@ -645,7 +645,7 @@ class PartialReadHandler : public TestHandler { ...@@ -645,7 +645,7 @@ class PartialReadHandler : public TestHandler {
PartialReadHandler(EventBase* eventBase, int fd, size_t readLength) PartialReadHandler(EventBase* eventBase, int fd, size_t readLength)
: TestHandler(eventBase, fd), fd_(fd), readLength_(readLength) {} : TestHandler(eventBase, fd), fd_(fd), readLength_(readLength) {}
virtual void handlerReady(uint16_t events) noexcept { void handlerReady(uint16_t events) noexcept override {
assert(events == EventHandler::READ); assert(events == EventHandler::READ);
ssize_t bytesRead = readFromFD(fd_, readLength_); ssize_t bytesRead = readFromFD(fd_, readLength_);
log.emplace_back(events, bytesRead, 0); log.emplace_back(events, bytesRead, 0);
...@@ -710,7 +710,7 @@ class PartialWriteHandler : public TestHandler { ...@@ -710,7 +710,7 @@ class PartialWriteHandler : public TestHandler {
PartialWriteHandler(EventBase* eventBase, int fd, size_t writeLength) PartialWriteHandler(EventBase* eventBase, int fd, size_t writeLength)
: TestHandler(eventBase, fd), fd_(fd), writeLength_(writeLength) {} : TestHandler(eventBase, fd), fd_(fd), writeLength_(writeLength) {}
virtual void handlerReady(uint16_t events) noexcept { void handlerReady(uint16_t events) noexcept override {
assert(events == EventHandler::WRITE); assert(events == EventHandler::WRITE);
ssize_t bytesWritten = writeToFD(fd_, writeLength_); ssize_t bytesWritten = writeToFD(fd_, writeLength_);
log.emplace_back(events, 0, bytesWritten); log.emplace_back(events, 0, bytesWritten);
...@@ -780,9 +780,7 @@ TEST(EventBaseTest, DestroyHandler) { ...@@ -780,9 +780,7 @@ TEST(EventBaseTest, DestroyHandler) {
: AsyncTimeout(eb) : AsyncTimeout(eb)
, handler_(h) {} , handler_(h) {}
virtual void timeoutExpired() noexcept { void timeoutExpired() noexcept override { delete handler_; }
delete handler_;
}
private: private:
EventHandler* handler_; EventHandler* handler_;
...@@ -895,9 +893,7 @@ class TestTimeout : public AsyncTimeout { ...@@ -895,9 +893,7 @@ class TestTimeout : public AsyncTimeout {
: AsyncTimeout(eventBase) : AsyncTimeout(eventBase)
, timestamp(false) {} , timestamp(false) {}
virtual void timeoutExpired() noexcept { void timeoutExpired() noexcept override { timestamp.reset(); }
timestamp.reset();
}
TimePoint timestamp; TimePoint timestamp;
}; };
...@@ -933,7 +929,7 @@ class ReschedulingTimeout : public AsyncTimeout { ...@@ -933,7 +929,7 @@ class ReschedulingTimeout : public AsyncTimeout {
reschedule(); reschedule();
} }
virtual void timeoutExpired() noexcept { void timeoutExpired() noexcept override {
timestamps.emplace_back(); timestamps.emplace_back();
reschedule(); reschedule();
} }
...@@ -1052,9 +1048,7 @@ TEST(EventBaseTest, DestroyTimeout) { ...@@ -1052,9 +1048,7 @@ TEST(EventBaseTest, DestroyTimeout) {
: AsyncTimeout(eb) : AsyncTimeout(eb)
, timeout_(t) {} , timeout_(t) {}
virtual void timeoutExpired() noexcept { void timeoutExpired() noexcept override { delete timeout_; }
delete timeout_;
}
private: private:
AsyncTimeout* timeout_; AsyncTimeout* timeout_;
...@@ -1269,7 +1263,7 @@ class CountedLoopCallback : public EventBase::LoopCallback { ...@@ -1269,7 +1263,7 @@ class CountedLoopCallback : public EventBase::LoopCallback {
, count_(count) , count_(count)
, action_(action) {} , action_(action) {}
virtual void runLoopCallback() noexcept { void runLoopCallback() noexcept override {
--count_; --count_;
if (count_ > 0) { if (count_ > 0) {
eventBase_->runInLoop(this); eventBase_->runInLoop(this);
...@@ -1437,7 +1431,7 @@ class TerminateTestCallback : public EventBase::LoopCallback, ...@@ -1437,7 +1431,7 @@ class TerminateTestCallback : public EventBase::LoopCallback,
unregisterHandler(); unregisterHandler();
} }
virtual void handlerReady(uint16_t events) noexcept { void handlerReady(uint16_t events) noexcept override {
// We didn't register with PERSIST, so we will have been automatically // We didn't register with PERSIST, so we will have been automatically
// unregistered already. // unregistered already.
ASSERT_FALSE(isHandlerRegistered()); ASSERT_FALSE(isHandlerRegistered());
...@@ -1449,7 +1443,7 @@ class TerminateTestCallback : public EventBase::LoopCallback, ...@@ -1449,7 +1443,7 @@ class TerminateTestCallback : public EventBase::LoopCallback,
eventBase_->runInLoop(this); eventBase_->runInLoop(this);
} }
virtual void runLoopCallback() noexcept { void runLoopCallback() noexcept override {
++loopInvocations_; ++loopInvocations_;
if (loopInvocations_ >= maxLoopInvocations_) { if (loopInvocations_ >= maxLoopInvocations_) {
return; return;
...@@ -1526,9 +1520,9 @@ class IdleTimeTimeoutSeries : public AsyncTimeout { ...@@ -1526,9 +1520,9 @@ class IdleTimeTimeoutSeries : public AsyncTimeout {
scheduleTimeout(1); scheduleTimeout(1);
} }
virtual ~IdleTimeTimeoutSeries() {} ~IdleTimeTimeoutSeries() override {}
void timeoutExpired() noexcept { void timeoutExpired() noexcept override {
++timeouts_; ++timeouts_;
if(timeout_.empty()){ if(timeout_.empty()){
...@@ -1696,9 +1690,7 @@ public: ...@@ -1696,9 +1690,7 @@ public:
PipeHandler(EventBase* eventBase, int fd) PipeHandler(EventBase* eventBase, int fd)
: EventHandler(eventBase, fd) {} : EventHandler(eventBase, fd) {}
void handlerReady(uint16_t events) noexcept { void handlerReady(uint16_t events) noexcept override { abort(); }
abort();
}
}; };
TEST(EventBaseTest, StopBeforeLoop) { TEST(EventBaseTest, StopBeforeLoop) {
......
...@@ -133,7 +133,7 @@ TEST(CompressionTestNeedsUncompressedLength, Simple) { ...@@ -133,7 +133,7 @@ TEST(CompressionTestNeedsUncompressedLength, Simple) {
class CompressionTest class CompressionTest
: public testing::TestWithParam<std::tr1::tuple<int, CodecType>> { : public testing::TestWithParam<std::tr1::tuple<int, CodecType>> {
protected: protected:
void SetUp() { void SetUp() override {
auto tup = GetParam(); auto tup = GetParam();
uncompressedLength_ = uint64_t(1) << std::tr1::get<0>(tup); uncompressedLength_ = uint64_t(1) << std::tr1::get<0>(tup);
codec_ = getCodec(std::tr1::get<1>(tup)); codec_ = getCodec(std::tr1::get<1>(tup));
...@@ -185,7 +185,7 @@ INSTANTIATE_TEST_CASE_P( ...@@ -185,7 +185,7 @@ INSTANTIATE_TEST_CASE_P(
class CompressionVarintTest class CompressionVarintTest
: public testing::TestWithParam<std::tr1::tuple<int, CodecType>> { : public testing::TestWithParam<std::tr1::tuple<int, CodecType>> {
protected: protected:
void SetUp() { void SetUp() override {
auto tup = GetParam(); auto tup = GetParam();
uncompressedLength_ = uint64_t(1) << std::tr1::get<0>(tup); uncompressedLength_ = uint64_t(1) << std::tr1::get<0>(tup);
codec_ = getCodec(std::tr1::get<1>(tup)); codec_ = getCodec(std::tr1::get<1>(tup));
...@@ -237,9 +237,7 @@ INSTANTIATE_TEST_CASE_P( ...@@ -237,9 +237,7 @@ INSTANTIATE_TEST_CASE_P(
class CompressionCorruptionTest : public testing::TestWithParam<CodecType> { class CompressionCorruptionTest : public testing::TestWithParam<CodecType> {
protected: protected:
void SetUp() { void SetUp() override { codec_ = getCodec(GetParam()); }
codec_ = getCodec(GetParam());
}
void runSimpleTest(const DataHolder& dh); void runSimpleTest(const DataHolder& dh);
......
...@@ -832,7 +832,7 @@ enum BufType { ...@@ -832,7 +832,7 @@ enum BufType {
class MoveToFbStringTest class MoveToFbStringTest
: public ::testing::TestWithParam<std::tr1::tuple<int, int, bool, BufType>> { : public ::testing::TestWithParam<std::tr1::tuple<int, int, bool, BufType>> {
protected: protected:
void SetUp() { void SetUp() override {
elementSize_ = std::tr1::get<0>(GetParam()); elementSize_ = std::tr1::get<0>(GetParam());
elementCount_ = std::tr1::get<1>(GetParam()); elementCount_ = std::tr1::get<1>(GetParam());
shared_ = std::tr1::get<2>(GetParam()); shared_ = std::tr1::get<2>(GetParam());
......
...@@ -139,8 +139,8 @@ public: ...@@ -139,8 +139,8 @@ public:
explicit IntException(int i) explicit IntException(int i)
: i_(i) {} : i_(i) {}
virtual int getInt() const override { return i_; } int getInt() const override { return i_; }
virtual const char* what() const noexcept override { const char* what() const noexcept override {
what_ = folly::to<std::string>("int == ", i_); what_ = folly::to<std::string>("int == ", i_);
return what_.c_str(); return what_.c_str();
} }
......
...@@ -84,7 +84,7 @@ class IntPaddedTestBase : public ::testing::Test { ...@@ -84,7 +84,7 @@ class IntPaddedTestBase : public ::testing::Test {
class IntPaddedConstTest : public IntPaddedTestBase { class IntPaddedConstTest : public IntPaddedTestBase {
protected: protected:
void SetUp() { void SetUp() override {
v_.resize(4); v_.resize(4);
n_ = 0; n_ = 0;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
...@@ -181,7 +181,7 @@ class StructPaddedTestBase : public ::testing::Test { ...@@ -181,7 +181,7 @@ class StructPaddedTestBase : public ::testing::Test {
class StructPaddedConstTest : public StructPaddedTestBase { class StructPaddedConstTest : public StructPaddedTestBase {
protected: protected:
void SetUp() { void SetUp() override {
v_.resize(4); v_.resize(4);
n_ = 0; n_ = 0;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
......
...@@ -28,7 +28,7 @@ class Base { ...@@ -28,7 +28,7 @@ class Base {
class Derived : public Base { class Derived : public Base {
public: public:
virtual int foo() const FOLLY_FINAL { return 2; } int foo() const FOLLY_FINAL { return 2; }
}; };
// A compiler that supports final will likely inline the call to p->foo() // A compiler that supports final will likely inline the call to p->foo()
......
...@@ -25,11 +25,9 @@ ...@@ -25,11 +25,9 @@
class Exception : public std::exception { class Exception : public std::exception {
public: public:
explicit Exception(const std::string& value) : value_(value) {} explicit Exception(const std::string& value) : value_(value) {}
virtual ~Exception(void) noexcept {} ~Exception(void) noexcept override {}
virtual const char *what(void) const noexcept { const char* what(void) const noexcept override { return value_.c_str(); }
return value_.c_str();
}
private: private:
std::string value_; std::string value_;
......
...@@ -69,30 +69,27 @@ class AcceptorHandshakeHelper : ...@@ -69,30 +69,27 @@ class AcceptorHandshakeHelper :
socket_->sslAccept(this); socket_->sslAccept(this);
} }
virtual void timeoutExpired() noexcept override { void timeoutExpired() noexcept override {
VLOG(4) << "SSL handshake timeout expired"; VLOG(4) << "SSL handshake timeout expired";
sslError_ = SSLErrorEnum::TIMEOUT; sslError_ = SSLErrorEnum::TIMEOUT;
dropConnection(); dropConnection();
} }
virtual void describe(std::ostream& os) const override { void describe(std::ostream& os) const override {
os << "pending handshake on " << clientAddr_; os << "pending handshake on " << clientAddr_;
} }
virtual bool isBusy() const override { bool isBusy() const override { return true; }
return true; void notifyPendingShutdown() override {}
} void closeWhenIdle() override {}
virtual void notifyPendingShutdown() override {}
virtual void closeWhenIdle() override {}
virtual void dropConnection() override { void dropConnection() override {
VLOG(10) << "Dropping in progress handshake for " << clientAddr_; VLOG(10) << "Dropping in progress handshake for " << clientAddr_;
socket_->closeNow(); socket_->closeNow();
} }
virtual void dumpConnectionState(uint8_t loglevel) override { void dumpConnectionState(uint8_t loglevel) override {}
}
private: private:
// AsyncSSLSocket::HandshakeCallback API // AsyncSSLSocket::HandshakeCallback API
virtual void handshakeSuc(AsyncSSLSocket* sock) noexcept override { void handshakeSuc(AsyncSSLSocket* sock) noexcept override {
const unsigned char* nextProto = nullptr; const unsigned char* nextProto = nullptr;
unsigned nextProtoLength = 0; unsigned nextProtoLength = 0;
...@@ -146,8 +143,8 @@ class AcceptorHandshakeHelper : ...@@ -146,8 +143,8 @@ class AcceptorHandshakeHelper :
delete this; delete this;
} }
virtual void handshakeErr(AsyncSSLSocket* sock, void handshakeErr(AsyncSSLSocket* sock,
const AsyncSocketException& ex) noexcept override { const AsyncSocketException& ex) noexcept override {
auto elapsedTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - acceptTime_); auto elapsedTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - acceptTime_);
VLOG(3) << "SSL handshake error after " << elapsedTime.count() << VLOG(3) << "SSL handshake error after " << elapsedTime.count() <<
" ms; " << sock->getRawBytesReceived() << " bytes received & " << " ms; " << sock->getRawBytesReceived() << " bytes received & " <<
......
...@@ -33,7 +33,7 @@ typedef ClientBootstrap<BytesPipeline> TestClient; ...@@ -33,7 +33,7 @@ typedef ClientBootstrap<BytesPipeline> TestClient;
class TestClientPipelineFactory : public PipelineFactory<BytesPipeline> { class TestClientPipelineFactory : public PipelineFactory<BytesPipeline> {
public: public:
std::unique_ptr<BytesPipeline, folly::DelayedDestruction::Destructor> std::unique_ptr<BytesPipeline, folly::DelayedDestruction::Destructor>
newPipeline(std::shared_ptr<AsyncSocket> sock) { newPipeline(std::shared_ptr<AsyncSocket> sock) override {
// We probably aren't connected immedately, check after a small delay // We probably aren't connected immedately, check after a small delay
EventBaseManager::get()->getEventBase()->tryRunAfterDelay([sock](){ EventBaseManager::get()->getEventBase()->tryRunAfterDelay([sock](){
CHECK(sock->good()); CHECK(sock->good());
...@@ -45,8 +45,8 @@ class TestClientPipelineFactory : public PipelineFactory<BytesPipeline> { ...@@ -45,8 +45,8 @@ class TestClientPipelineFactory : public PipelineFactory<BytesPipeline> {
class TestPipelineFactory : public PipelineFactory<BytesPipeline> { class TestPipelineFactory : public PipelineFactory<BytesPipeline> {
public: public:
std::unique_ptr<BytesPipeline, folly::DelayedDestruction::Destructor> newPipeline( std::unique_ptr<BytesPipeline, folly::DelayedDestruction::Destructor>
std::shared_ptr<AsyncSocket> sock) { newPipeline(std::shared_ptr<AsyncSocket> sock) override {
pipelines++; pipelines++;
return std::unique_ptr<BytesPipeline, folly::DelayedDestruction::Destructor>( return std::unique_ptr<BytesPipeline, folly::DelayedDestruction::Destructor>(
...@@ -61,17 +61,15 @@ EventBase base_; ...@@ -61,17 +61,15 @@ EventBase base_;
TestAcceptor() : Acceptor(ServerSocketConfig()) { TestAcceptor() : Acceptor(ServerSocketConfig()) {
Acceptor::init(nullptr, &base_); Acceptor::init(nullptr, &base_);
} }
void onNewConnection( void onNewConnection(AsyncSocket::UniquePtr sock,
AsyncSocket::UniquePtr sock, const folly::SocketAddress* address,
const folly::SocketAddress* address, const std::string& nextProtocolName,
const std::string& nextProtocolName, const TransportInfo& tinfo) override {}
const TransportInfo& tinfo) {
}
}; };
class TestAcceptorFactory : public AcceptorFactory { class TestAcceptorFactory : public AcceptorFactory {
public: public:
std::shared_ptr<Acceptor> newAcceptor(EventBase* base) { std::shared_ptr<Acceptor> newAcceptor(EventBase* base) override {
return std::make_shared<TestAcceptor>(); return std::make_shared<TestAcceptor>();
} }
}; };
...@@ -272,7 +270,7 @@ std::atomic<int> connections{0}; ...@@ -272,7 +270,7 @@ std::atomic<int> connections{0};
class TestHandlerPipeline : public InboundHandler<void*> { class TestHandlerPipeline : public InboundHandler<void*> {
public: public:
void read(Context* ctx, void* conn) { void read(Context* ctx, void* conn) override {
connections++; connections++;
return ctx->fireRead(conn); return ctx->fireRead(conn);
} }
...@@ -284,7 +282,7 @@ class TestHandlerPipelineFactory ...@@ -284,7 +282,7 @@ class TestHandlerPipelineFactory
public: public:
std::unique_ptr<ServerBootstrap<BytesPipeline>::AcceptPipeline, std::unique_ptr<ServerBootstrap<BytesPipeline>::AcceptPipeline,
folly::DelayedDestruction::Destructor> folly::DelayedDestruction::Destructor>
newPipeline(std::shared_ptr<AsyncSocket>) { newPipeline(std::shared_ptr<AsyncSocket>) override {
std::unique_ptr<ServerBootstrap<BytesPipeline>::AcceptPipeline, std::unique_ptr<ServerBootstrap<BytesPipeline>::AcceptPipeline,
folly::DelayedDestruction::Destructor> pipeline( folly::DelayedDestruction::Destructor> pipeline(
...@@ -320,9 +318,7 @@ TEST(Bootstrap, LoadBalanceHandler) { ...@@ -320,9 +318,7 @@ TEST(Bootstrap, LoadBalanceHandler) {
class TestUDPPipeline : public InboundHandler<void*> { class TestUDPPipeline : public InboundHandler<void*> {
public: public:
void read(Context* ctx, void* conn) { void read(Context* ctx, void* conn) override { connections++; }
connections++;
}
}; };
TEST(Bootstrap, UDP) { TEST(Bootstrap, UDP) {
......
...@@ -38,7 +38,7 @@ struct FileRegionTest : public Test { ...@@ -38,7 +38,7 @@ struct FileRegionTest : public Test {
EXPECT_EQ(0, unlink(path)); EXPECT_EQ(0, unlink(path));
} }
~FileRegionTest() { ~FileRegionTest() override {
// Close up shop // Close up shop
close(fd); close(fd);
acceptedSocket->close(); acceptedSocket->close();
......
...@@ -265,8 +265,8 @@ template <class Rin, class Rout = Rin, class Win = Rout, class Wout = Rin> ...@@ -265,8 +265,8 @@ template <class Rin, class Rout = Rin, class Win = Rout, class Wout = Rin>
class ConcreteHandler : public Handler<Rin, Rout, Win, Wout> { class ConcreteHandler : public Handler<Rin, Rout, Win, Wout> {
typedef typename Handler<Rin, Rout, Win, Wout>::Context Context; typedef typename Handler<Rin, Rout, Win, Wout>::Context Context;
public: public:
void read(Context* ctx, Rin msg) {} void read(Context* ctx, Rin msg) override {}
Future<void> write(Context* ctx, Win msg) { return makeFuture(); } Future<void> write(Context* ctx, Win msg) override { return makeFuture(); }
}; };
typedef HandlerAdapter<std::string, std::string> StringHandler; typedef HandlerAdapter<std::string, std::string> StringHandler;
......
...@@ -30,11 +30,11 @@ class FrameTester ...@@ -30,11 +30,11 @@ class FrameTester
explicit FrameTester(std::function<void(std::unique_ptr<IOBuf>)> test) explicit FrameTester(std::function<void(std::unique_ptr<IOBuf>)> test)
: test_(test) {} : test_(test) {}
void read(Context* ctx, std::unique_ptr<IOBuf> buf) { void read(Context* ctx, std::unique_ptr<IOBuf> buf) override {
test_(std::move(buf)); test_(std::move(buf));
} }
void readException(Context* ctx, exception_wrapper w) { void readException(Context* ctx, exception_wrapper w) override {
test_(nullptr); test_(nullptr);
} }
private: private:
...@@ -44,8 +44,7 @@ class FrameTester ...@@ -44,8 +44,7 @@ class FrameTester
class BytesReflector class BytesReflector
: public BytesToBytesHandler { : public BytesToBytesHandler {
public: public:
Future<void> write(Context* ctx, std::unique_ptr<IOBuf> buf) override {
Future<void> write(Context* ctx, std::unique_ptr<IOBuf> buf) {
IOBufQueue q_(IOBufQueue::cacheChainLength()); IOBufQueue q_(IOBufQueue::cacheChainLength());
q_.append(std::move(buf)); q_.append(std::move(buf));
ctx->fireRead(q_); ctx->fireRead(q_);
......
...@@ -33,11 +33,9 @@ class MemoryIdlerTimeout ...@@ -33,11 +33,9 @@ class MemoryIdlerTimeout
public: public:
explicit MemoryIdlerTimeout(EventBase* b) : AsyncTimeout(b), base_(b) {} explicit MemoryIdlerTimeout(EventBase* b) : AsyncTimeout(b), base_(b) {}
virtual void timeoutExpired() noexcept { void timeoutExpired() noexcept override { idled = true; }
idled = true;
}
virtual void runLoopCallback() noexcept { void runLoopCallback() noexcept override {
if (idled) { if (idled) {
MemoryIdler::flushLocalMallocCaches(); MemoryIdler::flushLocalMallocCaches();
MemoryIdler::unmapUnusedStack(MemoryIdler::kDefaultStackToRetain); MemoryIdler::unmapUnusedStack(MemoryIdler::kDefaultStackToRetain);
......
...@@ -322,16 +322,12 @@ TEST(ThreadPoolExecutorTest, PriorityPreemptionTest) { ...@@ -322,16 +322,12 @@ TEST(ThreadPoolExecutorTest, PriorityPreemptionTest) {
class TestObserver : public ThreadPoolExecutor::Observer { class TestObserver : public ThreadPoolExecutor::Observer {
public: public:
void threadStarted(ThreadPoolExecutor::ThreadHandle*) { void threadStarted(ThreadPoolExecutor::ThreadHandle*) override { threads_++; }
void threadStopped(ThreadPoolExecutor::ThreadHandle*) override { threads_--; }
void threadPreviouslyStarted(ThreadPoolExecutor::ThreadHandle*) override {
threads_++; threads_++;
} }
void threadStopped(ThreadPoolExecutor::ThreadHandle*) { void threadNotYetStopped(ThreadPoolExecutor::ThreadHandle*) override {
threads_--;
}
void threadPreviouslyStarted(ThreadPoolExecutor::ThreadHandle*) {
threads_++;
}
void threadNotYetStopped(ThreadPoolExecutor::ThreadHandle*) {
threads_--; threads_--;
} }
void checkCalls() { void checkCalls() {
......
...@@ -29,22 +29,21 @@ typedef Pipeline<IOBufQueue&, std::string> ServicePipeline; ...@@ -29,22 +29,21 @@ typedef Pipeline<IOBufQueue&, std::string> ServicePipeline;
class SimpleDecode : public ByteToMessageCodec { class SimpleDecode : public ByteToMessageCodec {
public: public:
virtual std::unique_ptr<IOBuf> decode( std::unique_ptr<IOBuf> decode(Context* ctx,
Context* ctx, IOBufQueue& buf, size_t&) { IOBufQueue& buf,
size_t&) override {
return buf.move(); return buf.move();
} }
}; };
class EchoService : public Service<std::string, std::string> { class EchoService : public Service<std::string, std::string> {
public: public:
virtual Future<std::string> operator()(std::string req) override { Future<std::string> operator()(std::string req) override { return req; }
return req;
}
}; };
class EchoIntService : public Service<std::string, int> { class EchoIntService : public Service<std::string, int> {
public: public:
virtual Future<int> operator()(std::string req) override { Future<int> operator()(std::string req) override {
return folly::to<int>(req); return folly::to<int>(req);
} }
}; };
...@@ -143,7 +142,7 @@ class AppendFilter : public ServiceFilter<std::string, std::string> { ...@@ -143,7 +142,7 @@ class AppendFilter : public ServiceFilter<std::string, std::string> {
std::shared_ptr<Service<std::string, std::string>> service) : std::shared_ptr<Service<std::string, std::string>> service) :
ServiceFilter<std::string, std::string>(service) {} ServiceFilter<std::string, std::string>(service) {}
virtual Future<std::string> operator()(std::string req) { Future<std::string> operator()(std::string req) override {
return (*service_)(req + "\n"); return (*service_)(req + "\n");
} }
}; };
...@@ -155,7 +154,7 @@ class IntToStringFilter ...@@ -155,7 +154,7 @@ class IntToStringFilter
std::shared_ptr<Service<std::string, std::string>> service) : std::shared_ptr<Service<std::string, std::string>> service) :
ServiceFilter<int, int, std::string, std::string>(service) {} ServiceFilter<int, int, std::string, std::string>(service) {}
virtual Future<int> operator()(int req) { Future<int> operator()(int req) override {
return (*service_)(folly::to<std::string>(req)).then([](std::string resp) { return (*service_)(folly::to<std::string>(req)).then([](std::string resp) {
return folly::to<int>(resp); return folly::to<int>(resp);
}); });
...@@ -183,7 +182,7 @@ class ChangeTypeFilter ...@@ -183,7 +182,7 @@ class ChangeTypeFilter
std::shared_ptr<Service<std::string, int>> service) : std::shared_ptr<Service<std::string, int>> service) :
ServiceFilter<int, std::string, std::string, int>(service) {} ServiceFilter<int, std::string, std::string, int>(service) {}
virtual Future<std::string> operator()(int req) { Future<std::string> operator()(int req) override {
return (*service_)(folly::to<std::string>(req)).then([](int resp) { return (*service_)(folly::to<std::string>(req)).then([](int resp) {
return folly::to<std::string>(resp); return folly::to<std::string>(resp);
}); });
...@@ -204,8 +203,8 @@ class ConnectionCountFilter : public ServiceFactoryFilter<Pipeline, Req, Resp> { ...@@ -204,8 +203,8 @@ class ConnectionCountFilter : public ServiceFactoryFilter<Pipeline, Req, Resp> {
std::shared_ptr<ServiceFactory<Pipeline, Req, Resp>> factory) std::shared_ptr<ServiceFactory<Pipeline, Req, Resp>> factory)
: ServiceFactoryFilter<Pipeline, Req, Resp>(factory) {} : ServiceFactoryFilter<Pipeline, Req, Resp>(factory) {}
virtual Future<std::shared_ptr<Service<Req, Resp>>> operator()( Future<std::shared_ptr<Service<Req, Resp>>> operator()(
std::shared_ptr<ClientBootstrap<Pipeline>> client) { std::shared_ptr<ClientBootstrap<Pipeline>> client) override {
connectionCount++; connectionCount++;
return (*this->serviceFactory_)(client); return (*this->serviceFactory_)(client);
} }
......
...@@ -60,7 +60,7 @@ private: ...@@ -60,7 +60,7 @@ private:
public: public:
SSLCacheClient(EventBase* eventBase, SSL_SESSION **pSess, ClientRunner* cr); SSLCacheClient(EventBase* eventBase, SSL_SESSION **pSess, ClientRunner* cr);
~SSLCacheClient() { ~SSLCacheClient() override {
if (session_ && !FLAGS_global) if (session_ && !FLAGS_global)
SSL_SESSION_free(session_); SSL_SESSION_free(session_);
if (socket_ != nullptr) { if (socket_ != nullptr) {
...@@ -75,17 +75,14 @@ public: ...@@ -75,17 +75,14 @@ public:
void start(); void start();
virtual void connectSuccess() noexcept; void connectSuccess() noexcept override;
virtual void connectErr(const AsyncSocketException& ex) void connectErr(const AsyncSocketException& ex) noexcept override;
noexcept ;
virtual void handshakeSuc(AsyncSSLSocket* sock) noexcept; void handshakeSuc(AsyncSSLSocket* sock) noexcept override;
virtual void handshakeErr(
AsyncSSLSocket* sock,
const AsyncSocketException& ex) noexcept;
void handshakeErr(AsyncSSLSocket* sock,
const AsyncSocketException& ex) noexcept override;
}; };
int int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment