diff --git a/src/asio.cpp b/src/asio.cpp index 1313ed7..d596e84 100644 --- a/src/asio.cpp +++ b/src/asio.cpp @@ -99,6 +99,7 @@ namespace fc { default_io_service_scope() { + cleanup_complete = false; io = new boost::asio::io_service(); the_work = new boost::asio::io_service::work(*io); for( int i = 0; i < 8; ++i ) { @@ -146,10 +147,16 @@ namespace fc { for( auto asio_thread : asio_threads ) { delete asio_thread; } + cleanup_complete = true; } ~default_io_service_scope() - {} + { + if (!cleanup_complete) + cleanup(); + } + private: + bool cleanup_complete; }; /// If cleanup is true, do not use the return value; it is a null reference diff --git a/src/network/tcp_socket.cpp b/src/network/tcp_socket.cpp index 1c980fc..57b9adf 100644 --- a/src/network/tcp_socket.cpp +++ b/src/network/tcp_socket.cpp @@ -90,7 +90,7 @@ namespace fc { tcp_socket::tcp_socket(){}; - tcp_socket::~tcp_socket(){}; + tcp_socket::~tcp_socket() {} void tcp_socket::flush() {} void tcp_socket::close() { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 40f3fe6..ae6ea92 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -51,6 +51,7 @@ add_executable( all_tests all_tests.cpp crypto/sha_tests.cpp io/json_tests.cpp io/stream_tests.cpp + io/tcp_test.cpp network/http/websocket_test.cpp thread/task_cancel.cpp thread/thread_tests.cpp diff --git a/tests/io/tcp_test.cpp b/tests/io/tcp_test.cpp new file mode 100644 index 0000000..535e607 --- /dev/null +++ b/tests/io/tcp_test.cpp @@ -0,0 +1,12 @@ +#include + +#include + +BOOST_AUTO_TEST_SUITE(tcp_tests) + +BOOST_AUTO_TEST_CASE(tcpconstructor_test) +{ + fc::tcp_socket socket; +} + +BOOST_AUTO_TEST_SUITE_END()