[#2823] Writing DefaultFileRegion with EpollSocketChannel may cause hang

Motivation:

In EpollSocketchannel.doWriteFileRegion(...) we need to make sure we write until sendFile(...) returns either 0 or all is written. Otherwise we may not get notified once the Channel is writable again.

This is the case as we use EPOLL_ET.

Modifications:

Always write until either sendFile returns 0 or all is written.

Result:

No more hangs when writing DefaultFileRegion can happen.
This commit is contained in:
Norman Maurer 2014-08-26 15:07:02 +02:00
parent dd557ca583
commit b9101b0331

View File

@ -276,7 +276,7 @@ public final class EpollSocketChannel extends AbstractEpollChannel implements So
boolean done = false;
long flushedAmount = 0;
for (int i = config().getWriteSpinCount() - 1; i >= 0; i --) {
for (;;) {
final long offset = region.transfered();
final long localFlushedAmount = Native.sendfile(fd, region, baseOffset, offset, regionCount - offset);
if (localFlushedAmount == 0) {