Skip to content

Commit ab8af9c

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 ab8af9c

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,18 @@ 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+
// std::printf("got IORING_CQE_F_MORE\n");
488+
io_queue* io_q = static_cast<io_queue*>(ptr);
489+
io_q->set_result(cqe->res);
490+
}
491+
else if (cqe->flags & IORING_CQE_F_NOTIF)
492+
{
493+
// std::printf("got IORING_CQE_F_NOTIF\n");
494+
io_queue* io_q = static_cast<io_queue*>(ptr);
495+
ops.push(io_q);
496+
}
485497
else
486498
{
487499
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)