return tfoFinished_;
}
+ /**
+ * Returns whether or not TFO attempt succeded on this
+ * connection.
+ * For servers this is pretty straightforward API and can
+ * be invoked right after the connection is accepted. This API
+ * will perform one syscall.
+ * This API is a bit tricky to use for clients, since clients
+ * only know this for sure after the SYN-ACK is returned. So it's
+ * appropriate to call this only after the first application
+ * data is read from the socket when the caller knows that
+ * the SYN has been ACKed by the server.
+ */
+ bool getTFOSucceded() const;
+
// Methods controlling socket options
/**
ASSERT_EQ(1, rcb.buffers.size());
ASSERT_EQ(sizeof(buf), rcb.buffers[0].length);
EXPECT_EQ(0, memcmp(rcb.buffers[0].buffer, buf.data(), buf.size()));
+ EXPECT_EQ(socket->getTFOFinished(), socket->getTFOSucceded());
}
TEST(AsyncSocketTest, ConnectTFOSupplyEarlyReadCB) {
ASSERT_EQ(1, rcb.buffers.size());
ASSERT_EQ(sizeof(buf), rcb.buffers[0].length);
EXPECT_EQ(0, memcmp(rcb.buffers[0].buffer, buf.data(), buf.size()));
+ EXPECT_EQ(socket->getTFOFinished(), socket->getTFOSucceded());
}
/**
if (!socket->getTFOFinished()) {
EXPECT_EQ(STATE_FAILED, write1.state);
- EXPECT_FALSE(socket->getTFOFinished());
} else {
EXPECT_EQ(STATE_SUCCEEDED, write1.state);
- EXPECT_TRUE(socket->getTFOFinished());
+ EXPECT_FALSE(socket->getTFOSucceded());
}
EXPECT_EQ(STATE_FAILED, write2.state);
ASSERT_EQ(1, rcb.buffers.size());
ASSERT_EQ(sizeof(buf), rcb.buffers[0].length);
EXPECT_EQ(0, memcmp(rcb.buffers[0].buffer, buf.data(), buf.size()));
+ EXPECT_EQ(socket->getTFOFinished(), socket->getTFOSucceded());
}
TEST(AsyncSocketTest, TestTFOUnsupportedTimeout) {
ASSERT_EQ(1, rcb.buffers.size());
ASSERT_EQ(sizeof(buf), rcb.buffers[0].length);
EXPECT_EQ(0, memcmp(rcb.buffers[0].buffer, buf.data(), buf.size()));
+ EXPECT_EQ(socket->getTFOFinished(), socket->getTFOSucceded());
}
#endif
sock.write((const uint8_t*)FLAGS_msg.data(), FLAGS_msg.size());
- LOG(ERROR) << "TFO attempted: " << sockAddr->getTFOAttempted();
- LOG(ERROR) << "TFO finished: " << sockAddr->getTFOFinished();
+ LOG(INFO) << "TFO attempted: " << sockAddr->getTFOAttempted();
+ LOG(INFO) << "TFO finished: " << sockAddr->getTFOFinished();
+ LOG(INFO) << "TFO success: " << sockAddr->getTFOSucceded();
std::array<char, 1024> buf;
int32_t bytesRead = 0;