Commit Graph

1359 Commits

Author SHA1 Message Date
Christopher Kohlhoff
9e2fc1f61e Some async operations that missed getting the async_result treatment.
[SVN r85762]
2013-09-17 22:12:07 +00:00
Christopher Kohlhoff
06e5aeedca Visual C++ language extensions use generic as a keyword. Add a
workaround that renames the namespace to cpp_generic when those
language extensions are in effect.


[SVN r85761]
2013-09-17 22:08:43 +00:00
Christopher Kohlhoff
12f4e8280b Enable certain C++11 standard library facilities for recent versions of Microsoft Visual Studio.
[SVN r85760]
2013-09-17 22:08:07 +00:00
Christopher Kohlhoff
4752c98d59 Inore ERROR_MORE_DATA as a non-fatal error when returned by
GetOverlappedResult for a synchronous read.


[SVN r85759]
2013-09-17 22:06:25 +00:00
Christopher Kohlhoff
07f0ea9996 Remove use of std::min.
[SVN r85758]
2013-09-17 22:05:38 +00:00
Christopher Kohlhoff
10dd1488c7 Add missing forward declarations needed for Windows.
[SVN r85757]
2013-09-17 22:04:55 +00:00
Christopher Kohlhoff
558a771072 Fix documentation error where an asynchronous function was described as
having synchronous behaviour.


[SVN r85756]
2013-09-17 22:04:10 +00:00
Christopher Kohlhoff
799f24ddf8 Fix another socket descriptor comparison that doesn't work correctly if
the descriptor type is unsigned.


[SVN r85755]
2013-09-17 22:03:29 +00:00
Christopher Kohlhoff
5cd67a72cc Add missing move cast.
[SVN r85754]
2013-09-17 22:01:26 +00:00
Christopher Kohlhoff
dcc918d0a9 Clean up some internal forward declarations.
[SVN r85753]
2013-09-17 22:00:53 +00:00
Christopher Kohlhoff
8fafa6f60a Remove spurious whitespace.
[SVN r85752]
2013-09-17 21:53:45 +00:00
Christopher Kohlhoff
c230dd2ed0 Fix error in comment.
[SVN r85751]
2013-09-17 21:53:03 +00:00
Christopher Kohlhoff
131b7a25ab Clarify that programs must not issue overlapping async_write_at operations.
[SVN r85750]
2013-09-17 21:52:27 +00:00
Christopher Kohlhoff
32a41f7871 Enable the move optimisation (and otherwise eliminate a copy) for handlers
using the default invocation hook.


[SVN r85749]
2013-09-17 21:51:28 +00:00
Christopher Kohlhoff
0bc20e40dd Fix link to refer to native_handle() rather than the deprecated native() function.
[SVN r85748]
2013-09-17 21:48:54 +00:00
Christopher Kohlhoff
aba096cc75 Suppress g++ 4.8+ warning about unused typedefs.
[SVN r85747]
2013-09-17 21:45:43 +00:00
Christopher Kohlhoff
749e9d2219 Ensure signal number is correctly passed to the completion handler when
starting an async_wait on a signal that is already raised.


[SVN r85746]
2013-09-17 21:43:29 +00:00
Christopher Kohlhoff
d203da445e Fix comparison used to test for a successful synchronous accept.
[SVN r85745]
2013-09-17 21:42:48 +00:00
Christopher Kohlhoff
475e3239e5 Fix a bug in handler tracking, where it was not correctly printing out some handler IDs.
[SVN r85744]
2013-09-17 21:42:08 +00:00
Christopher Kohlhoff
d747598321 Ensure ssl::io_op::want_ member is initialised.
[SVN r85743]
2013-09-17 21:41:04 +00:00
Christopher Kohlhoff
8bc2679db6 Fix typo in serial ports overview.
[SVN r85742]
2013-09-17 21:40:19 +00:00
Christopher Kohlhoff
c57920f5df Fix a regression on Windows where multiple threads are running an io_service.
[SVN r85741]
2013-09-17 21:39:38 +00:00
Christopher Kohlhoff
f6359cbf6e Fix nfds argument to select.
[SVN r85740]
2013-09-17 21:38:41 +00:00
Christopher Kohlhoff
5554bf5a6c Remove unused parameters and member variables.
[SVN r85739]
2013-09-17 21:36:54 +00:00
Christopher Kohlhoff
0199ad5d3b Fix a regression where, on some platforms, errors from async_connect are not
correctly propagated through to the completion handler.


