Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84895 - in branches/release: boost/asio boost/asio/detail boost/asio/detail/impl boost/asio/impl boost/asio/ssl/impl libs/asio/doc
From: chris_at_[hidden]
Date: 2013-06-23 19:34:42


Author: chris_kohlhoff
Date: 2013-06-23 19:34:42 EDT (Sun, 23 Jun 2013)
New Revision: 84895
URL: http://svn.boost.org/trac/boost/changeset/84895

Log:
Merge from trunk. Fixes #3605.

------------------------------------------------------------------------
r84880 | chris_kohlhoff | 2013-06-22 23:02:21 +1000 (Sat, 22 Jun 2013) | 1 line

Revision history.

------------------------------------------------------------------------
r84879 | chris_kohlhoff | 2013-06-22 22:58:50 +1000 (Sat, 22 Jun 2013) | 1 line

Regenerate documentation.

------------------------------------------------------------------------
r84878 | chris_kohlhoff | 2013-06-22 22:57:51 +1000 (Sat, 22 Jun 2013) | 1 line

Add missing documentation for use_future_t::allocator_type.

------------------------------------------------------------------------
r84877 | chris_kohlhoff | 2013-06-22 22:47:44 +1000 (Sat, 22 Jun 2013) | 1 line

Add mechanism for disabling automatic Winsock initialisation. Refs #3605

------------------------------------------------------------------------
r84876 | chris_kohlhoff | 2013-06-22 22:45:33 +1000 (Sat, 22 Jun 2013) | 1 line

Fix memory leak in ssl::rfc2818_verification class.

------------------------------------------------------------------------
r84875 | chris_kohlhoff | 2013-06-22 22:44:53 +1000 (Sat, 22 Jun 2013) | 1 line

Add support for both boost.coroutine v1 and v2.

Text files modified:
   branches/release/boost/asio/detail/impl/winsock_init.ipp | 13 ++++
   branches/release/boost/asio/detail/winsock_init.hpp | 38 +++++++++++++
   branches/release/boost/asio/impl/spawn.hpp | 20 +++---
   branches/release/boost/asio/spawn.hpp | 40 ++++++++++++-
   branches/release/boost/asio/ssl/impl/rfc2818_verification.ipp | 10 +++
   branches/release/boost/asio/use_future.hpp | 2
   branches/release/libs/asio/doc/history.qbk | 88 ++++++++++++++++++++++++++++++
   branches/release/libs/asio/doc/reference.qbk | 116 ++++++++++++++++++++++++++++++++++++++-
   8 files changed, 308 insertions(+), 19 deletions(-)

Modified: branches/release/boost/asio/detail/impl/winsock_init.ipp
==============================================================================
--- branches/release/boost/asio/detail/impl/winsock_init.ipp Sun Jun 23 17:53:01 2013 (r84894)
+++ branches/release/boost/asio/detail/impl/winsock_init.ipp 2013-06-23 19:34:42 EDT (Sun, 23 Jun 2013) (r84895)
@@ -41,6 +41,14 @@
   }
 }
 
+void winsock_init_base::manual_startup(data& d)
+{
+ if (::InterlockedIncrement(&d.init_count_) == 1)
+ {
+ ::InterlockedExchange(&d.result_, 0);
+ }
+}
+
 void winsock_init_base::cleanup(data& d)
 {
   if (::InterlockedDecrement(&d.init_count_) == 0)
@@ -49,6 +57,11 @@
   }
 }
 
+void winsock_init_base::manual_cleanup(data& d)
+{
+ ::InterlockedDecrement(&d.init_count_);
+}
+
 void winsock_init_base::throw_on_error(data& d)
 {
   long result = ::InterlockedExchangeAdd(&d.result_, 0);

Modified: branches/release/boost/asio/detail/winsock_init.hpp
==============================================================================
--- branches/release/boost/asio/detail/winsock_init.hpp Sun Jun 23 17:53:01 2013 (r84894)
+++ branches/release/boost/asio/detail/winsock_init.hpp 2013-06-23 19:34:42 EDT (Sun, 23 Jun 2013) (r84895)
@@ -39,8 +39,12 @@
   BOOST_ASIO_DECL static void startup(data& d,
       unsigned char major, unsigned char minor);
 
+ BOOST_ASIO_DECL static void manual_startup(data& d);
+
   BOOST_ASIO_DECL static void cleanup(data& d);
 
+ BOOST_ASIO_DECL static void manual_cleanup(data& d);
+
   BOOST_ASIO_DECL static void throw_on_error(data& d);
 };
 
