|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62558 - in trunk: boost/asio/detail libs/asio/test
From: chris_at_[hidden]
Date: 2010-06-08 07:01:57
Author: chris_kohlhoff
Date: 2010-06-08 07:01:57 EDT (Tue, 08 Jun 2010)
New Revision: 62558
URL: http://svn.boost.org/trac/boost/changeset/62558
Log:
Fix handling of empty buffer sequences.
Text files modified:
trunk/boost/asio/detail/consuming_buffers.hpp | 4 +++-
trunk/libs/asio/test/read.cpp | 12 ++++++++++++
trunk/libs/asio/test/write.cpp | 12 ++++++++++++
3 files changed, 27 insertions(+), 1 deletions(-)
Modified: trunk/boost/asio/detail/consuming_buffers.hpp
==============================================================================
--- trunk/boost/asio/detail/consuming_buffers.hpp (original)
+++ trunk/boost/asio/detail/consuming_buffers.hpp 2010-06-08 07:01:57 EDT (Tue, 08 Jun 2010)
@@ -153,12 +153,14 @@
consuming_buffers(const Buffers& buffers)
: buffers_(buffers),
at_end_(buffers_.begin() == buffers_.end()),
- first_(*buffers_.begin()),
begin_remainder_(buffers_.begin()),
max_size_((std::numeric_limits<std::size_t>::max)())
{
if (!at_end_)
+ {
+ first_ = *buffers_.begin();
++begin_remainder_;
+ }
}
// Copy constructor.
Modified: trunk/libs/asio/test/read.cpp
==============================================================================
--- trunk/libs/asio/test/read.cpp (original)
+++ trunk/libs/asio/test/read.cpp 2010-06-08 07:01:57 EDT (Tue, 08 Jun 2010)
@@ -20,6 +20,7 @@
#include <boost/bind.hpp>
#include <boost/noncopyable.hpp>
#include <cstring>
+#include <vector>
#include <boost/asio/io_service.hpp>
#include <boost/asio/placeholders.hpp>
#include <boost/asio/streambuf.hpp>
@@ -136,6 +137,16 @@
static const char read_data[]
= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+void test_2_arg_zero_buffers_read()
+{
+ boost::asio::io_service ios;
+ test_stream s(ios);
+ std::vector<boost::asio::mutable_buffer> buffers;
+
+ size_t bytes_transferred = boost::asio::read(s, buffers);
+ BOOST_CHECK(bytes_transferred == 0);
+}
+
void test_2_arg_mutable_buffers_1_read()
{
boost::asio::io_service ios;
@@ -2173,6 +2184,7 @@
test_suite* init_unit_test_suite(int, char*[])
{
test_suite* test = BOOST_TEST_SUITE("read");
+ test->add(BOOST_TEST_CASE(&test_2_arg_zero_buffers_read));
test->add(BOOST_TEST_CASE(&test_2_arg_mutable_buffers_1_read));
test->add(BOOST_TEST_CASE(&test_2_arg_multi_buffers_read));
test->add(BOOST_TEST_CASE(&test_2_arg_streambuf_read));
Modified: trunk/libs/asio/test/write.cpp
==============================================================================
--- trunk/libs/asio/test/write.cpp (original)
+++ trunk/libs/asio/test/write.cpp 2010-06-08 07:01:57 EDT (Tue, 08 Jun 2010)
@@ -20,6 +20,7 @@
#include <boost/bind.hpp>
#include <boost/noncopyable.hpp>
#include <cstring>
+#include <vector>
#include <boost/asio/io_service.hpp>
#include <boost/asio/placeholders.hpp>
#include "unit_test.hpp"
@@ -138,6 +139,16 @@
static char mutable_write_data[]
= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+void test_2_arg_zero_buffers_write()
+{
+ boost::asio::io_service ios;
+ test_stream s(ios);
+ std::vector<boost::asio::const_buffer> buffers;
+
+ size_t bytes_transferred = boost::asio::write(s, buffers);
+ BOOST_CHECK(bytes_transferred == 0);
+}
+
void test_2_arg_const_buffers_1_write()
{
boost::asio::io_service ios;
@@ -1930,6 +1941,7 @@
test_suite* init_unit_test_suite(int, char*[])
{
test_suite* test = BOOST_TEST_SUITE("write");
+ test->add(BOOST_TEST_CASE(&test_2_arg_zero_buffers_write));
test->add(BOOST_TEST_CASE(&test_2_arg_const_buffers_1_write));
test->add(BOOST_TEST_CASE(&test_2_arg_mutable_buffers_1_write));
test->add(BOOST_TEST_CASE(&test_2_arg_multi_buffers_write));
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk