Hi all,

we are using tomcat-embed (Tomcat 8.5.70) in our product which also contains a 
custom NIO implementation.
So i think i cannot give you a configuration to reproduce the issue.

Anyway, i will explain in short what happens.
It is within the included BlockPoller class in the NioBlockingSelector.
Within the run method: (in 8.5.70 it is in line 376)

sk.interestOps(sk.interestOps() & (~sk.readyOps()));
if ( sk.isReadable() ) {
    countDown(attachment.getReadLatch());
}
if (sk.isWritable()) {
    countDown(attachment.getWriteLatch());
}

It may happen that after the interestOps are reset, another thread will set the 
writeable flag to false (within our custom NIO)
In that case the writeLatch will not be count down and the write operation is 
blocked until timeout.

>From my point of view is will be better this way:

- sk.interestOps(sk.interestOps() & (~sk.readyOps()));
if ( sk.isReadable() ) {
+    sk.interestOps(sk.interestOps() & (~SelectionKey.OP_READ));
    countDown(attachment.getReadLatch());
}
if (sk.isWritable()) {
+    sk.interestOps(sk.interestOps() & (~SelectionKey.OP_WRITE));
    countDown(attachment.getWriteLatch());
}

This should fix it for tomcat 8.5.x.
If i understand the SelectionKey java doc right, the writable flag may be 
updated by the selector during a selection operation.

What do you think about?

Kind regards,
Mathias



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to