[SVN r85738]
2013-09-17 21:35:43 +00:00
Christopher Kohlhoff
aea3d133c4 Remove unused variable assignment.
[SVN r85737]
2013-09-17 21:33:39 +00:00
Christopher Kohlhoff
e4b1e832d2 Fix error in async_receive_from example.
[SVN r85736]
2013-09-17 21:32:48 +00:00
Christopher Kohlhoff
977543973d Remove dependency on Boost.Preprocessor library.
[SVN r85735]
2013-09-17 21:31:55 +00:00
Christopher Kohlhoff
623a696a78 Sync version number with release branch.
[SVN r85716]
2013-09-16 22:38:05 +00:00
Christopher Kohlhoff
5a6dbafee2 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.


[SVN r84895]
2013-06-23 23:34:42 +00:00
Christopher Kohlhoff
0923bc6904 Revision history.
[SVN r84880]
2013-06-22 13:02:21 +00:00
Christopher Kohlhoff
617ecf2598 Regenerate documentation.
[SVN r84879]
2013-06-22 12:58:50 +00:00
Christopher Kohlhoff
bf00b5d6d7 Add missing documentation for use_future_t::allocator_type.
[SVN r84878]
2013-06-22 12:57:51 +00:00
Christopher Kohlhoff
a897f60e3d Add mechanism for disabling automatic Winsock initialisation. Refs #3605
[SVN r84877]
2013-06-22 12:47:44 +00:00
Christopher Kohlhoff
74907c9aa2 Fix memory leak in ssl::rfc2818_verification class.
[SVN r84876]
2013-06-22 12:45:33 +00:00
Christopher Kohlhoff
5120123082 Add support for both boost.coroutine v1 and v2.
[SVN r84875]
2013-06-22 12:44:53 +00:00
Christopher Kohlhoff
81a79b69a7 Version bump.
[SVN r84531]
2013-05-27 12:38:17 +00:00
Christopher Kohlhoff
40361023c5 Merge from trunk. Fixes #8421, #8602, #7739, #8613, #7939.
------------------------------------------------------------------------
r84482 | chris_kohlhoff | 2013-05-25 21:35:10 +1000 (Sat, 25 May 2013) | 1 line

Fix potential deadlock in signal_set implementation.
------------------------------------------------------------------------
r84483 | chris_kohlhoff | 2013-05-25 21:38:01 +1000 (Sat, 25 May 2013) | 1 line

Fix error in acceptor example. Refs #8421
------------------------------------------------------------------------
r84484 | chris_kohlhoff | 2013-05-25 21:41:19 +1000 (Sat, 25 May 2013) | 1 line

Fix waitable timer documentation. Refs #8602
------------------------------------------------------------------------
r84485 | chris_kohlhoff | 2013-05-25 21:46:20 +1000 (Sat, 25 May 2013) | 1 line

Add assertions that num_buckets_ is non-zero. Refs #7739
------------------------------------------------------------------------
r84486 | chris_kohlhoff | 2013-05-25 21:50:52 +1000 (Sat, 25 May 2013) | 8 lines

Automatically disable SSL compression.

To mitigate the risk of certain attacks, SSL compression is now disabled
by default. To enable, you can use the new ssl::context::clear_options()
function like so:

  my_context.clear_options(asio::ssl::context::no_compression);

------------------------------------------------------------------------
r84487 | chris_kohlhoff | 2013-05-25 21:52:54 +1000 (Sat, 25 May 2013) | 3 lines

Fix bug on Windows where certain operations might generate an error_code with
an invalid (i.e. NULL) error_category. Refs #8613

------------------------------------------------------------------------
r84488 | chris_kohlhoff | 2013-05-25 21:57:36 +1000 (Sat, 25 May 2013) | 1 line

Fix problem in #warning directive. Refs #7939
------------------------------------------------------------------------
r84492 | chris_kohlhoff | 2013-05-25 22:35:43 +1000 (Sat, 25 May 2013) | 2 lines

Fix potential data race due to reading the reactor pointer outside the lock.

------------------------------------------------------------------------
r84494 | chris_kohlhoff | 2013-05-25 23:03:48 +1000 (Sat, 25 May 2013) | 1 line

