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 { try {
in.forEachFlushedMessage(iovecArray); in.forEachFlushedMessage(iovecArray);
} catch (Exception e) { } catch (Exception e) {
// This should never happem, anyway fallback to single write.
doWriteSingle((ByteBuf) in.current());
} }
if (iovecArray.count() > 0) { if (iovecArray.count() > 0) {
@ -298,8 +299,10 @@ abstract class AbstractIOUringChannel extends AbstractChannel implements UnixCha
submissionQueue().submit(); submissionQueue().submit();
writeScheduled = true; 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); ((AbstractIOUringChannel.AbstractUringUnsafe) readChannel.unsafe()).readComplete(res);
break; break;
case IOUring.OP_WRITEV: case IOUring.OP_WRITEV:
// Fall-through
case IOUring.OP_WRITE: case IOUring.OP_WRITE:
AbstractIOUringChannel writeChannel = channels.get(fd); AbstractIOUringChannel writeChannel = channels.get(fd);
if (writeChannel == null) { if (writeChannel == null) {
@ -219,18 +221,14 @@ final class IOUringEventLoop extends SingleThreadEventLoop implements
if (channel == null) { if (channel == null) {
break; break;
} }
switch (pollMask) { if ((pollMask & IOUring.POLLMASK_OUT) != 0) {
case IOUring.POLLMASK_IN: ((AbstractIOUringChannel.AbstractUringUnsafe) channel.unsafe()).pollOut(res);
((AbstractIOUringChannel.AbstractUringUnsafe) channel.unsafe()).pollIn(res); }
break; if ((pollMask & IOUring.POLLMASK_IN) != 0) {
case IOUring.POLLMASK_OUT: ((AbstractIOUringChannel.AbstractUringUnsafe) channel.unsafe()).pollIn(res);
((AbstractIOUringChannel.AbstractUringUnsafe) channel.unsafe()).pollOut(res); }
break; if ((pollMask & IOUring.POLLMASK_RDHUP) != 0) {
case IOUring.POLLMASK_RDHUP: ((AbstractIOUringChannel.AbstractUringUnsafe) channel.unsafe()).pollRdHup(res);
((AbstractIOUringChannel.AbstractUringUnsafe) channel.unsafe()).pollRdHup(res);
break;
default:
break;
} }
} }
break; break;