@@ -66,7 +70,41 @@
     cleanup(data_);
   }
 
+ // This class may be used to indicate that user code will manage Winsock
+ // initialisation and cleanup. This may be required in the case of a DLL, for
+ // example, where it is not safe to initialise Winsock from global object
+ // constructors.
+ //
+ // To prevent asio from initialising Winsock, the object must be constructed
+ // before any Asio's own global objects. With MSVC, this may be accomplished
+ // by adding the following code to the DLL:
+ //
+ // #pragma warning(push)
+ // #pragma warning(disable:4073)
+ // #pragma init_seg(lib)
+ // boost::asio::detail::winsock_init<>::manual manual_winsock_init;
+ // #pragma warning(pop)
+ class manual
+ {
+ public:
+ manual()
+ {
+ manual_startup(data_);
+ }
+
+ manual(const manual&)
+ {
+ manual_startup(data_);
+ }
+
+ ~manual()
+ {
+ manual_cleanup(data_);
+ }
+ };
+
 private:
+ friend class manual;
   static data data_;
 };
 

Modified: branches/release/boost/asio/impl/spawn.hpp
==============================================================================
--- branches/release/boost/asio/impl/spawn.hpp Sun Jun 23 17:53:01 2013 (r84894)
+++ branches/release/boost/asio/impl/spawn.hpp 2013-06-23 19:34:42 EDT (Sun, 23 Jun 2013) (r84895)
@@ -58,8 +58,8 @@
     }
 
   //private:
- detail::shared_ptr<boost::coroutines::coroutine<void()> > coro_;
- boost::coroutines::coroutine<void()>::caller_type& ca_;
+ shared_ptr<typename basic_yield_context<Handler>::callee_type> coro_;
+ typename basic_yield_context<Handler>::caller_type& ca_;
     Handler& handler_;
     boost::system::error_code* ec_;
     T* value_;
@@ -90,8 +90,8 @@
     }
 
   //private:
- detail::shared_ptr<boost::coroutines::coroutine<void()> > coro_;
- boost::coroutines::coroutine<void()>::caller_type& ca_;
+ shared_ptr<typename basic_yield_context<Handler>::callee_type> coro_;
+ typename basic_yield_context<Handler>::caller_type& ca_;
     Handler& handler_;
     boost::system::error_code* ec_;
   };
@@ -186,7 +186,7 @@
   }
 
 private:
- boost::coroutines::coroutine<void()>::caller_type& ca_;
+ typename basic_yield_context<Handler>::caller_type& ca_;
   boost::system::error_code* out_ec_;
   boost::system::error_code ec_;
   type value_;
@@ -212,7 +212,7 @@
   }
 
 private:
- boost::coroutines::coroutine<void()>::caller_type& ca_;
+ typename basic_yield_context<Handler>::caller_type& ca_;
   boost::system::error_code* out_ec_;
   boost::system::error_code ec_;
 };
@@ -230,7 +230,7 @@
     {
     }
 
- weak_ptr<boost::coroutines::coroutine<void()> > coro_;
+ weak_ptr<typename basic_yield_context<Handler>::callee_type> coro_;
     Handler handler_;
     bool call_handler_;
     Function function_;