Regenerate documentation.
------------------------------------------------------------------------
r84529 | chris_kohlhoff | 2013-05-27 22:17:19 +1000 (Mon, 27 May 2013) | 1 line

Add documentation for new features.
------------------------------------------------------------------------


[SVN r84530]
2013-05-27 12:36:39 +00:00
Christopher Kohlhoff
f97171acc9 Add documentation for new features.
[SVN r84529]
2013-05-27 12:17:19 +00:00
Christopher Kohlhoff
a05bbf3a53 Regenerate documentation.
[SVN r84494]
2013-05-25 13:03:48 +00:00
Christopher Kohlhoff
661fb4bac6 Fix potential data race due to reading the reactor pointer outside the lock.
[SVN r84492]
2013-05-25 12:35:43 +00:00
Christopher Kohlhoff
642a1cf824 Fix problem in #warning directive. Refs #7939
[SVN r84488]
2013-05-25 11:57:36 +00:00
Christopher Kohlhoff
e9d0dda331 Fix bug on Windows where certain operations might generate an error_code with
an invalid (i.e. NULL) error_category. Refs #8613


[SVN r84487]
2013-05-25 11:52:54 +00:00
Christopher Kohlhoff
bbf94e800e Automatically disable SSL compression.
To mitigate the risk of certain attacks, SSL compression is now disabled
by default. To enable, you can use the new ssl::context::clear_options()
function like so:

  my_context.clear_options(asio::ssl::context::no_compression);


[SVN r84486]
2013-05-25 11:50:52 +00:00
Christopher Kohlhoff
2b7646ae8d Add assertions that num_buckets_ is non-zero. Refs #7739
[SVN r84485]
2013-05-25 11:46:20 +00:00
Christopher Kohlhoff
b9ae1e866c Fix waitable timer documentation. Refs #8602
[SVN r84484]
2013-05-25 11:41:19 +00:00
Christopher Kohlhoff
2d307d2dcd Fix error in acceptor example. Refs #8421
[SVN r84483]
2013-05-25 11:38:01 +00:00
Christopher Kohlhoff
22d8e5e5f8 Fix potential deadlock in signal_set implementation.
[SVN r84482]
2013-05-25 11:35:10 +00:00
Christopher Kohlhoff
d499517905 Remove files left behind after merge.
[SVN r84397]
2013-05-21 00:20:50 +00:00
Christopher Kohlhoff
603397befb Merge from trunk.
------------------------------------------------------------------------
r84301 | chris_kohlhoff | 2013-05-17 07:34:54 +1000 (Fri, 17 May 2013) | 2 lines

Enable handler type requirements static_assert on clang.

------------------------------------------------------------------------
r84308 | chris_kohlhoff | 2013-05-17 09:26:04 +1000 (Fri, 17 May 2013) | 3 lines

Add new traits classes, handler_type and async_result, that allow
the customisation of the return type of an initiating function.

------------------------------------------------------------------------
r84311 | chris_kohlhoff | 2013-05-17 11:38:47 +1000 (Fri, 17 May 2013) | 81 lines

Add the asio::spawn() function, a high-level wrapper for running
stackful coroutines. It is based on the Boost.Coroutine library.

Here is an example of its use:

  asio::spawn(my_strand, do_echo);

  // ...

  void do_echo(asio::yield_context yield)
  {
    try
    {
      char data[128];
      for (;;)
      {
        std::size_t length =
          my_socket.async_read_some(
            asio::buffer(data), yield);

        asio::async_write(my_socket,
            asio::buffer(data, length), yield);
      }
    }
    catch (std::exception& e)
    {
      // ...
    }
  }

The first argument to asio::spawn() may be a strand, io_service or
completion handler. This argument determines the context in which the
coroutine is permitted to execute. For example, a server's per-client
object may consist of multiple coroutines; they should all run on the
same strand so that no explicit synchronisation is required.

The second argument is a function object with signature (**):

  void coroutine(asio::yield_context yield);

that specifies the code to be run as part of the coroutine. The
parameter yield may be passed to an asynchronous operation in place of
the completion handler, as in:

  std::size_t length =
    my_socket.async_read_some(
      asio::buffer(data), yield);

This starts the asynchronous operation and suspends the coroutine. The
coroutine will be resumed automatically when the asynchronous operation
completes.

Where a completion handler signature has the form:

  void handler(error_code ec, result_type result);

