Skip to content

Commit 7b43abb

Browse files
committed
IoUring: fix and remove TODOs
backout from updating `pipe2` syscall to use Pipe2 flags Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
1 parent 636e120 commit 7b43abb

File tree

2 files changed

+6
-35
lines changed

2 files changed

+6
-35
lines changed

lib/std/os/linux.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ pub fn pipe(fd: *[2]i32) usize {
13351335
}
13361336
}
13371337

1338-
pub fn pipe2(fd: *[2]i32, flags: Pipe2) usize {
1338+
pub fn pipe2(fd: *[2]i32, flags: O) usize {
13391339
return syscall2(.pipe2, @intFromPtr(fd), @as(u32, @bitCast(flags)));
13401340
}
13411341

lib/std/os/linux/IoUring.zig

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -927,12 +927,9 @@ pub fn bind(
927927
fd: linux.fd_t,
928928
addr: *const linux.sockaddr,
929929
addrlen: linux.socklen_t,
930-
// liburing doesn't have this flag, hence 0 should be passed
931-
// TODO: consider removing this and all flags like this
932-
flags: u32,
933930
) !*Sqe {
934931
const sqe = try self.get_sqe();
935-
sqe.prep_bind(fd, addr, addrlen, flags);
932+
sqe.prep_bind(fd, addr, addrlen);
936933
sqe.user_data = user_data;
937934
return sqe;
938935
}
@@ -945,12 +942,9 @@ pub fn listen(
945942
user_data: u64,
946943
fd: linux.fd_t,
947944
backlog: u32,
948-
// liburing doesn't have this flag, hence 0 should be passed
949-
// TODO: consider removing this and all flags like this
950-
flags: u32,
951945
) !*Sqe {
952946
const sqe = try self.get_sqe();
953-
sqe.prep_listen(fd, backlog, flags);
947+
sqe.prep_listen(fd, backlog);
954948
sqe.user_data = user_data;
955949
return sqe;
956950
}
@@ -3509,26 +3503,21 @@ pub const Sqe = extern struct {
35093503
sqe.set_target_fixed_file(file_index);
35103504
}
35113505

3512-
// TODO: maybe remove unused flag fields?
35133506
pub fn prep_bind(
35143507
sqe: *Sqe,
35153508
fd: linux.fd_t,
35163509
addr: *const linux.sockaddr,
35173510
addrlen: linux.socklen_t,
3518-
flags: u32, // flags is unused and does't exist in io_uring's api
35193511
) void {
35203512
sqe.prep_rw(.bind, fd, @intFromPtr(addr), 0, addrlen);
3521-
sqe.rw_flags = flags;
35223513
}
35233514

35243515
pub fn prep_listen(
35253516
sqe: *Sqe,
35263517
fd: linux.fd_t,
35273518
backlog: u32,
3528-
flags: u32, // flags is unused and does't exist in io_uring's api
35293519
) void {
35303520
sqe.prep_rw(.listen, fd, 0, backlog, 0);
3531-
sqe.rw_flags = flags;
35323521
}
35333522

35343523
pub fn prep_cmd_sock(
@@ -4466,8 +4455,7 @@ pub const uflags = struct {
44664455
link_timeout_update: bool = false,
44674456
/// Available since Linux 5.16
44684457
timeout_etime_success: bool = false,
4469-
// COMMIT: new Timeout Flag
4470-
// TODO: add when it became available
4458+
/// Available since Linux 6.4
44714459
timeout_multishot: bool = false,
44724460
_8: u25 = 0,
44734461
};
@@ -4487,7 +4475,6 @@ pub const uflags = struct {
44874475
/// Multishot poll. Sets IORING_CQE_F_MORE if the poll handler will
44884476
/// continue to report CQEs on behalf of the same SQE.
44894477
add_multi: bool = false,
4490-
// TODO: verify this doc comment is valid for the 2 flags below
44914478
/// IORING_POLL_UPDATE
44924479
/// Update existing poll request, matching sqe.addr as the old user_data
44934480
/// field.
@@ -4807,8 +4794,6 @@ pub const Op = enum(u8) {
48074794
bind,
48084795
listen,
48094796
recv_zc,
4810-
// COMMIT: new OPs
4811-
// TODO: to be implemented
48124797
epoll_wait,
48134798
readv_fixed,
48144799
writev_fixed,
@@ -4817,20 +4802,6 @@ pub const Op = enum(u8) {
48174802
_,
48184803
};
48194804

4820-
// TODO: I don't see these types in liburing and on a ddg search
4821-
// Maybe they should be removed
4822-
pub const io_uring_notification_slot = extern struct {
4823-
tag: u64,
4824-
resv: [3]u64,
4825-
};
4826-
pub const io_uring_notification_register = extern struct {
4827-
nr_slots: u32,
4828-
resv: u32,
4829-
resv2: u64,
4830-
data: u64,
4831-
resv3: u64,
4832-
};
4833-
48344805
test "structs/offsets/entries" {
48354806
if (!is_linux) return error.SkipZigTest;
48364807

@@ -7519,8 +7490,8 @@ test "bind/listen/connect" {
75197490
var optval: u32 = 1;
75207491
(try ring.setsockopt(2, listen_fd, .socket, .reuseaddr, mem.asBytes(&optval))).link_next();
75217492
(try ring.setsockopt(3, listen_fd, .socket, .reuseport, mem.asBytes(&optval))).link_next();
7522-
(try ring.bind(4, listen_fd, &addr.any, addr.getOsSockLen(), 0)).link_next();
7523-
_ = try ring.listen(5, listen_fd, 1, 0);
7493+
(try ring.bind(4, listen_fd, &addr.any, addr.getOsSockLen())).link_next();
7494+
_ = try ring.listen(5, listen_fd, 1);
75247495
// Submit 4 operations
75257496
try testing.expectEqual(4, try ring.submit());
75267497
// Expect all to succeed

0 commit comments

Comments
 (0)