Bug related to DefaultFileRegion offset position for EpollSocketChannel?

31 views
Skip to first unread message

Reynold Xin

unread,
Aug 13, 2014, 5:57:08 PM8/13/14
to ne...@googlegroups.com

This is the latest writeFileRegion code on 4.0 branch:

    private boolean writeFileRegion(ChannelOutboundBuffer in, DefaultFileRegion region) throws Exception {
        if (region.transfered() >= region.count()) {
            in.remove();
            return true;
        }

        boolean done = false;
        long flushedAmount = 0;

        for (int i = config().getWriteSpinCount() - 1; i >= 0; i --) {
            long expected = region.count() - region.position();
            long localFlushedAmount = Native.sendfile(fd, region, region.transfered(), expected);
            if (localFlushedAmount == 0) {
                // Returned EAGAIN need to set EPOLLOUT
                setEpollOut();
                break;
            }

            flushedAmount += localFlushedAmount;
            if (region.transfered() >= region.count()) {
                done = true;
                break;
            }
        }

        in.progress(flushedAmount);

        if (done) {
            in.remove();
        }
        return done;
    }

Should the highlighted part be region.position() + region.transferred() ?

Java_io_netty_channel_epoll_Native_sendfile's 3rd argument is off (offset), and if I am reading this correctly, writeFileRegion here ignores the offset specified by DefaultFileRegion.



이희승 (Trustin Lee)

unread,
Aug 13, 2014, 8:01:45 PM8/13/14
to Netty Discussions
Thanks for reporting. It's fixed now: https://github.com/netty/netty/issues/2764


--

---
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Norman Maurer

unread,
Aug 13, 2014, 11:56:51 PM8/13/14
to ne...@googlegroups.com
Thanks for taking care :)
Reply all
Reply to author
Forward
0 new messages