@@ -239,7 +239,7 @@
   template <typename Handler, typename Function>
   struct coro_entry_point
   {
- void operator()(boost::coroutines::coroutine<void()>::caller_type& ca)
+ void operator()(typename basic_yield_context<Handler>::caller_type& ca)
     {
       shared_ptr<spawn_data<Handler, Function> > data(data_);
       ca(); // Yield until coroutine pointer has been initialised.
@@ -258,9 +258,9 @@
   {
     void operator()()
     {
+ typedef typename basic_yield_context<Handler>::callee_type callee_type;
       coro_entry_point<Handler, Function> entry_point = { data_ };
- shared_ptr<boost::coroutines::coroutine<void()> > coro(
- new boost::coroutines::coroutine<void()>(entry_point, attributes_));
+ shared_ptr<callee_type> coro(new callee_type(entry_point, attributes_));
       data_->coro_ = coro;
       (*coro)();
     }

Modified: branches/release/boost/asio/spawn.hpp
==============================================================================
--- branches/release/boost/asio/spawn.hpp Sun Jun 23 17:53:01 2013 (r84894)
+++ branches/release/boost/asio/spawn.hpp 2013-06-23 19:34:42 EDT (Sun, 23 Jun 2013) (r84895)
@@ -49,6 +49,36 @@
 class basic_yield_context
 {
 public:
+ /// The coroutine callee type, used by the implementation.
+ /**
+ * When using Boost.Coroutine v1, this type is:
+ * @code typename coroutine<void()> @endcode
+ * When using Boost.Coroutine v2 (unidirectional coroutines), this type is:
+ * @code push_coroutine<void> @endcode
+ */
+#if defined(GENERATING_DOCUMENTATION)
+ typedef implementation_defined callee_type;
+#elif defined(BOOST_COROUTINES_UNIDRECT) || defined(BOOST_COROUTINES_V2)
+ typedef boost::coroutines::push_coroutine<void> callee_type;
+#else
+ typedef boost::coroutines::coroutine<void()> callee_type;
+#endif
+
+ /// The coroutine caller type, used by the implementation.
+ /**
+ * When using Boost.Coroutine v1, this type is:
+ * @code typename coroutine<void()>::caller_type @endcode
+ * When using Boost.Coroutine v2 (unidirectional coroutines), this type is:
+ * @code pull_coroutine<void> @endcode
+ */
+#if defined(GENERATING_DOCUMENTATION)
+ typedef implementation_defined caller_type;
+#elif defined(BOOST_COROUTINES_UNIDRECT) || defined(BOOST_COROUTINES_V2)
+ typedef boost::coroutines::pull_coroutine<void> caller_type;
+#else
+ typedef boost::coroutines::coroutine<void()>::caller_type caller_type;
+#endif
+
   /// Construct a yield context to represent the specified coroutine.
   /**
    * Most applications do not need to use this constructor. Instead, the
@@ -56,8 +86,8 @@
    * function.
    */
   basic_yield_context(
- const detail::weak_ptr<boost::coroutines::coroutine<void()> >& coro,
- boost::coroutines::coroutine<void()>::caller_type& ca, Handler& handler)
+ const detail::weak_ptr<callee_type>& coro,
+ caller_type& ca, Handler& handler)
     : coro_(coro),
       ca_(ca),
       handler_(handler),
@@ -84,7 +114,7 @@
    * ...
    * } @endcode
    */
- basic_yield_context operator[](boost::system::error_code& ec)
+ basic_yield_context operator[](boost::system::error_code& ec) const
   {
     basic_yield_context tmp(*this);
     tmp.ec_ = &ec;
@@ -94,8 +124,8 @@
 #if defined(GENERATING_DOCUMENTATION)
 private:
 #endif // defined(GENERATING_DOCUMENTATION)
- detail::weak_ptr<boost::coroutines::coroutine<void()> > coro_;
- boost::coroutines::coroutine<void()>::caller_type& ca_;
+ detail::weak_ptr<callee_type> coro_;
+ caller_type& ca_;
   Handler& handler_;
   boost::system::error_code* ec_;
 };

Modified: branches/release/boost/asio/ssl/impl/rfc2818_verification.ipp
==============================================================================
--- branches/release/boost/asio/ssl/impl/rfc2818_verification.ipp Sun Jun 23 17:53:01 2013 (r84894)
+++ branches/release/boost/asio/ssl/impl/rfc2818_verification.ipp 2013-06-23 19:34:42 EDT (Sun, 23 Jun 2013) (r84895)
@@ -70,7 +70,10 @@
         const char* pattern = reinterpret_cast<const char*>(domain->data);
         std::size_t pattern_length = domain->length;
         if (match_pattern(pattern, pattern_length, host_.c_str()))
+ {
+ GENERAL_NAMES_free(gens);
           return true;
+ }
       }
     }
     else if (gen->type == GEN_IPADD && is_address)
