Fallback to simple write when we can not allocate iovec array and correctly handle poll mask

This commit is contained in:
Norman Maurer 2020-08-30 21:13:52 +02:00
parent f77aa54f18
commit 076c35f785
2 changed files with 15 additions and 14 deletions

View File

@ -290,7 +290,8 @@ abstract class AbstractIOUringChannel extends AbstractChannel implements UnixCha
try {
in.forEachFlushedMessage(iovecArray);
} catch (Exception e) {
// This should never happem, anyway fallback to single write.
doWriteSingle((ByteBuf) in.current());
}
if (iovecArray.count() > 0) {
@ -298,8 +299,10 @@ abstract class AbstractIOUringChannel extends AbstractChannel implements UnixCha
submissionQueue().submit();
writeScheduled = true;
}
} else {
// We were not be able to create a new iovec, fallback to single write.
doWriteSingle((ByteBuf) in.current());
}
//Todo error handling
}

View File

@ -192,6 +192,8 @@ final class IOUringEventLoop extends SingleThreadEventLoop implements
((AbstractIOUringChannel.AbstractUringUnsafe) readChannel.unsafe()).readComplete(res);
break;
case IOUring.OP_WRITEV:
// Fall-through
case IOUring.OP_WRITE:
AbstractIOUringChannel writeChannel = channels.get(fd);
if (writeChannel == null) {
@ -219,18 +221,14 @@ final class IOUringEventLoop extends SingleThreadEventLoop implements
if (channel == null) {
break;
}
switch (pollMask) {
case IOUring.POLLMASK_IN:
((AbstractIOUringChannel.AbstractUringUnsafe) channel.unsafe()).pollIn(res);
break;
case IOUring.POLLMASK_OUT:
((AbstractIOUringChannel.AbstractUringUnsafe) channel.unsafe()).pollOut(res);
break;
case IOUring.POLLMASK_RDHUP:
((AbstractIOUringChannel.AbstractUringUnsafe) channel.unsafe()).pollRdHup(res);
break;
default:
break;
if ((pollMask & IOUring.POLLMASK_OUT) != 0) {
((AbstractIOUringChannel.AbstractUringUnsafe) channel.unsafe()).pollOut(res);
}
if ((pollMask & IOUring.POLLMASK_IN) != 0) {
((AbstractIOUringChannel.AbstractUringUnsafe) channel.unsafe()).pollIn(res);
}
if ((pollMask & IOUring.POLLMASK_RDHUP) != 0) {
((AbstractIOUringChannel.AbstractUringUnsafe) channel.unsafe()).pollRdHup(res);
}
}
break;