2
0
mirror of https://github.com/boostorg/asio.git synced 2026-02-22 01:32:08 +00:00
Commit Graph

1995 Commits

Author SHA1 Message Date
Christopher Kohlhoff
03f3fa07f1 Fix use of nullptr. 2023-03-06 23:37:18 +11:00
Christopher Kohlhoff
d40e6257bb Explicitly shutdown in io_context and thread_pool destructor.
Fixes a use-after destroy when shutdown() is called from the base class
execution_context destructor, and this in turns triggers the destruction
of outstanding work objects.
2023-03-01 23:10:27 +11:00
Christopher Kohlhoff
85ee73854d Fix execution context overload of get_associated_executor. 2023-03-01 23:10:14 +11:00
Christopher Kohlhoff
d7525504d0 Fix initialization of sqe->user_data for reuse by io_uring_service.
The value of user_data in a submission queue entry is only initialized
with with the ring itself, remaining unchanged after use and even
through calls to io_uring_get_sqe(3). Many submission paths apply
io_uring_sqe_set_data(3) but the remainder are submitted with stale
values that can apply completion operations on the wrong queues with the
wrong results, causing obscure bugs.
2023-03-01 23:10:02 +11:00
Christopher Kohlhoff
7182202ae3 Fix pipe release() when using io_uring. 2023-03-01 23:09:50 +11:00
Christopher Kohlhoff
ae19c7b9a0 Fix thread_pool::join() deadlock when pool has no internal threads. 2023-03-01 23:09:16 +11:00
Christopher Kohlhoff
3c6101b636 Fix experimental::channel try_send failure after cancel. 2023-03-01 23:09:05 +11:00
Christopher Kohlhoff
87c178c9ea Fix awaitable exception pointer check typos. 2023-03-01 23:08:55 +11:00
Christopher Kohlhoff
d341036043 Add protocol for AF_UNIX+SOCK_SEQPACKET. 2023-03-01 23:08:42 +11:00
Christopher Kohlhoff
387f74f575 Add user-defined literals for asio buffer types.
The _buf literal suffix, defined in namespace asio::buffer_literals, may
be used to create const_buffer objects from string, binary integer, and
hexadecimal integer literals. These buffer literals may be arbitrarily
long. For example:

  using namespace asio::buffer_literals;

  asio::const_buffer b1 = "hello"_buf;
  asio::const_buffer b2 = 0xdeadbeef_buf;
  asio::const_buffer b3 = 0x01234567'89abcdef'01234567'89abcdef_buf;
  asio::const_buffer b4 = 0b1010101011001100_buf;

The memory associated with a buffer literal is valid for the lifetime of
the program. This means that the buffer can be safely used with
asynchronous operations:

  async_write(my_socket, "hello"_buf, my_handler);