@@ -82,17 +85,24 @@
         {
           ip::address_v4::bytes_type bytes = address.to_v4().to_bytes();
           if (memcmp(bytes.data(), ip_address->data, 4) == 0)
+ {
+ GENERAL_NAMES_free(gens);
             return true;
+ }
         }
         else if (address.is_v6() && ip_address->length == 16)
         {
           ip::address_v6::bytes_type bytes = address.to_v6().to_bytes();
           if (memcmp(bytes.data(), ip_address->data, 16) == 0)
+ {
+ GENERAL_NAMES_free(gens);
             return true;
+ }
         }
       }
     }
   }
+ GENERAL_NAMES_free(gens);
 
   // No match in the alternate names, so try the common names. We should only
   // use the "most specific" common name, which is the last one in the list.

Modified: branches/release/boost/asio/use_future.hpp
==============================================================================
--- branches/release/boost/asio/use_future.hpp Sun Jun 23 17:53:01 2013 (r84894)
+++ branches/release/boost/asio/use_future.hpp 2013-06-23 19:34:42 EDT (Sun, 23 Jun 2013) (r84895)
@@ -42,6 +42,8 @@
 class use_future_t
 {
 public:
+ /// The allocator type. The allocator is used when constructing the
+ /// @c std::promise object for a given asynchronous operation.
   typedef Allocator allocator_type;
 
   /// Construct using default-constructed allocator.

Modified: branches/release/libs/asio/doc/history.qbk
==============================================================================
--- branches/release/libs/asio/doc/history.qbk Sun Jun 23 17:53:01 2013 (r84894)
+++ branches/release/libs/asio/doc/history.qbk 2013-06-23 19:34:42 EDT (Sun, 23 Jun 2013) (r84895)
@@ -7,6 +7,94 @@
 
 [section:history Revision History]
 
+[heading Asio 1.10.0 / Boost 1.54]
+
+* Added new traits classes, `handler_type` and `async_result`, that allow the
+ customisation of the return type of an initiating function.
+* Added the `asio::spawn()` function, a high-level wrapper for running
+ stackful coroutines, based on the Boost.Coroutine library. The `spawn()`
+ function enables programs to implement asynchronous logic in a synchronous
+ manner. For example: `size_t n = my_socket.async_read_some(my_buffer, yield);`.
+ For further information, see [link boost_asio.overview.core.spawn Stackful
+ Coroutines].
+* Added the `asio::use_future` special value, which provides first-class
+ support for returning a C++11 `std::future` from an asynchronous
+ operation's initiating function. For example:
+ `future<size_t> = my_socket.async_read_some(my_buffer, asio::use_future);`.
+ For further information, see [link boost_asio.overview.cpp2011.futures C++
+ 2011 Support - Futures].
+* Promoted the stackless coroutine class and macros to be part of Asio's
+ documented interface, rather than part of the HTTP server 4 example.
+ For further information, see [link boost_asio.overview.core.coroutine
+ Stackless Coroutines].
+* Added a new handler hook called `asio_handler_is_continuation`.
+ Asynchronous operations may represent a continuation of the asynchronous
+ control flow associated with the current executing handler. The
+ `asio_handler_is_continuation` hook can be customised to return `true` if
+ this is the case, and Asio's implementation can use this knowledge to
+ optimise scheduling of the new handler. To cover common cases, Asio
+ customises the hook for strands, `spawn()` and composed asynchronous
+ operations.
+* Added four new generic protocol classes, `generic::datagram_protocol`,
+ `generic::raw_protocol`, `generic::seq_packet_protocol` and
+ `generic::stream_protocol`, which implement the `Protocol` type
+ requirements, but allow the user to specify the address family (e.g.
+ `AF_INET`) and protocol type (e.g. `IPPROTO_TCP`) at runtime.
+ For further information, see [link
+ boost_asio.overview.networking.other_protocols Support for Other Protocols].
+* Added C++11 move constructors that allow the conversion of a socket (or
+ acceptor) into a more generic type. For example, an `ip::tcp::socket` can
+ be converted into a `generic::stream_protocol::socket` via move
+ construction.
+ For further information, see [link
+ boost_asio.overview.networking.other_protocols Support for Other Protocols].
+* Extended the `basic_socket_acceptor<>`'s `accept()` and `async_accept()`
+ functions to allow a new connection to be accepted directly into a socket
+ of a more generic type. For example, an `ip::tcp::acceptor` can be used to
+ accept into a `generic::stream_protocol::socket` object.
+ For further information, see [link
+ boost_asio.overview.networking.other_protocols Support for Other Protocols].
+* Moved existing examples into a C++03-specific directory, and added a new
+ directory for C++11-specific examples. A limited subset of the C++03
+ examples have been converted to their C++11 equivalents.
+* Various SSL enhancements. Thanks go to Nick Jones, on whose work these changes
+ are based.
+ * Added support for SSL handshakes with re-use of data already read from
+ the wire. New overloads of the `ssl::stream<>` class's `handshake()` and
+ `async_handshake()` functions have been added. These accept a
+ `ConstBufferSequence` to be used as initial input to the ssl engine for
+ the handshake procedure.
+ * Added support for creation of TLSv1.1 and TLSv1.2 `ssl::context` objects.
+ * Added a `set_verify_depth()` function to the `ssl::context` and
+ `ssl::stream<>` classes.
+ * Added the ability to load SSL certificate and key data from memory
+ buffers. New functions, `add_certificate_authority()`,
+ `use_certificate()`, `use_certificate_chain()`, `use_private_key()`,
+ `use_rsa_private_key()` and `use_tmp_dh()`, have been added to the
+ `ssl::context` class.
+ * Changed `ssl::context` to automatically disable SSL compression by
+ default. To enable, use the new `ssl::context::clear_options()` function,
+ as in `my_context.clear_options(ssl::context::no_compression)`.
+* Fixed a potential deadlock in `signal_set` implementation.
+* Fixed an error in acceptor example in documentation [ticket 8421].
+* Fixed copy-paste errors in waitable timer documentation [ticket 8602].
+* Added assertions to satisfy some code analysis tools [ticket 7739].
+* Fixed a malformed `#warning` directive [ticket 7939].
+* Fixed a potential data race in the Linux `epoll` implementation.
+* Fixed a Windows-specific bug, where certain operations might generate an
+ `error_code` with an invalid (i.e. `NULL`) `error_category` [ticket 8613].
+* Fixed `basic_waitable_timer`'s underlying implementation so that it can
+ handle any `time_point` value without overflowing the intermediate duration
+ objects.
+* Fixed a problem with lost thread wakeups that can occur when making
+ concurrent calls to `run()` and `poll()` on the same `io_service` object
+ [ticket 8354].
+* Fixed implementation of asynchronous connect operation so that it can cope
+ with spurious readiness notifications from the reactor [ticket 7961].
+* Fixed a memory leak in the `ssl::rfc2818_verification` class.
+* Added a mechanism for disabling automatic Winsock initialisation [ticket
+ 3605]. See the header file [^boost/asio/detail/winsock_init.hpp] for details.
+
 [heading Asio 1.8.3 / Boost 1.53]
 
 * Fixed some 64-to-32-bit conversion warnings ([ticket 7459]).

Modified: branches/release/libs/asio/doc/reference.qbk
==============================================================================
--- branches/release/libs/asio/doc/reference.qbk Sun Jun 23 17:53:01 2013 (r84894)
+++ branches/release/libs/asio/doc/reference.qbk 2013-06-23 19:34:42 EDT (Sun, 23 Jun 2013) (r84895)
@@ -45112,6 +45112,26 @@
   class basic_yield_context
 
 
+[heading Types]
+[table
+ [[Name][Description]]
+
+ [
+
+ [[link boost_asio.reference.basic_yield_context.callee_type [*callee_type]]]
+ [The coroutine callee type, used by the implementation. ]
+
+ ]
+
+ [
+
+ [[link boost_asio.reference.basic_yield_context.caller_type [*caller_type]]]
+ [The coroutine caller type, used by the implementation. ]
+
+ ]
+
+]
+
 [heading Member Functions]
 [table
   [[Name][Description]]
@@ -45159,8 +45179,8 @@
 
 
   basic_yield_context(
- const detail::weak_ptr< boost::coroutines::coroutine< void()> > & coro,
- boost::coroutines::coroutine< void()>::caller_type & ca,
+ const detail::weak_ptr< callee_type > & coro,
+ caller_type & ca,
       Handler & handler);
 
 
@@ -45171,6 +45191,72 @@
 
 
 
+[section:callee_type basic_yield_context::callee_type]
+
+[indexterm2 callee_type..basic_yield_context]
+The coroutine callee type, used by the implementation.
+
+
+ typedef implementation_defined callee_type;
+
+
+
+When using Boost.Coroutine v1, this type is:
+
+ typename coroutine<void()>
+
+
+When using Boost.Coroutine v2 (unidirectional coroutines), this type is:
+
+ push_coroutine<void>
+
+
+
+
+[heading Requirements]
+
+['Header: ][^boost/asio/spawn.hpp]
+
+['Convenience header: ][^boost/asio.hpp]
+
+
+[endsect]
+
+
+
+[section:caller_type basic_yield_context::caller_type]
+
+[indexterm2 caller_type..basic_yield_context]
+The coroutine caller type, used by the implementation.
+
+
+ typedef implementation_defined caller_type;
+
+
+
+When using Boost.Coroutine v1, this type is:
+
+ typename coroutine<void()>::caller_type
+
+
+When using Boost.Coroutine v2 (unidirectional coroutines), this type is:
+
+ pull_coroutine<void>
+
+
+
+
+[heading Requirements]
+
+['Header: ][^boost/asio/spawn.hpp]
+
+['Convenience header: ][^boost/asio.hpp]
+
+
+[endsect]
+
+
+
 [section:operator_lb__rb_ basic_yield_context::operator\[\]]
 
 [indexterm2 operator\[\]..basic_yield_context]
@@ -45178,7 +45264,7 @@
 
 
   basic_yield_context operator[](
- boost::system::error_code & ec);
+ boost::system::error_code & ec) const;
 
 
 By default, when a yield context is used with an asynchronous operation, a non-success error\_code is converted to system\_error and thrown. This operator may be used to specify an error\_code object that should instead be set with the asynchronous operation's result. For example:
@@ -95580,7 +95666,7 @@
   [
 
     [[link boost_asio.reference.use_future_t.allocator_type [*allocator_type]]]
- []
+ [The allocator type. The allocator is used when constructing the std::promise object for a given asynchronous operation. ]
   
   ]
 
@@ -95631,6 +95717,8 @@
 [section:allocator_type use_future_t::allocator_type]
 
 [indexterm2 allocator_type..use_future_t]
+The allocator type. The allocator is used when constructing the `std::promise` object for a given asynchronous operation.
+
 
   typedef Allocator allocator_type;
 
@@ -105140,6 +105228,26 @@
   typedef basic_yield_context< unspecified > yield_context;
 
 
+[heading Types]
+[table
+ [[Name][Description]]
+
+ [
+
+ [[link boost_asio.reference.basic_yield_context.callee_type [*callee_type]]]
+ [The coroutine callee type, used by the implementation. ]
+
+ ]
+
+ [
+
+ [[link boost_asio.reference.basic_yield_context.caller_type [*caller_type]]]
+ [The coroutine caller type, used by the implementation. ]
+
+ ]
+
+]
+
 [heading Member Functions]
 [table
   [[Name][Description]]


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