|
Boost-Commit : |
From: chris_at_[hidden]
Date: 2007-11-13 07:50:28
Author: chris_kohlhoff
Date: 2007-11-13 07:50:27 EST (Tue, 13 Nov 2007)
New Revision: 41059
URL: http://svn.boost.org/trac/boost/changeset/41059
Log:
Add a workaround for MSVC secure iterator problem where allowing the
destruction of an iterator to an already-destroyed string object results in
a program crash. Revert previous change to destroy buffers prior to
invoking the handler since it didn't fix the problem and wasn't cleaning
up all copies of the buffers anyway.
Text files modified:
trunk/boost/asio/buffer.hpp | 7 ++++++-
trunk/boost/asio/impl/read.ipp | 20 ++++++++------------
trunk/boost/asio/impl/write.ipp | 18 ++++++------------
3 files changed, 20 insertions(+), 25 deletions(-)
Modified: trunk/boost/asio/buffer.hpp
==============================================================================
--- trunk/boost/asio/buffer.hpp (original)
+++ trunk/boost/asio/buffer.hpp 2007-11-13 07:50:27 EST (Tue, 13 Nov 2007)
@@ -27,7 +27,7 @@
#include <boost/asio/detail/pop_options.hpp>
#if defined(BOOST_MSVC)
-# if defined(_HAS_ITERATOR_DEBUGGING)
+# if defined(_HAS_ITERATOR_DEBUGGING) && (_HAS_ITERATOR_DEBUGGING != 0)
# if !defined(BOOST_ASIO_DISABLE_BUFFER_DEBUGGING)
# define BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
# endif // !defined(BOOST_ASIO_DISABLE_BUFFER_DEBUGGING)
@@ -391,6 +391,11 @@
{
}
+ ~buffer_debug_check()
+ {
+ iter_ = Iterator();
+ }
+
void operator()()
{
*iter_;
Modified: trunk/boost/asio/impl/read.ipp
==============================================================================
--- trunk/boost/asio/impl/read.ipp (original)
+++ trunk/boost/asio/impl/read.ipp 2007-11-13 07:50:27 EST (Tue, 13 Nov 2007)
@@ -19,7 +19,6 @@
#include <boost/asio/detail/push_options.hpp>
#include <algorithm>
-#include <boost/optional.hpp>
#include <boost/asio/detail/pop_options.hpp>
#include <boost/asio/buffer.hpp>
@@ -140,25 +139,23 @@
std::size_t bytes_transferred)
{
total_transferred_ += bytes_transferred;
- buffers_->consume(bytes_transferred);
- if ((*completion_condition_)(ec, total_transferred_)
- || buffers_->begin() == buffers_->end())
+ buffers_.consume(bytes_transferred);
+ if (completion_condition_(ec, total_transferred_)
+ || buffers_.begin() == buffers_.end())
{
- buffers_.reset();
- completion_condition_.reset();
handler_(ec, total_transferred_);
}
else
{
- stream_.async_read_some(*buffers_, *this);
+ stream_.async_read_some(buffers_, *this);
}
}
//private:
AsyncReadStream& stream_;
- boost::optional<buffers_type> buffers_;
+ buffers_type buffers_;
std::size_t total_transferred_;
- boost::optional<CompletionCondition> completion_condition_;
+ CompletionCondition completion_condition_;
ReadHandler handler_;
};
@@ -239,9 +236,8 @@
total_transferred_ += bytes_transferred;
streambuf_.commit(bytes_transferred);
if (streambuf_.size() == streambuf_.max_size()
- || (*completion_condition_)(ec, total_transferred_))
+ || completion_condition_(ec, total_transferred_))
{
- completion_condition_.reset();
handler_(ec, total_transferred_);
}
else
@@ -256,7 +252,7 @@
AsyncReadStream& stream_;
boost::asio::basic_streambuf<Allocator>& streambuf_;
std::size_t total_transferred_;
- boost::optional<CompletionCondition> completion_condition_;
+ CompletionCondition completion_condition_;
ReadHandler handler_;
};
Modified: trunk/boost/asio/impl/write.ipp
==============================================================================
--- trunk/boost/asio/impl/write.ipp (original)
+++ trunk/boost/asio/impl/write.ipp 2007-11-13 07:50:27 EST (Tue, 13 Nov 2007)
@@ -17,10 +17,6 @@
#include <boost/asio/detail/push_options.hpp>
-#include <boost/asio/detail/push_options.hpp>
-#include <boost/optional.hpp>
-#include <boost/asio/detail/pop_options.hpp>
-
#include <boost/asio/buffer.hpp>
#include <boost/asio/completion_condition.hpp>
#include <boost/asio/detail/bind_handler.hpp>
@@ -129,25 +125,23 @@
std::size_t bytes_transferred)
{
total_transferred_ += bytes_transferred;
- buffers_->consume(bytes_transferred);
- if ((*completion_condition_)(ec, total_transferred_)
- || buffers_->begin() == buffers_->end())
+ buffers_.consume(bytes_transferred);
+ if (completion_condition_(ec, total_transferred_)
+ || buffers_.begin() == buffers_.end())
{
- buffers_.reset();
- completion_condition_.reset();
handler_(ec, total_transferred_);
}
else
{
- stream_.async_write_some(*buffers_, *this);
+ stream_.async_write_some(buffers_, *this);
}
}
//private:
AsyncWriteStream& stream_;
- boost::optional<buffers_type> buffers_;
+ buffers_type buffers_;
std::size_t total_transferred_;
- boost::optional<CompletionCondition> completion_condition_;
+ CompletionCondition completion_condition_;
WriteHandler handler_;
};
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