Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85781 - in trunk/boost/asio/detail: . impl
From: chris_at_[hidden]
Date: 2013-09-18 18:43:01


Author: chris_kohlhoff
Date: 2013-09-18 18:43:01 EDT (Wed, 18 Sep 2013)
New Revision: 85781
URL: http://svn.boost.org/trac/boost/changeset/85781

Log:
Implement end-of-file condition for WinRT stream sockets.

Text files modified:
   trunk/boost/asio/detail/impl/winrt_ssocket_service_base.ipp | 8 +++++++-
   trunk/boost/asio/detail/winrt_socket_recv_op.hpp | 10 ++++++++--
   2 files changed, 15 insertions(+), 3 deletions(-)

Modified: trunk/boost/asio/detail/impl/winrt_ssocket_service_base.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/winrt_ssocket_service_base.ipp Wed Sep 18 18:40:25 2013 (r85780)
+++ trunk/boost/asio/detail/impl/winrt_ssocket_service_base.ipp 2013-09-18 18:43:01 EDT (Wed, 18 Sep 2013) (r85781)
@@ -543,7 +543,13 @@
           bufs.buffers()[0], bufs.buffers()[0]->Capacity,
           Windows::Storage::Streams::InputStreamOptions::Partial), ec);
 
- return bufs.buffers()[0]->Length;
+ std::size_t bytes_transferred = bufs.buffers()[0]->Length;
+ if (bytes_transferred == 0 && !ec)
+ {
+ ec = boost::asio::error::eof;
+ }
+
+ return bytes_transferred;
   }
   catch (Platform::Exception^ e)
   {

Modified: trunk/boost/asio/detail/winrt_socket_recv_op.hpp
==============================================================================
--- trunk/boost/asio/detail/winrt_socket_recv_op.hpp Wed Sep 18 18:40:25 2013 (r85780)
+++ trunk/boost/asio/detail/winrt_socket_recv_op.hpp 2013-09-18 18:43:01 EDT (Wed, 18 Sep 2013) (r85781)
@@ -67,7 +67,13 @@
     }
 #endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
 
- // TODO check for end-of-file.
+ std::size_t bytes_transferred = o->result_ ? o->result_->Length : 0;
+ if (bytes_transferred == 0 && !o->ec_ &&
+ !buffer_sequence_adapter<boost::asio::mutable_buffer,
+ MutableBufferSequence>::all_empty(o->buffers_))
+ {
+ o->ec_ = boost::asio::error::eof;
+ }
 
     // Make a copy of the handler so that the memory can be deallocated before
     // the upcall is made. Even if we're not about to make an upcall, a
@@ -76,7 +82,7 @@
     // to ensure that any owning sub-object remains valid until after we have
     // deallocated the memory here.
     detail::binder2<Handler, boost::system::error_code, std::size_t>
- handler(o->handler_, o->ec_, o->result_ ? o->result_->Length : 0);
+ handler(o->handler_, o->ec_, bytes_transferred);
     p.h = boost::asio::detail::addressof(handler.handler_);
     p.reset();
 


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