From 09570996a97904bc7006ad7e05f9c57fc1932e06 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Tue, 4 Mar 2014 14:56:48 -0500 Subject: [PATCH] Fix beast::asio failures on OS X. There are 38 unittest failures on OS X. These changes address all of them by adjusting which side of the socket (send or receive) gets shut down. In each case, the failure was 'Socket is not connected'. I've interpreted that to mean that the other thread had already shut down its side of the connection. --- .../modules/beast_asio/tests/TestPeerLogicAsyncClient.cpp | 4 ++-- .../modules/beast_asio/tests/TestPeerLogicAsyncServer.cpp | 4 ++-- .../modules/beast_asio/tests/TestPeerLogicSyncClient.cpp | 3 ++- .../modules/beast_asio/tests/TestPeerLogicSyncServer.cpp | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/beast/modules/beast_asio/tests/TestPeerLogicAsyncClient.cpp b/src/beast/modules/beast_asio/tests/TestPeerLogicAsyncClient.cpp index 0b6f585233..f6a4b339ad 100644 --- a/src/beast/modules/beast_asio/tests/TestPeerLogicAsyncClient.cpp +++ b/src/beast/modules/beast_asio/tests/TestPeerLogicAsyncClient.cpp @@ -108,7 +108,7 @@ void TestPeerLogicAsyncClient::on_read_final (error_code const& ec, std::size_t) { // on_shutdown will call finished () error_code ec; - on_shutdown (socket ().shutdown (Socket::shutdown_both, ec)); + on_shutdown (socket ().shutdown (Socket::shutdown_send, ec)); } } else @@ -137,7 +137,7 @@ void TestPeerLogicAsyncClient::on_shutdown (error_code const& ec) { if (socket ().needs_handshake ()) { - socket ().shutdown (Socket::shutdown_both, error ()); + socket ().shutdown (Socket::shutdown_send, error ()); } if (! error ()) diff --git a/src/beast/modules/beast_asio/tests/TestPeerLogicAsyncServer.cpp b/src/beast/modules/beast_asio/tests/TestPeerLogicAsyncServer.cpp index c290b54135..8fbf38a397 100644 --- a/src/beast/modules/beast_asio/tests/TestPeerLogicAsyncServer.cpp +++ b/src/beast/modules/beast_asio/tests/TestPeerLogicAsyncServer.cpp @@ -90,7 +90,7 @@ void TestPeerLogicAsyncServer::on_write (error_code const& ec, std::size_t bytes // on_shutdown will call finished () // we need another instance of ec so we can call on_shutdown() error_code ec; - on_shutdown (socket ().shutdown (Socket::shutdown_both, ec)); + on_shutdown (socket ().shutdown (Socket::shutdown_receive, ec)); } } @@ -102,7 +102,7 @@ void TestPeerLogicAsyncServer::on_shutdown (error_code const& ec) { if (socket ().needs_handshake ()) { - socket ().shutdown (Socket::shutdown_both, error ()); + socket ().shutdown (Socket::shutdown_receive, error ()); } if (success (socket ().close (error ()))) diff --git a/src/beast/modules/beast_asio/tests/TestPeerLogicSyncClient.cpp b/src/beast/modules/beast_asio/tests/TestPeerLogicSyncClient.cpp index 4fa98893a2..eb187c8660 100644 --- a/src/beast/modules/beast_asio/tests/TestPeerLogicSyncClient.cpp +++ b/src/beast/modules/beast_asio/tests/TestPeerLogicSyncClient.cpp @@ -94,9 +94,10 @@ void TestPeerLogicSyncClient::on_connect () { if (failure (socket ().shutdown (error ()), true)) return; + error () = error_code (); } - if (failure (socket ().shutdown (Socket::shutdown_both, error ()))) + if (failure (socket ().shutdown (Socket::shutdown_send, error ()))) return; if (failure (socket ().close (error ()))) diff --git a/src/beast/modules/beast_asio/tests/TestPeerLogicSyncServer.cpp b/src/beast/modules/beast_asio/tests/TestPeerLogicSyncServer.cpp index a1358c83f9..cb64f3df3b 100644 --- a/src/beast/modules/beast_asio/tests/TestPeerLogicSyncServer.cpp +++ b/src/beast/modules/beast_asio/tests/TestPeerLogicSyncServer.cpp @@ -72,7 +72,7 @@ void TestPeerLogicSyncServer::on_connect () return; } - if (failure (socket ().shutdown (Socket::shutdown_both, error ()))) + if (failure (socket ().shutdown (Socket::shutdown_send, error ()))) return; if (failure (socket ().close (error ())))