Skip to content

Commit 97ad45f

Browse files
committed
support for ZeroCopy Send
two changes: 1. use IORING_OP_SENDMSG_ZC instead of IORING_OP_SENDMSG for sending. 2. support for multislot completion notify. the proactor nature in asio is very suitable for zero-copy send. since the buffer is assumed to be valid until operation complete. the only drawback is kernel requirement but this is not an issue. people tent to upgrade their kernel to take advantage of io-uring anyway.
1 parent 62481a2 commit 97ad45f

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

asio/include/asio/detail/impl/io_uring_service.ipp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,16 @@ void io_uring_service::run(long usec, op_queue<operation>& ops)
482482
{
483483
--local_ops;
484484
}
485+
else if (cqe->flags & IORING_CQE_F_MORE)
486+
{
487+
io_queue* io_q = static_cast<io_queue*>(ptr);
488+
io_q->set_result(cqe->res);
489+
}
490+
else if (cqe->flags & IORING_CQE_F_NOTIF)
491+
{
492+
io_queue* io_q = static_cast<io_queue*>(ptr);
493+
ops.push(io_q);
494+
}
485495
else
486496
{
487497
io_queue* io_q = static_cast<io_queue*>(ptr);

asio/include/asio/detail/io_uring_socket_send_op.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class io_uring_socket_send_op_base : public io_uring_operation
7373
}
7474
else
7575
{
76-
::io_uring_prep_sendmsg(sqe, o->socket_, &o->msghdr_, o->flags_);
76+
::io_uring_prep_sendmsg_zc(sqe, o->socket_, &o->msghdr_, o->flags_);
7777
}
7878
}
7979

asio/include/asio/detail/io_uring_socket_sendto_op.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class io_uring_socket_sendto_op_base : public io_uring_operation
7070
}
7171
else
7272
{
73-
::io_uring_prep_sendmsg(sqe, o->socket_, &o->msghdr_, o->flags_);
73+
::io_uring_prep_sendmsg_zc(sqe, o->socket_, &o->msghdr_, o->flags_);
7474
}
7575
}
7676

0 commit comments

Comments
 (0)