Skip to content
Draft
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
7 changes: 3 additions & 4 deletions include/condy/async_operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,11 +930,10 @@ inline auto async_uring_cmd128(int cmd_op, Fd fd, CmdFunc &&cmd_func,
cmd_func =
std::forward<CmdFunc>(cmd_func)](detail::Ring *ring) {
auto *sqe = ring->get_sqe128();
if (!sqe) {
detail::panic_on("SQE128 not enabled in the ring");
if (sqe) {
io_uring_prep_uring_cmd128(sqe, cmd_op, fd);
cmd_func(sqe);
}
io_uring_prep_uring_cmd128(sqe, cmd_op, fd);
cmd_func(sqe);
return sqe;
};
auto op = build_op_awaiter<CQEHandler>(std::move(prep_func),
Expand Down
5 changes: 2 additions & 3 deletions include/condy/detail/async_operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ auto make_op_awaiter128(Func &&func, Args &&...args) {
... args =
unwrap_fixed(std::forward<Args>(args))](Ring *ring) {
auto *sqe = ring->get_sqe128();
if (!sqe) {
panic_on("SQE128 not enabled in the ring");
if (sqe) {
func(sqe, args...);
}
func(sqe, args...);
return sqe;
};
return build_op_awaiter<SimpleCQEHandler>(std::move(prep_func));
Expand Down
9 changes: 7 additions & 2 deletions include/condy/detail/op_states.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ template <typename Handle, PrepFuncLike Func> class OpSenderOperationState {
void start(unsigned int flags) noexcept {
auto &context = Context::current();
auto &ring = context.runtime()->ring_internal();
context.runtime()->pend_work_internal();
io_uring_sqe *sqe = prep_func_(&ring);
assert(sqe && "prep_func must return a valid sqe");
if (sqe == nullptr) {
io_uring_cqe cqe = {};
cqe.res = -EINVAL;
finish_handle_.get().handle(&cqe);
return;
}
context.runtime()->pend_work_internal();
io_uring_sqe_set_flags(sqe, sqe->flags | flags);
auto work = encode_work(&finish_handle_.get(), WorkType::Common);
io_uring_sqe_set_data64(sqe, work);
Expand Down
11 changes: 11 additions & 0 deletions tests/test_async_operations.2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ TEST_CASE("test async_operations - test nop128 - sqe mixed") {
}
#endif

#if CONDY_URING_VERSION_GE(2, 13) // >= 2.13
TEST_CASE("test async_operations - test nop128 - no sqe128") {
condy::Runtime runtime;
auto func = [&]() -> condy::Coro<void> {
int r = co_await condy::async_nop128();
REQUIRE(r == -EINVAL);
};
condy::sync_wait(runtime, func());
}
#endif

TEST_CASE("test async_operations - test timeout - basic") {
auto func = [&]() -> condy::Coro<void> {
__kernel_timespec ts = {
Expand Down
20 changes: 20 additions & 0 deletions tests/test_async_operations.4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,26 @@ TEST_CASE("test async_operations - test uring_cmd_multishot - tx timestamp") {
}
#endif

#if CONDY_URING_VERSION_GE(2, 13) // >= 2.13
TEST_CASE("test async_operations - test uring_cmd128 - no sqe128") {
condy::Runtime runtime;

int listen_fd = socket(AF_INET, SOCK_STREAM, 0);
REQUIRE(listen_fd >= 0);

auto func = [&]() -> condy::Coro<void> {
int val = 1;
int r = co_await my_async_cmd_sock<true>(
SOCKET_URING_OP_SETSOCKOPT, listen_fd, SOL_SOCKET, SO_REUSEADDR,
&val, sizeof(val));
REQUIRE(r == -EINVAL);
};
condy::sync_wait(runtime, func());

close(listen_fd);
}
#endif

#if CONDY_URING_VERSION_GE(2, 13) // >= 2.13
TEST_CASE("test async_operations - test uring_cmd128 - cmd sock - basic") {
condy::Runtime runtime(
Expand Down
Loading