GeezerVison is showing github.com — 1 apply review comment · netty/netty@57135f5
File treeExpand file treeCollapse file tree Open diff view settings transport-classes-io_uring/src/main/java/io/netty/channel/uring
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringIoHandler.java +15-14Lines changed: 15 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -277,6 +277,13 @@ private static void handleLoopException(Throwable throwable) { | 277 | 277 |
| 278 | 278 | private void handle(int res, int flags, long udata, ByteBuffer extraCqeData) { | 279 | 279 | try { | | 280 | + if (udata == EVENTFD_TOKEN) { | | 281 | + handleEventFdRead(); | | 282 | + return; | | 283 | + } | | 284 | + if (udata == RINGFD_TOKEN) { | | 285 | + return; | | 286 | + } | 280 | 287 | // Only remove from pendingOps if IORING_CQE_F_MORE is not set, as otherwise we know | 281 | 288 | // that we will receive more completions for the initial request. | 282 | 289 | boolean oneshotOp = (flags & Native.IORING_CQE_F_MORE) == 0; | @@ -294,25 +301,13 @@ private void handle(int res, int flags, long udata, ByteBuffer extraCqeData) { | 294 | 301 | return; | 295 | 302 | } | 296 | 303 | } | 297 | | - if (udata == EVENTFD_TOKEN) { | 298 | | - handleEventFdRead(); | 299 | | - return; | 300 | | - } | 301 | | - if (udata == RINGFD_TOKEN) { | 302 | | - return; | 303 | | - } | 304 | 304 | int slot = pendingOps.findSlot(udata); | 305 | 305 | if (slot != -1) { | 306 | 306 | int registrationId = pendingOps.registrationId(slot); | 307 | 307 | DefaultIoUringIoRegistration registration = registrations.get(registrationId); | 308 | 308 | byte op = pendingOps.op(slot); | 309 | 309 | long userData = pendingOps.userData(slot); | 310 | 310 |
| 311 | | - if (logger.isTraceEnabled()) { | 312 | | - logger.trace("completed(ring {}): {}(userData={}, res={})", | 313 | | - ringBuffer.fd(), Native.opToStr(op), userData, res); | 314 | | - } | 315 | | - | 316 | 311 | // Recycle if this completion is terminal (no more CQEs expected for this SQE). | 317 | 312 | if (oneshotOp) { | 318 | 313 | pendingOps.release(slot); | @@ -322,6 +317,11 @@ private void handle(int res, int flags, long udata, ByteBuffer extraCqeData) { | 322 | 317 | if (registration != null) { | 323 | 318 | registration.handle(res, flags, op, userData, extraCqeData); | 324 | 319 | } | | 320 | + | | 321 | + if (logger.isTraceEnabled()) { | | 322 | + logger.trace("completed(ring {}): {}(userData={}, res={})", | | 323 | + ringBuffer.fd(), Native.opToStr(op), userData, res); | | 324 | + } | 325 | 325 | return; | 326 | 326 | } | 327 | 327 | if (logger.isDebugEnabled()) { | @@ -577,11 +577,10 @@ public long submit(IoOps ops) { | 577 | 577 | long token = pendingOps.nextToken(); | 578 | 578 | if (executor.isExecutorThread(Thread.currentThread())) { | 579 | 579 | submitSlowPath0(ioOps, token, userData); | 580 | | - return token; | 581 | 580 | } else { | 582 | 581 | executor.execute(() -> submitSlowPath0(ioOps, token, userData)); | 583 | | - return token; | 584 | 582 | } | | 583 | + return token; | 585 | 584 | } | 586 | 585 |
| 587 | 586 | private void submitFastPath0(IoUringIoOps ioOps, long seq) { | @@ -690,6 +689,8 @@ private static final class PendingOpSlots { | 690 | 689 | long nextToken() { | 691 | 690 | long sequence = nextSequence.getAndIncrement(); | 692 | 691 | if (sequence <= 0) { | | 692 | + // Monotonic sequence starting at 3; ~29k years to exhaust positive long space at 10M/s, | | 693 | + // so overflow is purely theoretical. | 693 | 694 | throw new IllegalStateException("slow path sequence overflow"); | 694 | 695 | } | 695 | 696 | return token(sequence); | |
Collapse file Copy file name to clipboardExpand all lines: transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringIoOps.java +11-8Lines changed: 11 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -37,6 +37,17 @@ public final class IoUringIoOps implements IoOps { | 37 | 37 | private final int union5; | 38 | 38 | private final long union6; | 39 | 39 |
| | 40 | + /** | | 41 | + * Create a new instance which represents the {@code io_uring_sqe} struct. | | 42 | + * @deprecated use | | 43 | + * {@link #IoUringIoOps(byte, byte, short, int, long, long, int, int, long, short, short, int, long)} instead. | | 44 | + */ | | 45 | + @Deprecated | | 46 | + public IoUringIoOps(byte opcode, byte flags, short ioPrio, int fd, long union1, long union2, int len, int union3, | | 47 | + short data, short union4, short personality, int union5, long union6) { | | 48 | + this(opcode, flags, ioPrio, fd, union1, union2, len, union3, (long) data, union4, personality, union5, union6); | | 49 | + } | | 50 | + | 40 | 51 | /** | 41 | 52 | * Create a new instance which represents the {@code io_uring_sqe} struct. | 42 | 53 | * | @@ -131,14 +142,6 @@ public final class IoUringIoOps implements IoOps { | 131 | 142 | * } | 132 | 143 | * </pre> | 133 | 144 | */ | 134 | | - public IoUringIoOps(byte opcode, byte flags, short ioPrio, int fd, long union1, long union2, int len, int union3, | 135 | | - short data, short union4, short personality, int union5, long union6) { | 136 | | - this(opcode, flags, ioPrio, fd, union1, union2, len, union3, (long) data, union4, personality, union5, union6); | 137 | | - } | 138 | | - | 139 | | - /** | 140 | | - * Create a new instance which represents the {@code io_uring_sqe} struct with a full long user data. | 141 | | - */ | 142 | 145 | public IoUringIoOps(byte opcode, byte flags, short ioPrio, int fd, long union1, long union2, int len, int union3, | 143 | 146 | long data, short union4, short personality, int union5, long union6) { | 144 | 147 | this.opcode = opcode; | |
|