Merge pull request #2 from normanmaurer/io_uring_break

Add missing break statement and cleanup
This commit is contained in:
Josef Grieb 2020-08-27 10:57:52 +02:00 committed by GitHub
commit 3cdb1d60ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 13 deletions

View File

@ -52,7 +52,7 @@ abstract class AbstractIOUringServerChannel extends AbstractIOUringChannel imple
abstract Channel newChildChannel(int fd) throws Exception; abstract Channel newChildChannel(int fd) throws Exception;
void acceptComplete(int res) { boolean acceptComplete(int res) {
if (res >= 0) { if (res >= 0) {
final IOUringRecvByteAllocatorHandle allocHandle = final IOUringRecvByteAllocatorHandle allocHandle =
(IOUringRecvByteAllocatorHandle) unsafe() (IOUringRecvByteAllocatorHandle) unsafe()
@ -71,6 +71,7 @@ abstract class AbstractIOUringServerChannel extends AbstractIOUringChannel imple
} }
//Todo refactoring method name //Todo refactoring method name
executeReadEvent(); executeReadEvent();
return res >= 0;
} }
final class UringServerChannelUnsafe extends AbstractIOUringChannel.AbstractUringUnsafe { final class UringServerChannelUnsafe extends AbstractIOUringChannel.AbstractUringUnsafe {

View File

@ -44,8 +44,6 @@ final class IOUringEventLoop extends SingleThreadEventLoop implements
private static final long ETIME = -62; private static final long ETIME = -62;
static final long ECANCELED = -125; static final long ECANCELED = -125;
// events should be unique to identify which event type that was
private long eventIdCounter;
private final IntObjectMap<AbstractIOUringChannel> channels = new IntObjectHashMap<AbstractIOUringChannel>(4096); private final IntObjectMap<AbstractIOUringChannel> channels = new IntObjectHashMap<AbstractIOUringChannel>(4096);
private final RingBuffer ringBuffer; private final RingBuffer ringBuffer;
@ -191,8 +189,11 @@ final class IOUringEventLoop extends SingleThreadEventLoop implements
if (res != -1 && res != ERRNO_EAGAIN_NEGATIVE && if (res != -1 && res != ERRNO_EAGAIN_NEGATIVE &&
res != ERRNO_EWOULDBLOCK_NEGATIVE) { res != ERRNO_EWOULDBLOCK_NEGATIVE) {
logger.trace("server filedescriptor Fd: {}", fd); logger.trace("server filedescriptor Fd: {}", fd);
acceptChannel.acceptComplete(res); if (acceptChannel.acceptComplete(res)) {
pollRdHup(res); // all childChannels should poll POLLRDHUP
submissionQueue.addPollRdHup(res);
submissionQueue.submit();
}
} }
break; break;
case IOUring.OP_READ: case IOUring.OP_READ:
@ -247,9 +248,9 @@ final class IOUringEventLoop extends SingleThreadEventLoop implements
} else { } else {
//Todo error handling error //Todo error handling error
logger.trace("POLL_LINK Res: {}", res); logger.trace("POLL_LINK Res: {}", res);
break;
} }
} }
break;
case IOUring.OP_POLL_REMOVE: case IOUring.OP_POLL_REMOVE:
if (res == ENOENT) { if (res == ENOENT) {
logger.trace("POLL_REMOVE OPERATION not permitted"); logger.trace("POLL_REMOVE OPERATION not permitted");
@ -282,11 +283,4 @@ final class IOUringEventLoop extends SingleThreadEventLoop implements
Native.eventFdWrite(eventfd.intValue(), 1L); Native.eventFdWrite(eventfd.intValue(), 1L);
} }
} }
//to be notified when the filedesciptor is closed
private void pollRdHup(int fd) {
//all childChannels should poll POLLRDHUP
ringBuffer.getIoUringSubmissionQueue().addPollRdHup(fd);
ringBuffer.getIoUringSubmissionQueue().submit();
}
} }