Skip to content

Commit

Permalink
(io_uring) Simplify new entry creation
Browse files Browse the repository at this point in the history
Also add fix for rebase
  • Loading branch information
InKryption committed Feb 4, 2025
1 parent 8c68446 commit 85136f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
19 changes: 7 additions & 12 deletions src/rpc/server/linux_io_uring.zig
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,17 @@ fn consumeOurCqe(
const buffer = try server_ctx.allocator.alloc(u8, server_ctx.read_buffer_size);
errdefer server_ctx.allocator.free(buffer);

const new_recv_entry: Entry = entry: {
const data_ptr = try server_ctx.allocator.create(EntryData);
errdefer comptime unreachable;

data_ptr.* = .{
.buffer = buffer,
.stream = stream,
.state = EntryState.INIT,
};
break :entry .{ .ptr = data_ptr };
const data_ptr = try server_ctx.allocator.create(EntryData);
errdefer server_ctx.allocator.destroy(data_ptr);
data_ptr.* = .{
.buffer = buffer,
.stream = stream,
.state = EntryState.INIT,
};
errdefer if (new_recv_entry.ptr) |data_ptr| server_ctx.allocator.destroy(data_ptr);

const sqe = try getSqeRetry(&liou.io_uring);
sqe.prep_recv(stream.handle, buffer, 0);
sqe.user_data = @bitCast(new_recv_entry);
sqe.user_data = @bitCast(Entry{ .ptr = data_ptr });
return;
};
errdefer server_ctx.wait_group.finish();
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/server/requests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub const MAX_TARGET_LEN: usize = blk: {
break :blk "/".len + SnapSpec.fmtLenValue(.{
.base_slot = std.math.maxInt(sig.core.Slot),
.slot = std.math.maxInt(sig.core.Slot),
.hash = sig.core.Hash.base58String(.{ .data = .{255} ** sig.core.Hash.size }).constSlice(),
.hash = sig.core.Hash.base58String(.{ .data = .{255} ** sig.core.Hash.SIZE }).constSlice(),
});
};
pub const TargetBoundedStr = std.BoundedArray(u8, MAX_TARGET_LEN);
Expand Down

0 comments on commit 85136f9

Please sign in to comment.