Fix composed read/write operations when multiple buffers are supplied.

This commit is contained in:
Christopher Kohlhoff 2017-01-13 09:42:23 +11:00
parent 14db6371b3
commit bc6e494d2d
3 changed files with 25 additions and 13 deletions

View File

@ -101,7 +101,7 @@ public:
Buffer_Iterator next = asio::buffer_sequence_begin(buffers_);
Buffer_Iterator end = asio::buffer_sequence_end(buffers_);
std::advance(end, next_elem_);
std::advance(next, next_elem_);
while (next != end && size > 0)
{
Buffer next_buf = Buffer(*next) + next_elem_offset_;

View File

@ -187,7 +187,8 @@ void test_2_arg_vector_buffers_read()
char read_buf[sizeof(read_data)];
std::vector<asio::mutable_buffer> buffers;
buffers.push_back(asio::buffer(read_buf, 32));
buffers.push_back(asio::buffer(read_buf) + 32);
buffers.push_back(asio::buffer(read_buf, 39) + 32);
buffers.push_back(asio::buffer(read_buf) + 39);
s.reset(read_data, sizeof(read_data));
memset(read_buf, 0, sizeof(read_buf));
@ -292,7 +293,8 @@ void test_3_arg_nothrow_vector_buffers_read()
char read_buf[sizeof(read_data)];
std::vector<asio::mutable_buffer> buffers;
buffers.push_back(asio::buffer(read_buf, 32));
buffers.push_back(asio::buffer(read_buf) + 32);
buffers.push_back(asio::buffer(read_buf, 39) + 32);
buffers.push_back(asio::buffer(read_buf) + 39);
s.reset(read_data, sizeof(read_data));
memset(read_buf, 0, sizeof(read_buf));
@ -582,7 +584,8 @@ void test_3_arg_vector_buffers_read()
char read_buf[sizeof(read_data)];
std::vector<asio::mutable_buffer> buffers;
buffers.push_back(asio::buffer(read_buf, 32));
buffers.push_back(asio::buffer(read_buf) + 32);
buffers.push_back(asio::buffer(read_buf, 39) + 32);
buffers.push_back(asio::buffer(read_buf) + 39);
s.reset(read_data, sizeof(read_data));
memset(read_buf, 0, sizeof(read_buf));
@ -1293,7 +1296,8 @@ void test_4_arg_vector_buffers_read()
char read_buf[sizeof(read_data)];
std::vector<asio::mutable_buffer> buffers;
buffers.push_back(asio::buffer(read_buf, 32));
buffers.push_back(asio::buffer(read_buf) + 32);
buffers.push_back(asio::buffer(read_buf, 39) + 32);
buffers.push_back(asio::buffer(read_buf) + 39);
s.reset(read_data, sizeof(read_data));
memset(read_buf, 0, sizeof(read_buf));
@ -2051,7 +2055,8 @@ void test_3_arg_vector_buffers_async_read()
char read_buf[sizeof(read_data)];
std::vector<asio::mutable_buffer> buffers;
buffers.push_back(asio::buffer(read_buf, 32));
buffers.push_back(asio::buffer(read_buf) + 32);
buffers.push_back(asio::buffer(read_buf, 39) + 32);
buffers.push_back(asio::buffer(read_buf) + 39);
s.reset(read_data, sizeof(read_data));
memset(read_buf, 0, sizeof(read_buf));
@ -3203,7 +3208,8 @@ void test_4_arg_vector_buffers_async_read()
char read_buf[sizeof(read_data)];
std::vector<asio::mutable_buffer> buffers;
buffers.push_back(asio::buffer(read_buf, 32));
buffers.push_back(asio::buffer(read_buf) + 32);
buffers.push_back(asio::buffer(read_buf, 39) + 32);
buffers.push_back(asio::buffer(read_buf) + 39);
s.reset(read_data, sizeof(read_data));
memset(read_buf, 0, sizeof(read_buf));

View File

@ -209,7 +209,8 @@ void test_2_arg_vector_buffers_write()
test_stream s(ioc);
std::vector<asio::const_buffer> buffers;
buffers.push_back(asio::buffer(write_data, 32));
buffers.push_back(asio::buffer(write_data) + 32);
buffers.push_back(asio::buffer(write_data, 39) + 32);
buffers.push_back(asio::buffer(write_data) + 39);
s.reset();
size_t bytes_transferred = asio::write(s, buffers);
@ -305,7 +306,8 @@ void test_3_arg_nothrow_vector_buffers_write()
test_stream s(ioc);
std::vector<asio::const_buffer> buffers;
buffers.push_back(asio::buffer(write_data, 32));
buffers.push_back(asio::buffer(write_data) + 32);
buffers.push_back(asio::buffer(write_data, 39) + 32);
buffers.push_back(asio::buffer(write_data) + 39);
s.reset();
asio::error_code error;
@ -711,7 +713,8 @@ void test_3_arg_vector_buffers_write()
test_stream s(ioc);
std::vector<asio::const_buffer> buffers;
buffers.push_back(asio::buffer(write_data, 32));
buffers.push_back(asio::buffer(write_data) + 32);
buffers.push_back(asio::buffer(write_data, 39) + 32);
buffers.push_back(asio::buffer(write_data) + 39);
s.reset();
size_t bytes_transferred = asio::write(s, buffers,
@ -1368,7 +1371,8 @@ void test_4_arg_vector_buffers_write()
test_stream s(ioc);
std::vector<asio::const_buffer> buffers;
buffers.push_back(asio::buffer(write_data, 32));
buffers.push_back(asio::buffer(write_data) + 32);
buffers.push_back(asio::buffer(write_data, 39) + 32);
buffers.push_back(asio::buffer(write_data) + 39);
s.reset();
asio::error_code error;
@ -1848,7 +1852,8 @@ void test_3_arg_vector_buffers_async_write()
test_stream s(ioc);
std::vector<asio::const_buffer> buffers;
buffers.push_back(asio::buffer(write_data, 32));
buffers.push_back(asio::buffer(write_data) + 32);
buffers.push_back(asio::buffer(write_data, 39) + 32);
buffers.push_back(asio::buffer(write_data) + 39);
s.reset();
bool called = false;
@ -3222,7 +3227,8 @@ void test_4_arg_vector_buffers_async_write()
test_stream s(ioc);
std::vector<asio::const_buffer> buffers;
buffers.push_back(asio::buffer(write_data, 32));
buffers.push_back(asio::buffer(write_data) + 32);
buffers.push_back(asio::buffer(write_data, 39) + 32);
buffers.push_back(asio::buffer(write_data) + 39);
s.reset();
bool called = false;