the initiating function returns the result_type. In the async_read_some
example above, this is std::size_t. If the asynchronous operation fails,
the error_code is converted into a system_error exception and thrown.

Where a completion handler signature has the form:

  void handler(error_code ec);

the initiating function returns void. As above, an error is passed back
to the coroutine as a system_error exception.

To collect the error_code from an operation, rather than have it throw
an exception, associate the output variable with the yield_context as
follows:

  error_code ec;
  std::size_t length =
    my_socket.async_read_some(
      asio::buffer(data), yield[ec]);

**Note: if asio::spawn() is used with a custom completion handler of
type Handler, the function object signature is actually:
  
  void coroutine(asio::basic_yield_context<Handler> yield);

------------------------------------------------------------------------
r84312 | chris_kohlhoff | 2013-05-17 12:25:10 +1000 (Fri, 17 May 2013) | 4 lines

Move existing examples into a C++03-specific directory, and add a new
directory for C++11-specific examples. A limited subset of the C++03
examples have been converted to their C++11 equivalents.

------------------------------------------------------------------------
r84313 | chris_kohlhoff | 2013-05-17 12:35:08 +1000 (Fri, 17 May 2013) | 26 lines

Add the asio::use_future special value, which adds first-class support
for returning a C++11 std::future from an asynchronous operation's
initiating function.

To use asio::use_future, pass it to an asynchronous operation instead of
a normal completion handler. For example:

  std::future<std::size_t> length =
    my_socket.async_read_some(my_buffer, asio::use_future);

Where a completion handler signature has the form:

  void handler(error_code ec, result_type result);

the initiating function returns a std::future templated on result_type.
In the above example, this is std::size_t. If the asynchronous operation
fails, the error_code is converted into a system_error exception and
passed back to the caller through the future.

Where a completion handler signature has the form:

  void handler(error_code ec);

the initiating function returns std::future<void>. As above, an error
is passed back in the future as a system_error exception.

------------------------------------------------------------------------
r84314 | chris_kohlhoff | 2013-05-17 13:07:51 +1000 (Fri, 17 May 2013) | 27 lines

Add a new handler hook called asio_handler_is_continuation.

Asynchronous operations may represent a continuation of the asynchronous
control flow associated with the current handler. Asio's implementation
can use this knowledge to optimise scheduling of the handler.

The asio_handler_is_continuation hook returns true to indicate whether a
completion handler represents a continuation of the current call
context. The default implementation of the hook returns false, and
applications may customise the hook when necessary. The hook has already
been customised within Asio to return true for the following cases:

- Handlers returned by strand.wrap(), when the corresponding
  asynchronous operation is being initiated from within the strand.

- The internal handlers used to implement the asio::spawn() function's
  stackful coroutines.

- When an intermediate handler of a composed operation (e.g.
  asio::async_read(), asio::async_write(), asio::async_connect(),
  ssl::stream<>, etc.) starts a new asynchronous operation due to the
  composed operation not being complete.

To support this optimisation, a new running_in_this_thread() member
function has been added to the io_service::strand class. This function
returns true when called from within a strand.

------------------------------------------------------------------------
r84315 | chris_kohlhoff | 2013-05-17 20:06:50 +1000 (Fri, 17 May 2013) | 3 lines

Partially decouple Asio from other boost components via an extra level
of indirection.

------------------------------------------------------------------------
r84316 | chris_kohlhoff | 2013-05-17 20:15:21 +1000 (Fri, 17 May 2013) | 2 lines

Minor cleanup.

------------------------------------------------------------------------
r84319 | chris_kohlhoff | 2013-05-17 20:52:08 +1000 (Fri, 17 May 2013) | 9 lines

Support handshake with re-use of data already read from the wire.

Add new overloads of the SSL stream's handshake() and async_handshake()
functions, that accepts a ConstBufferSequence to be used as initial
input to the ssl engine for the handshake procedure.

Thanks go to Nick Jones <nick dot fa dot jones at gmail dot com>, on
whose work this commit is partially based.

------------------------------------------------------------------------
r84320 | chris_kohlhoff | 2013-05-17 20:57:02 +1000 (Fri, 17 May 2013) | 6 lines

Support for creation of TLSv1.1 and TLSv1.2 contexts.

