This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push: new 0bd48ff Implement poller timeout with async 0bd48ff is described below commit 0bd48ff7c773cd6ef587df0f904111a741019530 Author: remm <r...@apache.org> AuthorDate: Tue Apr 16 09:45:56 2019 +0200 Implement poller timeout with async Updating the last operation time must be explicit when there is an IO operation. --- java/org/apache/tomcat/util/net/NioEndpoint.java | 15 +++++++++++---- webapps/docs/changelog.xml | 3 +++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index b869876..56b49e3 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -970,7 +970,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel> keycount++; try { NioSocketWrapper socketWrapper = (NioSocketWrapper) key.attachment(); - if ( socketWrapper == null ) { + if (socketWrapper == null) { // We don't support any keys without attachments cancelledKey(key); } else if (close) { @@ -989,6 +989,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel> long timeout = socketWrapper.getReadTimeout(); isTimedOut = timeout > 0 && delta > timeout; readTimeout = true; + System.out.println("Timeout: " + timeout + " Delta: " + delta + " isTimedOut: " + isTimedOut); } // Check for write timeout if (!isTimedOut && (socketWrapper.interestOps() & SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE) { @@ -1003,15 +1004,19 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel> socketWrapper.interestOps(0); socketWrapper.setError(new SocketTimeoutException()); if (readTimeout && socketWrapper.readOperation != null) { - getExecutor().execute(socketWrapper.readOperation); + if (!socketWrapper.readOperation.process()) { + cancelledKey(key); + } } else if (writeTimeout && socketWrapper.writeOperation != null) { - getExecutor().execute(socketWrapper.writeOperation); + if (!socketWrapper.writeOperation.process()) { + cancelledKey(key); + } } else if (!processSocket(socketWrapper, SocketEvent.ERROR, true)) { cancelledKey(key); } } } - }catch ( CancelledKeyException ckx ) { + } catch (CancelledKeyException ckx) { cancelledKey(key); } } @@ -1491,8 +1496,10 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel> try { if (read) { nBytes = getSocket().read(buffers, offset, length); + updateLastRead(); } else { nBytes = getSocket().write(buffers, offset, length); + updateLastWrite(); } } catch (IOException e) { setError(e); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 4def071..a71fb58 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -65,6 +65,9 @@ Fix socket close discrepancies for NIO, now the wrapper close is used everywhere except for socket accept problems. (remm) </fix> + <fix> + Implement poller timeout when using async IO with NIO. (remm) + </fix> </changelog> </subsection> </section> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org