2023-03-01 23:07:32 +11:00
Christopher Kohlhoff
50600cdb8f Fix ambiguity of associated_cancellation_slot<reference_wrapper>::get(). 2023-03-01 23:07:16 +11:00
Christopher Kohlhoff
6550b831d3 Support immediate completion with reactor-based sockets and descriptors. 2023-03-01 23:07:02 +11:00
Christopher Kohlhoff
1f2f4bc862 Change cancellation_slot_binder to support detection of unspecialised associators. 2023-03-01 23:06:32 +11:00
Christopher Kohlhoff
c35218f219 Change executor_binder to support detection of unspecialised associators. 2023-03-01 23:06:21 +11:00
Christopher Kohlhoff
55759280c2 Change allocator_binder to support detection of unspecialised associators. 2023-03-01 23:06:08 +11:00
Christopher Kohlhoff
0f5ed97183 Add bind_immediate_executor function and immediate_executor_binder adapter. 2023-03-01 23:05:44 +11:00
Christopher Kohlhoff
e199980569 Add associated_immediate_executor associator. 2023-03-01 23:04:58 +11:00
Christopher Kohlhoff
8fb8b1f6bb Move dispatch, post and defer initiation objects to detail headers. 2023-03-01 23:03:43 +11:00
Christopher Kohlhoff
35e93e4e90 Update copyright notices. 2023-03-01 23:03:03 +11:00
Christopher Kohlhoff
a1b17d8cac Version bump. 2022-12-07 22:17:23 +11:00
Christopher Kohlhoff
47cf334752 Revision history. 2022-12-07 22:17:23 +11:00
Christopher Kohlhoff
926058f20f Fix coroutine detection with recent Xcode. 2022-12-07 22:11:30 +11:00
Christopher Kohlhoff
3668ffb3c4 Add io_uring, updated Windows versions to implementation notes. 2022-12-07 20:37:59 +11:00
Christopher Kohlhoff
2e30d9e1be Update async operation requirements to relax the requirements on the associated executor. 2022-12-07 20:37:44 +11:00
Christopher Kohlhoff
f7ff39e66e Add missing include. 2022-12-07 07:36:02 +11:00
Christopher Kohlhoff
32b9ff6204 Fix detection of return type deduction with MSVC. 2022-12-07 07:35:50 +11:00
Christopher Kohlhoff
71907d44c5 Always enable std::invoke_result when targeting c++17 or later. 2022-12-07 07:35:27 +11:00
Christopher Kohlhoff
1941736519 Update detection of C++20 coroutine support on clang 14 and later.
This includes the ability to use coroutines with libstdc++.
2022-12-07 07:35:15 +11:00
Christopher Kohlhoff
2f124c3acb Add namespace qualifications to aligned_new and aligned_delete calls.
These functions are defined in the asio namespace but are called
from namespace asio_handler_alloc_helpers, hence the qualification
is needed.
2022-12-07 07:35:01 +11:00
Christopher Kohlhoff
d12b1a4f45 Add missing semicolon. 2022-12-07 07:34:50 +11:00
Christopher Kohlhoff
26fd5e9bb6 Fix the arguments to select_reactor::run. 2022-12-07 07:34:39 +11:00
Christopher Kohlhoff
7811479a80 Fix compatibility between co_spawn and any_completion_handler. 2022-12-07 07:34:26 +11:00
Christopher Kohlhoff
7fdff94997 Use snprintf rather than sprintf on latest Xcode. 2022-12-07 07:34:10 +11:00
Christopher Kohlhoff
e715db5fc4 Ensure spawn()'s completion handler is dispatched through the correct executor. 2022-12-07 07:33:54 +11:00
Christopher Kohlhoff
61796a5704 Dispatch cancellation handlers on the correct executor.
When a completion handler for spawn() or co_spawn() uses a specified
(i.e. non-default) associated executor, cancellation handlers need to
be dispatched to the executor that was passed to spawn() or co_spawn().
2022-12-07 07:33:39 +11:00
Christopher Kohlhoff
ce07af1fdf Fix namespace for co_composed's coroutine_traits specialisation. 2022-11-14 22:01:26 +11:00
Christopher Kohlhoff
dac750114c Version bump. 2022-11-09 23:23:56 +11:00
Christopher Kohlhoff
d5d33a7eda Revision history. 2022-11-09 23:23:28 +11:00
Christopher Kohlhoff
e874ca5aab Fall back to fcntl if ioctl fails with ENOTTY when setting non-blocking mode. 2022-11-09 21:57:53 +11:00
Christopher Kohlhoff
80fd0e2971 Constrain post/defer overloads on ability to require blocking.never. 2022-11-03 17:42:29 +11:00
Christopher Kohlhoff
0636a1ca16 Add io_executor_type and get_io_executor() to experimental::co_composed's state. 2022-11-03 17:32:16 +11:00
Christopher Kohlhoff
6ab07fa35e Add io_executor_type and get_io_executor to async_compose's 'self' object. 2022-11-03 17:32:07 +11:00
Christopher Kohlhoff
b67260f30a Add any_completion_handler.hpp to convenience header. 2022-11-03 17:31:53 +11:00
Christopher Kohlhoff
56c1f0f647 Cleaned up promise and made it an async_op. 2022-11-03 17:31:32 +11:00
Christopher Kohlhoff
09716d71f3 Enabled deferred awaiting for coros, regularized use_coro, and fixed allocator handling.
This means that use_coro does not return a coro object, just like
use_awaitable does, i.e. it's an overhead that buys us type erasure.
Allocators can now be set for coro by including allocator_arg in the
coro signature.
2022-11-03 17:29:53 +11:00
Christopher Kohlhoff
10fba74faa Fix broken get_nt_set_info() for overlapped handles.
When calling handle->release(), Asio uses kernel-provided
NtSetInformationFile() routine to remove IOCP for the specific handle.
Since this routine is not part of SDK, Asio retrieves the address of
that function from NTDLL.DLL and caches it into nt_set_info_ class
member. The fact that address is cached is checked by comparing it to 0.

The bug is that class member is not initialized and contains undefined
value, so Asio assumes that the address is already retrieved and uses
undefined value, which leads to acces violation.

Fix by initializing nt_set_info_ to zero, as it is done for sockets in
win_iocp_socket_service_base.ipp.
2022-11-03 17:28:47 +11:00
Christopher Kohlhoff
bf4dfbc607 Remove unused header. 2022-11-03 17:28:44 +11:00
Christopher Kohlhoff
74d0590e82 Make cancelled() public on an async_composed-base composed operation. 2022-11-03 17:27:27 +11:00
Christopher Kohlhoff
9e03478ba1 Add range-based experimental::make_parallel_group().
Added new overloads of experimental::make_parallel_group that may be used
to launch a dynamically-sized set of asynchronous operations, where all
operations are the same type. For example:

  using op_type = decltype(
      socket1.async_read_some(
        boost::asio::buffer(data1),
        boost::asio::deferred
      )
    );

  std::vector<op_type> ops;

  ops.push_back(
      socket1.async_read_some(
        boost::asio::buffer(data1),
        boost::asio::deferred
      )
    );

  ops.push_back(
      socket2.async_read_some(
        boost::asio::buffer(data2),
        boost::asio::deferred
      )
    );

  boost::asio::experimental::make_parallel_group(ops).async_wait(
      boost::asio::experimental::wait_for_all(),
      [](
          std::vector<std::size_t> completion_order,
          std::vector<boost::system::error_code> e,
          std::vector<std::size_t> n
        )
      {
        for (std::size_t i = 0; i < completion_order.size(); ++i)
        {
          std::size_t idx = completion_order[i];
          std::cout << "socket " << idx << " finished: ";
          std::cout << e[idx] << ", " << n[idx] << "\n";
        }
      }
    );

Thanks go to Klemens Morgenstern for supplying part of this implementation.
2022-11-03 00:48:45 +11:00
Christopher Kohlhoff
7b8d9b4f5f Fix link to experimental::co_composed. 2022-11-01 13:49:17 +11:00