Commit 4548dadb authored by Wilhelm Bierbaum's avatar Wilhelm Bierbaum Committed by Facebook Github Bot

Add accessor to read connection establishment time-point

Summary:
In furtherance of advancing connection conditioning in dependent code, the
time-point which a connection was established can be read through an
accessor.

Reviewed By: yfeldblum

Differential Revision: D8669627

fbshipit-source-id: 156924689354d7a19188f4873009e678a68be64b
parent 4aeeb1f6
......@@ -598,6 +598,14 @@ class AsyncSocket : virtual public AsyncTransportWrapper {
return connectTimeout_;
}
std::chrono::steady_clock::time_point getConnectStartTime() const {
return connectStartTime_;
}
std::chrono::steady_clock::time_point getConnectEndTime() const {
return connectEndTime_;
}
bool getTFOAttempted() const {
return tfoAttempted_;
}
......
......@@ -102,12 +102,17 @@ TEST(AsyncSocketTest, Connect) {
EventBase evb;
std::shared_ptr<AsyncSocket> socket = AsyncSocket::newSocket(&evb);
ConnCallback cb;
const auto startedAt = std::chrono::steady_clock::now();
socket->connect(&cb, server.getAddress(), 30);
evb.loop();
const auto finishedAt = std::chrono::steady_clock::now();
ASSERT_EQ(cb.state, STATE_SUCCEEDED);
EXPECT_LE(0, socket->getConnectTime().count());
EXPECT_GE(socket->getConnectStartTime(), startedAt);
EXPECT_LE(socket->getConnectStartTime(), socket->getConnectEndTime());
EXPECT_LE(socket->getConnectEndTime(), finishedAt);
EXPECT_EQ(socket->getConnectTimeout(), std::chrono::milliseconds(30));
}
......
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