Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions include/asio/detail/impl/socket_ops.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,9 @@ bool non_blocking_recv(socket_type s,
buf* bufs, size_t count, int flags, bool is_stream,
asio::error_code& ec, size_t& bytes_transferred)
{
#if defined(MSG_DONTWAIT)
flags |= MSG_DONTWAIT;
#endif
for (;;)
{
// Read some data.
Expand Down Expand Up @@ -1045,6 +1048,9 @@ bool non_blocking_recv1(socket_type s,
void* data, size_t size, int flags, bool is_stream,
asio::error_code& ec, size_t& bytes_transferred)
{
#if defined(MSG_DONTWAIT)
flags |= MSG_DONTWAIT;
#endif
for (;;)
{
// Read some data.
Expand Down Expand Up @@ -1256,6 +1262,9 @@ bool non_blocking_recvfrom(socket_type s, buf* bufs,
size_t count, int flags, void* addr, std::size_t* addrlen,
asio::error_code& ec, size_t& bytes_transferred)
{
#if defined(MSG_DONTWAIT)
flags |= MSG_DONTWAIT;
#endif
for (;;)
{
// Read some data.
Expand Down Expand Up @@ -1288,6 +1297,9 @@ bool non_blocking_recvfrom1(socket_type s, void* data,
size_t size, int flags, void* addr, std::size_t* addrlen,
asio::error_code& ec, size_t& bytes_transferred)
{
#if defined(MSG_DONTWAIT)
flags |= MSG_DONTWAIT;
#endif
for (;;)
{
// Read some data.
Expand Down Expand Up @@ -1401,6 +1413,9 @@ bool non_blocking_recvmsg(socket_type s,
buf* bufs, size_t count, int in_flags, int& out_flags,
asio::error_code& ec, size_t& bytes_transferred)
{
#if defined(MSG_DONTWAIT)
in_flags |= MSG_DONTWAIT;
#endif
for (;;)
{
// Read some data.
Expand Down Expand Up @@ -1597,6 +1612,9 @@ bool non_blocking_send(socket_type s,
const buf* bufs, size_t count, int flags,
asio::error_code& ec, size_t& bytes_transferred)
{
#if defined(MSG_DONTWAIT)
flags |= MSG_DONTWAIT;
#endif
for (;;)
{
// Write some data.
Expand Down Expand Up @@ -1628,6 +1646,9 @@ bool non_blocking_send1(socket_type s,
const void* data, size_t size, int flags,
asio::error_code& ec, size_t& bytes_transferred)
{
#if defined(MSG_DONTWAIT)
flags |= MSG_DONTWAIT;
#endif
for (;;)
{
// Write some data.
Expand Down Expand Up @@ -1808,6 +1829,9 @@ bool non_blocking_sendto(socket_type s,
const void* addr, std::size_t addrlen,
asio::error_code& ec, size_t& bytes_transferred)
{
#if defined(MSG_DONTWAIT)
flags |= MSG_DONTWAIT;
#endif
for (;;)
{
// Write some data.
Expand Down Expand Up @@ -1841,6 +1865,9 @@ bool non_blocking_sendto1(socket_type s,
const void* addr, std::size_t addrlen,
asio::error_code& ec, size_t& bytes_transferred)
{
#if defined(MSG_DONTWAIT)
flags |= MSG_DONTWAIT;
#endif
for (;;)
{
// Write some data.
Expand Down
16 changes: 14 additions & 2 deletions include/asio/detail/reactive_socket_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,14 @@ class reactive_socket_service :
ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
&impl, impl.socket_, "async_send_to"));

#if defined(MSG_DONTWAIT)
constexpr bool has_msg_dontwait = true;
#else
constexpr bool has_msg_dontwait = false;
#endif

start_op(impl, reactor::write_op, p.p,
is_continuation, true, false, true, &io_ex, 0);
is_continuation, true, false, !has_msg_dontwait, &io_ex, 0);
p.v = p.p = 0;
}

Expand Down Expand Up @@ -430,10 +436,16 @@ class reactive_socket_service :
ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
&impl, impl.socket_, "async_receive_from"));

#if defined(MSG_DONTWAIT)
constexpr bool has_msg_dontwait = true;
#else
constexpr bool has_msg_dontwait = false;
#endif

start_op(impl,
(flags & socket_base::message_out_of_band)
? reactor::except_op : reactor::read_op,
p.p, is_continuation, true, false, true, &io_ex, 0);
p.p, is_continuation, true, false, !has_msg_dontwait, &io_ex, 0);
p.v = p.p = 0;
}

Expand Down
24 changes: 21 additions & 3 deletions include/asio/detail/reactive_socket_service_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,16 @@ class reactive_socket_service_base
ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
&impl, impl.socket_, "async_send"));

#if defined(MSG_DONTWAIT)
constexpr bool has_msg_dontwait = true;
#else
constexpr bool has_msg_dontwait = false;
#endif

start_op(impl, reactor::write_op, p.p, is_continuation, true,
((impl.state_ & socket_ops::stream_oriented)
&& buffer_sequence_adapter<asio::const_buffer,
ConstBufferSequence>::all_empty(buffers)), true, &io_ex, 0);
ConstBufferSequence>::all_empty(buffers)), !has_msg_dontwait, &io_ex, 0);
p.v = p.p = 0;
}

Expand Down Expand Up @@ -419,14 +425,20 @@ class reactive_socket_service_base
ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
&impl, impl.socket_, "async_receive"));

#if defined(MSG_DONTWAIT)
constexpr bool has_msg_dontwait = true;
#else
constexpr bool has_msg_dontwait = false;
#endif

start_op(impl,
(flags & socket_base::message_out_of_band)
? reactor::except_op : reactor::read_op,
p.p, is_continuation,
(flags & socket_base::message_out_of_band) == 0,
((impl.state_ & socket_ops::stream_oriented)
&& buffer_sequence_adapter<asio::mutable_buffer,
MutableBufferSequence>::all_empty(buffers)), true, &io_ex, 0);
MutableBufferSequence>::all_empty(buffers)), !has_msg_dontwait, &io_ex, 0);
p.v = p.p = 0;
}

Expand Down Expand Up @@ -530,12 +542,18 @@ class reactive_socket_service_base
ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
&impl, impl.socket_, "async_receive_with_flags"));

#if defined(MSG_DONTWAIT)
constexpr bool has_msg_dontwait = true;
#else
constexpr bool has_msg_dontwait = false;
#endif

start_op(impl,
(in_flags & socket_base::message_out_of_band)
? reactor::except_op : reactor::read_op,
p.p, is_continuation,
(in_flags & socket_base::message_out_of_band) == 0,
false, true, &io_ex, 0);
false, !has_msg_dontwait, &io_ex, 0);
p.v = p.p = 0;
}

Expand Down