Thanks go to Alvin Cheung <alvin dot cheung at alumni dot ust dot hk>
and Nick Jones <nick dot fa dot jones at gmail dot com>, on whose work
this is based.

------------------------------------------------------------------------
r84322 | chris_kohlhoff | 2013-05-17 21:00:49 +1000 (Fri, 17 May 2013) | 5 lines

Add set_verify_depth function to SSL context and stream.

Thanks go to Nick Jones <nick dot fa dot jones at gmail dot com>, on
whose work this commit is based.

------------------------------------------------------------------------
r84325 | chris_kohlhoff | 2013-05-17 21:04:11 +1000 (Fri, 17 May 2013) | 9 lines

Allow loading of SSL certificate and key data from memory buffers.

Added new buffer-based interfaces:
add_certificate_authority, use_certificate, use_certificate_chain,
use_private_key, use_rsa_private_key, use_tmp_dh.

Thanks go to Nick Jones <nick dot fa dot jones at gmail dot com>, on
whose work this commit is based.

------------------------------------------------------------------------
r84345 | chris_kohlhoff | 2013-05-18 21:24:59 +1000 (Sat, 18 May 2013) | 2 lines

Update copyright notices.

------------------------------------------------------------------------
r84346 | chris_kohlhoff | 2013-05-18 21:54:59 +1000 (Sat, 18 May 2013) | 3 lines

Remove the stackless coroutine class and macros from the HTTP server 4
example, and instead make them a part of Asio's documented interface.

------------------------------------------------------------------------
r84347 | chris_kohlhoff | 2013-05-18 22:01:59 +1000 (Sat, 18 May 2013) | 4 lines

Fix basic_waitable_timer's underlying implementation so that it can
handle any time_point value without overflowing the intermediate
duration objects.

------------------------------------------------------------------------
r84348 | chris_kohlhoff | 2013-05-18 22:07:00 +1000 (Sat, 18 May 2013) | 3 lines

Fix a problem with lost thread wakeups that can occur when making
concurrent calls to run() and poll() on the same io_service object.

------------------------------------------------------------------------
r84349 | chris_kohlhoff | 2013-05-18 22:13:17 +1000 (Sat, 18 May 2013) | 3 lines

Fix implementation of asynchronous connect operation so that it can cope
with spurious readiness notifications from the reactor.

------------------------------------------------------------------------
r84361 | chris_kohlhoff | 2013-05-19 07:56:31 +1000 (Sun, 19 May 2013) | 1 line

Remove some trailing spaces and fix another copyright notice.

------------------------------------------------------------------------
r84363 | chris_kohlhoff | 2013-05-19 14:55:11 +1000 (Sun, 19 May 2013) | 53 lines

Add generic socket protocols and converting move constructors.

Four new protocol classes have been added:

- asio::generic::datagram_protocol
- asio::generic::raw_protocol
- asio::generic::seq_packet_protocol
- asio::generic::stream_protocol

These classes 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.

A new endpoint class template, asio::generic::basic_endpoint, has been
added to support these new protocol classes. This endpoint can hold any
other endpoint type, provided its native representation fits into a
sockaddr_storage object.

When using C++11, it is now possible to perform move construction from a
socket (or acceptor) object to convert to the more generic protocol's
socket (or acceptor) type. If the protocol conversion is valid:

  Protocol1 p1 = ...;
  Protocol2 p2(p1);

then the corresponding socket conversion is allowed:

  Protocol1::socket socket1(io_service);
  ...
  Protocol2::socket socket2(std::move(socket1));

For example, one possible conversion is from a TCP socket to a generic
stream-oriented socket:

  asio::ip::tcp::socket socket1(io_service);
  ...
  asio::generic::stream_protocol::socket socket2(std::move(socket1));

The conversion is also available for move-assignment. Note that these
conversions are not limited to the newly added generic protocol classes.
User-defined protocols may take advantage of this feature by similarly
ensuring the conversion from Protocol1 to Protocol2 is valid, as above.

As a convenience, the socket acceptor's accept() and async_accept()
functions have been changed so that they can directly accept into a
different protocol's socket type, provided the protocol conversion is
valid. For example, the following is now possible:

  asio::ip::tcp::acceptor acceptor(io_service);
  ...
  asio::generic::stream_protocol::socket socket1(io_service);
  acceptor.accept(socket1);


[SVN r84388]
2013-05-20 12:32:20 +00:00