GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||
GeezerVison is showing github.com — io_uring stream channel does not support generic FileRegion, causing ClassCastException · Issue #16570 · netty/netty Closed DescriptionSummary
Expected behaviorAny Actual behaviorWriting a custom Additionally, } else { ByteBuf buf = (ByteBuf) msg; // would ClassCastException if a FileRegion reached here Root causeIn protected Object filterOutboundMessage(Object msg) { if (IoUring.isSpliceSupported() && msg instanceof DefaultFileRegion) { return new IoUringFileRegion((DefaultFileRegion) msg); } // Any non-DefaultFileRegion FileRegion falls through to super, // which only accepts ByteBuf and throws UnsupportedOperationException. return super.filterOutboundMessage(msg); } Compare with EPOLL's protected Object filterOutboundMessage(Object msg) { if (msg instanceof ByteBuf) { ... } if (msg instanceof FileRegion || msg instanceof SpliceOutTask) { return msg; // accepts ANY FileRegion } throw new UnsupportedOperationException(...); } And EPOLL's if (msg instanceof DefaultFileRegion) { return writeDefaultFileRegion(in, (DefaultFileRegion) msg); // sendfile } else if (msg instanceof FileRegion) { return writeFileRegion(in, (FileRegion) msg); // transferTo fallback } io_uring has no such fallback. Affected use caseApache Spark wraps I am currently evaluating Apache Spark's support for io_uring transport. This issue blocks io_uring adoption for any framework that wraps Proposed fixAdd a generic protected Object filterOutboundMessage(Object msg) { if (IoUring.isSpliceSupported() && msg instanceof DefaultFileRegion) { return new IoUringFileRegion((DefaultFileRegion) msg); } if (msg instanceof FileRegion) { FileRegion region = (FileRegion) msg; long remaining = region.count() - region.transferred(); ByteBuf buf = alloc().directBuffer((int) remaining); try { ByteBufWritableByteChannel channel = new ByteBufWritableByteChannel(buf); while (region.transferred() < region.count()) { long transferred = region.transferTo(channel, region.transferred()); if (transferred <= 0) { break; } } } catch (IOException e) { buf.release(); throw new RuntimeException("Failed to convert FileRegion to ByteBuf", e); } finally { region.release(); } return buf; } return super.filterOutboundMessage(msg); } This is not zero-copy but is functionally correct and consistent with EPOLL's Comparison across transports
Environment
Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions | |||||||||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |