`make style` applied
diff --git a/lib/cpp/test/TSocketInterruptTest.cpp b/lib/cpp/test/TSocketInterruptTest.cpp
index 4f6b2bc..02da3ee 100644
--- a/lib/cpp/test/TSocketInterruptTest.cpp
+++ b/lib/cpp/test/TSocketInterruptTest.cpp
@@ -33,122 +33,110 @@
using apache::thrift::transport::TTransport;
using apache::thrift::transport::TTransportException;
-BOOST_FIXTURE_TEST_SUITE ( TSocketInterruptTest, TestPortFixture )
+BOOST_FIXTURE_TEST_SUITE(TSocketInterruptTest, TestPortFixture)
-void readerWorker(boost::shared_ptr<TTransport> tt, uint32_t expectedResult)
-{
+void readerWorker(boost::shared_ptr<TTransport> tt, uint32_t expectedResult) {
+ uint8_t buf[4];
+ BOOST_CHECK_EQUAL(expectedResult, tt->read(buf, 4));
+}
+
+void readerWorkerMustThrow(boost::shared_ptr<TTransport> tt) {
+ try {
uint8_t buf[4];
- BOOST_CHECK_EQUAL(expectedResult, tt->read(buf, 4));
+ tt->read(buf, 4);
+ BOOST_ERROR("should not have gotten here");
+ } catch (const TTransportException& tx) {
+ BOOST_CHECK_EQUAL(TTransportException::INTERRUPTED, tx.getType());
+ }
}
-void readerWorkerMustThrow(boost::shared_ptr<TTransport> tt)
-{
- try
- {
- uint8_t buf[4];
- tt->read(buf, 4);
- BOOST_ERROR("should not have gotten here");
- }
- catch (const TTransportException& tx)
- {
- BOOST_CHECK_EQUAL(TTransportException::INTERRUPTED, tx.getType());
- }
+BOOST_AUTO_TEST_CASE(test_interruptable_child_read) {
+ TServerSocket sock1("localhost", m_serverPort);
+ sock1.listen();
+ TSocket clientSock("localhost", m_serverPort);
+ clientSock.open();
+ boost::shared_ptr<TTransport> accepted = sock1.accept();
+ boost::thread readThread(boost::bind(readerWorkerMustThrow, accepted));
+ boost::this_thread::sleep(boost::posix_time::milliseconds(50));
+ // readThread is practically guaranteed to be blocking now
+ sock1.interruptChildren();
+ BOOST_CHECK_MESSAGE(readThread.try_join_for(boost::chrono::milliseconds(200)),
+ "server socket interruptChildren did not interrupt child read");
+ clientSock.close();
+ accepted->close();
+ sock1.close();
}
-BOOST_AUTO_TEST_CASE( test_interruptable_child_read )
-{
- TServerSocket sock1("localhost", m_serverPort);
- sock1.listen();
- TSocket clientSock("localhost", m_serverPort);
- clientSock.open();
- boost::shared_ptr<TTransport> accepted = sock1.accept();
- boost::thread readThread(boost::bind(readerWorkerMustThrow, accepted));
- boost::this_thread::sleep(boost::posix_time::milliseconds(50));
- // readThread is practically guaranteed to be blocking now
- sock1.interruptChildren();
- BOOST_CHECK_MESSAGE(readThread.try_join_for(boost::chrono::milliseconds(200)),
- "server socket interruptChildren did not interrupt child read");
- clientSock.close();
- accepted->close();
- sock1.close();
+BOOST_AUTO_TEST_CASE(test_non_interruptable_child_read) {
+ TServerSocket sock1("localhost", m_serverPort);
+ sock1.setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior
+ sock1.listen();
+ TSocket clientSock("localhost", m_serverPort);
+ clientSock.open();
+ boost::shared_ptr<TTransport> accepted = sock1.accept();
+ boost::thread readThread(boost::bind(readerWorker, accepted, 0));
+ boost::this_thread::sleep(boost::posix_time::milliseconds(50));
+ // readThread is practically guaranteed to be blocking here
+ sock1.interruptChildren();
+ BOOST_CHECK_MESSAGE(!readThread.try_join_for(boost::chrono::milliseconds(200)),
+ "server socket interruptChildren interrupted child read");
+
+ // only way to proceed is to have the client disconnect
+ clientSock.close();
+ readThread.join();
+ accepted->close();
+ sock1.close();
}
-BOOST_AUTO_TEST_CASE( test_non_interruptable_child_read )
-{
- TServerSocket sock1("localhost", m_serverPort);
- sock1.setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior
- sock1.listen();
- TSocket clientSock("localhost", m_serverPort);
- clientSock.open();
- boost::shared_ptr<TTransport> accepted = sock1.accept();
- boost::thread readThread(boost::bind(readerWorker, accepted, 0));
- boost::this_thread::sleep(boost::posix_time::milliseconds(50));
- // readThread is practically guaranteed to be blocking here
- sock1.interruptChildren();
- BOOST_CHECK_MESSAGE(!readThread.try_join_for(boost::chrono::milliseconds(200)),
- "server socket interruptChildren interrupted child read");
-
- // only way to proceed is to have the client disconnect
- clientSock.close();
- readThread.join();
- accepted->close();
- sock1.close();
+BOOST_AUTO_TEST_CASE(test_cannot_change_after_listen) {
+ TServerSocket sock1("localhost", m_serverPort);
+ sock1.listen();
+ BOOST_CHECK_THROW(sock1.setInterruptableChildren(false), std::logic_error);
+ sock1.close();
}
-BOOST_AUTO_TEST_CASE( test_cannot_change_after_listen )
-{
- TServerSocket sock1("localhost", m_serverPort);
- sock1.listen();
- BOOST_CHECK_THROW(sock1.setInterruptableChildren(false), std::logic_error);
- sock1.close();
+void peekerWorker(boost::shared_ptr<TTransport> tt, bool expectedResult) {
+ BOOST_CHECK_EQUAL(expectedResult, tt->peek());
}
-void peekerWorker(boost::shared_ptr<TTransport> tt, bool expectedResult)
-{
- BOOST_CHECK_EQUAL(expectedResult, tt->peek());
+BOOST_AUTO_TEST_CASE(test_interruptable_child_peek) {
+ TServerSocket sock1("localhost", m_serverPort);
+ sock1.listen();
+ TSocket clientSock("localhost", m_serverPort);
+ clientSock.open();
+ boost::shared_ptr<TTransport> accepted = sock1.accept();
+ // peek() will return false if child is interrupted
+ boost::thread peekThread(boost::bind(peekerWorker, accepted, false));
+ boost::this_thread::sleep(boost::posix_time::milliseconds(50));
+ // peekThread is practically guaranteed to be blocking now
+ sock1.interruptChildren();
+ BOOST_CHECK_MESSAGE(peekThread.try_join_for(boost::chrono::milliseconds(200)),
+ "server socket interruptChildren did not interrupt child peek");
+ clientSock.close();
+ accepted->close();
+ sock1.close();
}
-BOOST_AUTO_TEST_CASE( test_interruptable_child_peek )
-{
- TServerSocket sock1("localhost", m_serverPort);
- sock1.listen();
- TSocket clientSock("localhost", m_serverPort);
- clientSock.open();
- boost::shared_ptr<TTransport> accepted = sock1.accept();
- // peek() will return false if child is interrupted
- boost::thread peekThread(boost::bind(peekerWorker, accepted, false));
- boost::this_thread::sleep(boost::posix_time::milliseconds(50));
- // peekThread is practically guaranteed to be blocking now
- sock1.interruptChildren();
- BOOST_CHECK_MESSAGE(peekThread.try_join_for(boost::chrono::milliseconds(200)),
- "server socket interruptChildren did not interrupt child peek");
- clientSock.close();
- accepted->close();
- sock1.close();
-}
+BOOST_AUTO_TEST_CASE(test_non_interruptable_child_peek) {
+ TServerSocket sock1("localhost", m_serverPort);
+ sock1.setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior
+ sock1.listen();
+ TSocket clientSock("localhost", m_serverPort);
+ clientSock.open();
+ boost::shared_ptr<TTransport> accepted = sock1.accept();
+ // peek() will return false when remote side is closed
+ boost::thread peekThread(boost::bind(peekerWorker, accepted, false));
+ boost::this_thread::sleep(boost::posix_time::milliseconds(50));
+ // peekThread is practically guaranteed to be blocking now
+ sock1.interruptChildren();
+ BOOST_CHECK_MESSAGE(!peekThread.try_join_for(boost::chrono::milliseconds(200)),
+ "server socket interruptChildren interrupted child peek");
-BOOST_AUTO_TEST_CASE( test_non_interruptable_child_peek )
-{
- TServerSocket sock1("localhost", m_serverPort);
- sock1.setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior
- sock1.listen();
- TSocket clientSock("localhost", m_serverPort);
- clientSock.open();
- boost::shared_ptr<TTransport> accepted = sock1.accept();
- // peek() will return false when remote side is closed
- boost::thread peekThread(boost::bind(peekerWorker, accepted, false));
- boost::this_thread::sleep(boost::posix_time::milliseconds(50));
- // peekThread is practically guaranteed to be blocking now
- sock1.interruptChildren();
- BOOST_CHECK_MESSAGE(!peekThread.try_join_for(boost::chrono::milliseconds(200)),
- "server socket interruptChildren interrupted child peek");
-
- // only way to proceed is to have the client disconnect
- clientSock.close();
- peekThread.join();
- accepted->close();
- sock1.close();
+ // only way to proceed is to have the client disconnect
+ clientSock.close();
+ peekThread.join();
+ accepted->close();
+ sock1.close();
}
BOOST_AUTO_TEST_SUITE_END()
-