BIND 10 trac499, updated. a0d91794e105108425429a6ab9eed196171955eb [trac499] Modify send size in tests
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Mar 9 14:41:44 UTC 2011
The branch, trac499 has been updated
via a0d91794e105108425429a6ab9eed196171955eb (commit)
via db57bdd2f3f73b7d4048fec614f0a3db73c8489a (commit)
from 87d58087b71b509d9798bd700b9ba968712e142d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a0d91794e105108425429a6ab9eed196171955eb
Author: Stephen Morris <stephen at isc.org>
Date: Wed Mar 9 14:40:20 2011 +0000
[trac499] Modify send size in tests
In the IOFetch unit test, modify the send buffer size to match the
size of the TCP socket send buffer in a bid to solve problems with
the test on FreeBSD.
commit db57bdd2f3f73b7d4048fec614f0a3db73c8489a
Author: Stephen Morris <stephen at isc.org>
Date: Wed Mar 9 14:19:36 2011 +0000
[trac499] Add missing newlines to the end of some files
... which causes Solaris to complain - loudly.
-----------------------------------------------------------------------
Summary of changes:
src/lib/asiolink/asiolink.h | 2 +-
src/lib/asiolink/io_address.h | 2 +-
src/lib/asiolink/io_endpoint.h | 2 +-
src/lib/asiolink/tests/io_fetch_unittest.cc | 37 +++++++++++++++++++-----
src/lib/asiolink/tests/tcp_socket_unittest.cc | 2 +-
5 files changed, 33 insertions(+), 12 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/asiolink/asiolink.h b/src/lib/asiolink/asiolink.h
index 86c55dc..251413e 100644
--- a/src/lib/asiolink/asiolink.h
+++ b/src/lib/asiolink/asiolink.h
@@ -84,4 +84,4 @@
/// the placeholder of callback handlers:
/// http://think-async.com/Asio/asio-1.3.1/doc/asio/reference/asio_handler_allocate.html
-#endif // __ASIOLINK_H
\ No newline at end of file
+#endif // __ASIOLINK_H
diff --git a/src/lib/asiolink/io_address.h b/src/lib/asiolink/io_address.h
index 07caafe..d759827 100644
--- a/src/lib/asiolink/io_address.h
+++ b/src/lib/asiolink/io_address.h
@@ -120,4 +120,4 @@ private:
};
} // asiolink
-#endif // __IO_ADDRESS_H
\ No newline at end of file
+#endif // __IO_ADDRESS_H
diff --git a/src/lib/asiolink/io_endpoint.h b/src/lib/asiolink/io_endpoint.h
index 20bf0f8..2ec4083 100644
--- a/src/lib/asiolink/io_endpoint.h
+++ b/src/lib/asiolink/io_endpoint.h
@@ -115,4 +115,4 @@ public:
};
} // asiolink
-#endif // __IO_ENDPOINT_H
\ No newline at end of file
+#endif // __IO_ENDPOINT_H
diff --git a/src/lib/asiolink/tests/io_fetch_unittest.cc b/src/lib/asiolink/tests/io_fetch_unittest.cc
index 4282c80..4ef0683 100644
--- a/src/lib/asiolink/tests/io_fetch_unittest.cc
+++ b/src/lib/asiolink/tests/io_fetch_unittest.cc
@@ -54,7 +54,7 @@ const size_t MAX_SIZE = 64 * 1024; // Should be able to take 64kB
// The tests are complex, so debug output has been left in (although disabled).
// Set this to true to enable it.
-const bool DEBUG = false;
+const bool DEBUG = true;
/// \brief Test fixture for the asiolink::IOFetch.
class IOFetchTest : public virtual ::testing::Test, public virtual IOFetch::Callback
@@ -83,6 +83,7 @@ public:
string return_data_; ///< Data returned by server
string test_data_; ///< Large string - here for convenience
bool debug_; ///< true to enable debug output
+ size_t tcp_send_size_; ///< Max size of TCP send
/// \brief Constructor
IOFetchTest() :
@@ -95,7 +96,7 @@ public:
udp_fetch_(IOFetch::UDP, service_, question_, IOAddress(TEST_HOST),
TEST_PORT, result_buff_, this, 100),
tcp_fetch_(IOFetch::TCP, service_, question_, IOAddress(TEST_HOST),
- TEST_PORT, result_buff_, this, (4 * SEND_INTERVAL)),
+ TEST_PORT, result_buff_, this, (16 * SEND_INTERVAL)),
// Timeout interval chosen to ensure no timeout
protocol_(IOFetch::TCP), // for initialization - will be changed
cumulative_(0),
@@ -105,7 +106,8 @@ public:
send_cumulative_(0),
return_data_(""),
test_data_(""),
- debug_(DEBUG)
+ debug_(DEBUG),
+ tcp_send_size_(0)
{
// Construct the data buffer for question we expect to receive.
Message msg(Message::RENDER);
@@ -182,6 +184,19 @@ public:
// Expect that the accept completed without a problem.
EXPECT_EQ(0, ec.value());
+ // Work out the maximum size of data we can send over it when we
+ // respond, then subtract 1kB or so for safety.
+ tcp::socket::send_buffer_size send_size;
+ socket->get_option(send_size);
+ if (send_size.value() < (2 * 1024)) {
+ FAIL() << "TCP send size is less than 2kB";
+ } else {
+ tcp_send_size_ = send_size.value() - 1024;
+ if (debug_) {
+ cout << "tcpacceptHandler(): will use send size = " << tcp_send_size_ << endl;
+ }
+ }
+
// Initiate a read on the socket.
cumulative_ = 0;
socket->async_receive(asio::buffer(receive_buffer_, sizeof(receive_buffer_)),
@@ -274,12 +289,18 @@ public:
} else {
- // Third time through, send the remainder.
- amount = send_buffer_.size() - send_cumulative_;
+ // For all subsequent times, send the remainder, maximised to
+ // whatever we have chosen for the maximum send size.
+ amount = min(tcp_send_size_,
+ (send_buffer_.size() - send_cumulative_));
}
+ if (debug_) {
+ cout << "tcpSendData(): sending " << amount << " bytes" << endl;
+ }
+
- // ... and send it. The amount sent is also passed as the first argument
- // of the send callback, as a check.
+ // ... and send it. The amount sent is also passed as the first
+ // argument of the send callback, as a check.
socket->async_send(asio::buffer(send_ptr, amount),
boost::bind(&IOFetchTest::tcpSendHandler, this,
amount, socket, _1, _2));
@@ -435,7 +456,7 @@ public:
protocol_ = IOFetch::TCP;
expected_ = IOFetch::SUCCESS;
- // Socket into which the connection will be accepted
+ // Socket into which the connection will be accepted.
tcp::socket socket(service_.get_io_service());
// Acceptor object - called when the connection is made, the handler
diff --git a/src/lib/asiolink/tests/tcp_socket_unittest.cc b/src/lib/asiolink/tests/tcp_socket_unittest.cc
index cbaa209..11267c9 100644
--- a/src/lib/asiolink/tests/tcp_socket_unittest.cc
+++ b/src/lib/asiolink/tests/tcp_socket_unittest.cc
@@ -511,4 +511,4 @@ TEST(TCPSocket, SequenceTest) {
// Close client and server.
EXPECT_NO_THROW(client.close());
EXPECT_NO_THROW(server_socket.close());
-}
\ No newline at end of file
+}
More information about the bind10-changes
mailing list