UringServerChannelUnsafe Class — netty Architecture
Architecture documentation for the UringServerChannelUnsafe class in AbstractIoUringServerChannel.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 92c310a1_fd2c_26a6_1171_7ed00ce40178["UringServerChannelUnsafe"] 5b47452d_abef_bdce_c83f_bda00ce524e5["AbstractIoUringServerChannel.java"] 92c310a1_fd2c_26a6_1171_7ed00ce40178 -->|defined in| 5b47452d_abef_bdce_c83f_bda00ce524e5 c41d33dd_adc9_d721_ce2f_79bc65ebd263["scheduleWriteMultiple()"] 92c310a1_fd2c_26a6_1171_7ed00ce40178 -->|method| c41d33dd_adc9_d721_ce2f_79bc65ebd263 f51c9b53_f85c_87c3_c9d1_3f48773cfd36["scheduleWriteSingle()"] 92c310a1_fd2c_26a6_1171_7ed00ce40178 -->|method| f51c9b53_f85c_87c3_c9d1_3f48773cfd36 6c69a69c_92e2_d6e4_db9f_1087e68b7b4e["writeComplete0()"] 92c310a1_fd2c_26a6_1171_7ed00ce40178 -->|method| 6c69a69c_92e2_d6e4_db9f_1087e68b7b4e 18480b94_3706_e128_938e_ec849da3eb51["scheduleRead0()"] 92c310a1_fd2c_26a6_1171_7ed00ce40178 -->|method| 18480b94_3706_e128_938e_ec849da3eb51 e2ee99fb_f186_acab_0b67_59f9b2eebadd["readComplete0()"] 92c310a1_fd2c_26a6_1171_7ed00ce40178 -->|method| e2ee99fb_f186_acab_0b67_59f9b2eebadd b17f13c4_0efd_d14d_d81e_58a8fc48be44["connect()"] 92c310a1_fd2c_26a6_1171_7ed00ce40178 -->|method| b17f13c4_0efd_d14d_d81e_58a8fc48be44 51e16d68_1abd_04cd_4409_0fe3b1d56be6["unregistered()"] 92c310a1_fd2c_26a6_1171_7ed00ce40178 -->|method| 51e16d68_1abd_04cd_4409_0fe3b1d56be6
Relationship Graph
Source Code
transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIoUringServerChannel.java lines 132–286
private final class UringServerChannelUnsafe extends AbstractIoUringChannel.AbstractUringUnsafe {
@Override
protected int scheduleWriteMultiple(ChannelOutboundBuffer in) {
throw new UnsupportedOperationException();
}
@Override
protected int scheduleWriteSingle(Object msg) {
throw new UnsupportedOperationException();
}
@Override
boolean writeComplete0(byte op, int res, int flags, short data, int outstanding) {
throw new UnsupportedOperationException();
}
@Override
protected int scheduleRead0(boolean first, boolean socketIsEmpty) {
assert acceptId == 0;
final IoUringRecvByteAllocatorHandle allocHandle = recvBufAllocHandle();
allocHandle.attemptedBytesRead(1);
int fd = fd().intValue();
IoRegistration registration = registration();
final short ioPrio;
final long acceptedAddressMemoryAddress;
final long acceptedAddressLengthMemoryAddress;
if (IoUring.isAcceptMultishotEnabled()) {
// Let's use multi-shot accept to reduce overhead.
ioPrio = Native.IORING_ACCEPT_MULTISHOT;
acceptedAddressMemoryAddress = 0;
acceptedAddressLengthMemoryAddress = 0;
} else {
// Depending on if socketIsEmpty is true we will arm the poll upfront and skip the initial transfer
// attempt.
// See https://github.com/axboe/liburing/wiki/io_uring-and-networking-in-2023#socket-state
//
// Depending on if this is the first read or not we will use Native.IORING_ACCEPT_DONT_WAIT.
// The idea is that if the socket is blocking we can do the first read in a blocking fashion
// and so not need to also register POLLIN. As we can not 100 % sure if reads after the first will
// be possible directly we schedule these with Native.IORING_ACCEPT_DONT_WAIT. This allows us to still
// be able to signal the fireChannelReadComplete() in a timely manner and be consistent with other
// transports.
//
// IORING_ACCEPT_POLL_FIRST and IORING_ACCEPT_DONTWAIT were added in the same release.
// We need to check if its supported as otherwise providing these would result in an -EINVAL.
if (IoUring.isAcceptNoWaitSupported()) {
if (first) {
ioPrio = socketIsEmpty ? Native.IORING_ACCEPT_POLL_FIRST : 0;
} else {
ioPrio = Native.IORING_ACCEPT_DONTWAIT;
}
} else {
ioPrio = 0;
}
assert acceptedAddressMemory != null;
acceptedAddressMemoryAddress = acceptedAddressMemory.acceptedAddressMemoryAddress;
acceptedAddressLengthMemoryAddress = acceptedAddressMemory.acceptedAddressLengthMemoryAddress;
}
// See https://github.com/axboe/liburing/wiki/What's-new-with-io_uring-in-6.10#improvements-for-accept
IoUringIoOps ops = IoUringIoOps.newAccept(fd, (byte) 0, 0, ioPrio,
acceptedAddressMemoryAddress, acceptedAddressLengthMemoryAddress, nextOpsId());
acceptId = registration.submit(ops);
if (acceptId == 0) {
return 0;
}
if ((ioPrio & Native.IORING_ACCEPT_MULTISHOT) != 0) {
// Let's return -1 to signal that we used multi-shot.
return -1;
}
return 1;
}
@Override
protected void readComplete0(byte op, int res, int flags, short data, int outstanding) {
if (res == Native.ERRNO_ECANCELED_NEGATIVE) {
Defined In
Source
Frequently Asked Questions
What is the UringServerChannelUnsafe class?
UringServerChannelUnsafe is a class in the netty codebase, defined in transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIoUringServerChannel.java.
Where is UringServerChannelUnsafe defined?
UringServerChannelUnsafe is defined in transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIoUringServerChannel.java at line 132.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free