[Bug 65565] Tomcat responds with HTTP status code 503 with response body upstream connect error or disconnect/reset before headers. reset reason: remote refused stream reset
https://bz.apache.org/bugzilla/show_bug.cgi?id=65565 Chaitanya kanagala changed: What|Removed |Added CC||chaitu56...@gmail.com -- You are receiving this mail because: You are the assignee for the bug. - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch main updated: Fix potential (not observed) concurrency issues
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/main by this push: new 814492bce4 Fix potential (not observed) concurrency issues 814492bce4 is described below commit 814492bce4906bf0a3b40fb49d05c4862bf63b68 Author: Mark Thomas AuthorDate: Tue Jun 28 19:42:31 2022 +0100 Fix potential (not observed) concurrency issues I have been investigating some HTTP/2 test failures and noticed that these fields could be accessed by multiple threads. Make the fields volatile to ensure that the changes made by the previous thread are visible to the current thread. --- java/org/apache/coyote/http2/Http2AsyncParser.java | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/java/org/apache/coyote/http2/Http2AsyncParser.java b/java/org/apache/coyote/http2/Http2AsyncParser.java index 94cd096fb6..d01497051d 100644 --- a/java/org/apache/coyote/http2/Http2AsyncParser.java +++ b/java/org/apache/coyote/http2/Http2AsyncParser.java @@ -59,12 +59,12 @@ class Http2AsyncParser extends Http2Parser { private class PrefaceCompletionHandler extends FrameCompletionHandler { -private boolean prefaceValidated = false; - private final WebConnection webConnection; private final Stream stream; private final byte[] prefaceData; +private volatile boolean prefaceValidated = false; + private PrefaceCompletionHandler(WebConnection webConnection, Stream stream, byte[] prefaceData, ByteBuffer... buffers) { super(FrameType.SETTINGS, buffers); this.webConnection = webConnection; @@ -166,15 +166,15 @@ class Http2AsyncParser extends Http2Parser { private final FrameType expected; protected final ByteBuffer[] buffers; -private boolean parsedFrameHeader = false; -private boolean validated = false; -private CompletionState state = null; -protected int payloadSize; -protected int frameTypeId; -protected FrameType frameType; -protected int flags; -protected int streamId; -protected boolean streamException = false; +private volatile boolean parsedFrameHeader = false; +private volatile boolean validated = false; +private volatile CompletionState state = null; +protected volatile int payloadSize; +protected volatile int frameTypeId; +protected volatile FrameType frameType; +protected volatile int flags; +protected volatile int streamId; +protected volatile boolean streamException = false; private FrameCompletionHandler(FrameType expected, ByteBuffer... buffers) { this.expected = expected; - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 10.0.x updated: Fix potential (not observed) concurrency issues
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/10.0.x by this push: new 577d9f0a3d Fix potential (not observed) concurrency issues 577d9f0a3d is described below commit 577d9f0a3df177feefee68d5a774be4104f521ff Author: Mark Thomas AuthorDate: Tue Jun 28 19:42:31 2022 +0100 Fix potential (not observed) concurrency issues I have been investigating some HTTP/2 test failures and noticed that these fields could be accessed by multiple threads. Make the fields volatile to ensure that the changes made by the previous thread are visible to the current thread. --- java/org/apache/coyote/http2/Http2AsyncParser.java | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/java/org/apache/coyote/http2/Http2AsyncParser.java b/java/org/apache/coyote/http2/Http2AsyncParser.java index 94cd096fb6..d01497051d 100644 --- a/java/org/apache/coyote/http2/Http2AsyncParser.java +++ b/java/org/apache/coyote/http2/Http2AsyncParser.java @@ -59,12 +59,12 @@ class Http2AsyncParser extends Http2Parser { private class PrefaceCompletionHandler extends FrameCompletionHandler { -private boolean prefaceValidated = false; - private final WebConnection webConnection; private final Stream stream; private final byte[] prefaceData; +private volatile boolean prefaceValidated = false; + private PrefaceCompletionHandler(WebConnection webConnection, Stream stream, byte[] prefaceData, ByteBuffer... buffers) { super(FrameType.SETTINGS, buffers); this.webConnection = webConnection; @@ -166,15 +166,15 @@ class Http2AsyncParser extends Http2Parser { private final FrameType expected; protected final ByteBuffer[] buffers; -private boolean parsedFrameHeader = false; -private boolean validated = false; -private CompletionState state = null; -protected int payloadSize; -protected int frameTypeId; -protected FrameType frameType; -protected int flags; -protected int streamId; -protected boolean streamException = false; +private volatile boolean parsedFrameHeader = false; +private volatile boolean validated = false; +private volatile CompletionState state = null; +protected volatile int payloadSize; +protected volatile int frameTypeId; +protected volatile FrameType frameType; +protected volatile int flags; +protected volatile int streamId; +protected volatile boolean streamException = false; private FrameCompletionHandler(FrameType expected, ByteBuffer... buffers) { this.expected = expected; - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 9.0.x updated: Fix potential (not observed) concurrency issues
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/9.0.x by this push: new 9fe8413b4c Fix potential (not observed) concurrency issues 9fe8413b4c is described below commit 9fe8413b4cb1b27535708b0360709f7146ff1254 Author: Mark Thomas AuthorDate: Tue Jun 28 19:42:31 2022 +0100 Fix potential (not observed) concurrency issues I have been investigating some HTTP/2 test failures and noticed that these fields could be accessed by multiple threads. Make the fields volatile to ensure that the changes made by the previous thread are visible to the current thread. --- java/org/apache/coyote/http2/Http2AsyncParser.java | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/java/org/apache/coyote/http2/Http2AsyncParser.java b/java/org/apache/coyote/http2/Http2AsyncParser.java index 89cdc8268e..4e76b12c0c 100644 --- a/java/org/apache/coyote/http2/Http2AsyncParser.java +++ b/java/org/apache/coyote/http2/Http2AsyncParser.java @@ -59,12 +59,12 @@ class Http2AsyncParser extends Http2Parser { private class PrefaceCompletionHandler extends FrameCompletionHandler { -private boolean prefaceValidated = false; - private final WebConnection webConnection; private final Stream stream; private final byte[] prefaceData; +private volatile boolean prefaceValidated = false; + private PrefaceCompletionHandler(WebConnection webConnection, Stream stream, byte[] prefaceData, ByteBuffer... buffers) { super(FrameType.SETTINGS, buffers); this.webConnection = webConnection; @@ -166,15 +166,15 @@ class Http2AsyncParser extends Http2Parser { private final FrameType expected; protected final ByteBuffer[] buffers; -private boolean parsedFrameHeader = false; -private boolean validated = false; -private CompletionState state = null; -protected int payloadSize; -protected int frameTypeId; -protected FrameType frameType; -protected int flags; -protected int streamId; -protected boolean streamException = false; +private volatile boolean parsedFrameHeader = false; +private volatile boolean validated = false; +private volatile CompletionState state = null; +protected volatile int payloadSize; +protected volatile int frameTypeId; +protected volatile FrameType frameType; +protected volatile int flags; +protected volatile int streamId; +protected volatile boolean streamException = false; private FrameCompletionHandler(FrameType expected, ByteBuffer... buffers) { this.expected = expected; - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch main updated: Fix duplicate Poller registration with HTTP/2, NIO and async IO
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/main by this push: new 7977615c10 Fix duplicate Poller registration with HTTP/2, NIO and async IO 7977615c10 is described below commit 7977615c10b669c50bbca7fbdd890478029aa517 Author: Mark Thomas AuthorDate: Tue Jun 28 20:31:41 2022 +0100 Fix duplicate Poller registration with HTTP/2, NIO and async IO This could cause HTTP/2 connections to unexpectedly fail --- java/org/apache/coyote/AbstractProtocol.java | 5 - java/org/apache/coyote/http2/Http2UpgradeHandler.java | 13 ++--- java/org/apache/tomcat/util/net/AbstractEndpoint.java | 2 +- webapps/docs/changelog.xml| 4 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/java/org/apache/coyote/AbstractProtocol.java b/java/org/apache/coyote/AbstractProtocol.java index 8134955c2f..449d662f54 100644 --- a/java/org/apache/coyote/AbstractProtocol.java +++ b/java/org/apache/coyote/AbstractProtocol.java @@ -910,7 +910,7 @@ public abstract class AbstractProtocol implements ProtocolHandler, if (httpUpgradeHandler instanceof InternalHttpUpgradeHandler) { if (((InternalHttpUpgradeHandler) httpUpgradeHandler).hasAsyncIO()) { // The handler will initiate all further I/O -state = SocketState.UPGRADED; +state = SocketState.ASYNC_IO; } } } @@ -946,6 +946,9 @@ public abstract class AbstractProtocol implements ProtocolHandler, longPoll(wrapper, processor); getProtocol().addWaitingProcessor(processor); } +} else if (state == SocketState.ASYNC_IO) { +// Don't add sockets back to the poller. +// The handler will initiate all further I/O } else if (state == SocketState.SUSPENDED) { // Don't add sockets back to the poller. // The resumeProcessing() method will add this socket diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java index 426d0bfa9c..d0a9b21724 100644 --- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java +++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java @@ -393,14 +393,21 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH } if (connectionState.get() != ConnectionState.CLOSED) { -result = SocketState.UPGRADED; +if (socketWrapper.hasAsyncIO()) { +result = SocketState.ASYNC_IO; +} else { +result = SocketState.UPGRADED; +} } break; case OPEN_WRITE: processWrites(); - -result = SocketState.UPGRADED; +if (socketWrapper.hasAsyncIO()) { +result = SocketState.ASYNC_IO; +} else { +result = SocketState.UPGRADED; +} break; case TIMEOUT: diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java b/java/org/apache/tomcat/util/net/AbstractEndpoint.java index da280ce4a8..05fe1fa834 100644 --- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java +++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java @@ -77,7 +77,7 @@ public abstract class AbstractEndpoint { public enum SocketState { // TODO Add a new state to the AsyncStateMachine and remove // ASYNC_END (if possible) -OPEN, CLOSED, LONG, ASYNC_END, SENDFILE, UPGRADING, UPGRADED, SUSPENDED +OPEN, CLOSED, LONG, ASYNC_END, SENDFILE, UPGRADING, UPGRADED, ASYNC_IO, SUSPENDED } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index f33e004e4c..fa87fc1c1c 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -145,6 +145,10 @@ Correct a regression in the refactoring to support experimentation with project Loom that broke HTTP/2 support if async IO was disabled. (markt) + +Fix duplicate Poller registration with HTTP/2, NIO and async IO that +could cause HTTP/2 connections to unexpectedly fail. (markt) + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch main updated (7977615c10 -> 22bc541097)
This is an automated email from the ASF dual-hosted git repository. markt pushed a change to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git from 7977615c10 Fix duplicate Poller registration with HTTP/2, NIO and async IO new fdd20c32e5 Only need to check socket/network buffers for writes new 22bc541097 Fix logic for sending HTTP/2 pings The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: java/org/apache/coyote/http2/Http2UpgradeHandler.java | 3 +-- java/org/apache/tomcat/util/net/NioEndpoint.java | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 02/02: Fix logic for sending HTTP/2 pings
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git commit 22bc541097cb6700f4c2c5cf2376e25278ad02cf Author: Mark Thomas AuthorDate: Tue Jun 28 19:52:30 2022 +0100 Fix logic for sending HTTP/2 pings --- java/org/apache/coyote/http2/Http2UpgradeHandler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java index d0a9b21724..8e285e17ec 100644 --- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java +++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java @@ -329,7 +329,6 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH // Might not be necessary. init() will handle that. init(null); - SocketState result = SocketState.CLOSED; try { @@ -337,7 +336,7 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH case OPEN_READ: socketWrapper.getLock().lock(); try { -if (!socketWrapper.canWrite()) { +if (socketWrapper.canWrite()) { // Only send a ping if there is no other data waiting to be sent. // Ping manager will ensure they aren't sent too frequently. pingManager.sendPing(false); - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 01/02: Only need to check socket/network buffers for writes
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git commit fdd20c32e52613058c19d3d47f3cf74566a0a078 Author: Mark Thomas AuthorDate: Tue Jun 28 19:51:28 2022 +0100 Only need to check socket/network buffers for writes --- java/org/apache/tomcat/util/net/NioEndpoint.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index d4e9d4ec52..ae8d64e6cd 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -1638,7 +1638,7 @@ public class NioEndpoint extends AbstractJsseEndpoint } } if (nBytes != 0 || (!buffersArrayHasRemaining(buffers, offset, length) && -!socketOrNetworkBufferHasDataLeft())) { +(read || !socketOrNetworkBufferHasDataLeft( { completionDone = false; } } @@ -1647,7 +1647,7 @@ public class NioEndpoint extends AbstractJsseEndpoint } } if (nBytes > 0 || (nBytes == 0 && !buffersArrayHasRemaining(buffers, offset, length) && -!socketOrNetworkBufferHasDataLeft())) { +(read || !socketOrNetworkBufferHasDataLeft( { // The bytes processed are only updated in the completion handler completion.completed(Long.valueOf(nBytes), this); } else if (nBytes < 0 || getError() != null) { - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 10.0.x updated (577d9f0a3d -> 4bd90299ab)
This is an automated email from the ASF dual-hosted git repository. markt pushed a change to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git from 577d9f0a3d Fix potential (not observed) concurrency issues new 2426f4881a Fix duplicate Poller registration with HTTP/2, NIO and async IO new e3cb239c5d Only need to check socket/network buffers for writes new 4bd90299ab Fix logic for sending HTTP/2 pings The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: java/org/apache/coyote/AbstractProtocol.java | 5 - java/org/apache/coyote/http2/Http2UpgradeHandler.java | 16 +++- java/org/apache/tomcat/util/net/AbstractEndpoint.java | 2 +- java/org/apache/tomcat/util/net/NioEndpoint.java | 4 ++-- webapps/docs/changelog.xml| 4 5 files changed, 22 insertions(+), 9 deletions(-) - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 03/03: Fix logic for sending HTTP/2 pings
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git commit 4bd90299ab2a6aa4a73d1fb9904b942e3a3f9e5c Author: Mark Thomas AuthorDate: Tue Jun 28 19:52:30 2022 +0100 Fix logic for sending HTTP/2 pings --- java/org/apache/coyote/http2/Http2UpgradeHandler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java index fed4383972..de33bfded6 100644 --- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java +++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java @@ -327,14 +327,13 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH // Might not be necessary. init() will handle that. init(null); - SocketState result = SocketState.CLOSED; try { switch(status) { case OPEN_READ: synchronized (socketWrapper) { -if (!socketWrapper.canWrite()) { +if (socketWrapper.canWrite()) { // Only send a ping if there is no other data waiting to be sent. // Ping manager will ensure they aren't sent too frequently. pingManager.sendPing(false); - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 01/03: Fix duplicate Poller registration with HTTP/2, NIO and async IO
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git commit 2426f4881a7de32e50ceaf8ec97f8c232ae6e597 Author: Mark Thomas AuthorDate: Tue Jun 28 20:31:41 2022 +0100 Fix duplicate Poller registration with HTTP/2, NIO and async IO This could cause HTTP/2 connections to unexpectedly fail --- java/org/apache/coyote/AbstractProtocol.java | 5 - java/org/apache/coyote/http2/Http2UpgradeHandler.java | 13 ++--- java/org/apache/tomcat/util/net/AbstractEndpoint.java | 2 +- webapps/docs/changelog.xml| 4 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/java/org/apache/coyote/AbstractProtocol.java b/java/org/apache/coyote/AbstractProtocol.java index a3331c175a..09367766d6 100644 --- a/java/org/apache/coyote/AbstractProtocol.java +++ b/java/org/apache/coyote/AbstractProtocol.java @@ -919,7 +919,7 @@ public abstract class AbstractProtocol implements ProtocolHandler, if (httpUpgradeHandler instanceof InternalHttpUpgradeHandler) { if (((InternalHttpUpgradeHandler) httpUpgradeHandler).hasAsyncIO()) { // The handler will initiate all further I/O -state = SocketState.UPGRADED; +state = SocketState.ASYNC_IO; } } } @@ -955,6 +955,9 @@ public abstract class AbstractProtocol implements ProtocolHandler, longPoll(wrapper, processor); getProtocol().addWaitingProcessor(processor); } +} else if (state == SocketState.ASYNC_IO) { +// Don't add sockets back to the poller. +// The handler will initiate all further I/O } else if (state == SocketState.SUSPENDED) { // Don't add sockets back to the poller. // The resumeProcessing() method will add this socket diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java index 8b7ec85cc5..fed4383972 100644 --- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java +++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java @@ -388,14 +388,21 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH } if (connectionState.get() != ConnectionState.CLOSED) { -result = SocketState.UPGRADED; +if (socketWrapper.hasAsyncIO()) { +result = SocketState.ASYNC_IO; +} else { +result = SocketState.UPGRADED; +} } break; case OPEN_WRITE: processWrites(); - -result = SocketState.UPGRADED; +if (socketWrapper.hasAsyncIO()) { +result = SocketState.ASYNC_IO; +} else { +result = SocketState.UPGRADED; +} break; case TIMEOUT: diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java b/java/org/apache/tomcat/util/net/AbstractEndpoint.java index 572901a9fb..d058703953 100644 --- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java +++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java @@ -77,7 +77,7 @@ public abstract class AbstractEndpoint { public enum SocketState { // TODO Add a new state to the AsyncStateMachine and remove // ASYNC_END (if possible) -OPEN, CLOSED, LONG, ASYNC_END, SENDFILE, UPGRADING, UPGRADED, SUSPENDED +OPEN, CLOSED, LONG, ASYNC_END, SENDFILE, UPGRADING, UPGRADED, ASYNC_IO, SUSPENDED } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 03eca51763..3943cd54ff 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -132,6 +132,10 @@ default value for the jmvRoute attribute of an Engine. (markt) + +Fix duplicate Poller registration with HTTP/2, NIO and async IO that +could cause HTTP/2 connections to unexpectedly fail. (markt) + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 02/03: Only need to check socket/network buffers for writes
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git commit e3cb239c5d669475dbc94dc23e9c74467a88be04 Author: Mark Thomas AuthorDate: Tue Jun 28 19:51:28 2022 +0100 Only need to check socket/network buffers for writes --- java/org/apache/tomcat/util/net/NioEndpoint.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index 041f2d4be1..ddcdcd39ab 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -1661,7 +1661,7 @@ public class NioEndpoint extends AbstractJsseEndpoint } } if (nBytes != 0 || (!buffersArrayHasRemaining(buffers, offset, length) && -!socketOrNetworkBufferHasDataLeft())) { +(read || !socketOrNetworkBufferHasDataLeft( { completionDone = false; } } @@ -1670,7 +1670,7 @@ public class NioEndpoint extends AbstractJsseEndpoint } } if (nBytes > 0 || (nBytes == 0 && !buffersArrayHasRemaining(buffers, offset, length) && -!socketOrNetworkBufferHasDataLeft())) { +(read || !socketOrNetworkBufferHasDataLeft( { // The bytes processed are only updated in the completion handler completion.completed(Long.valueOf(nBytes), this); } else if (nBytes < 0 || getError() != null) { - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 9.0.x updated (9fe8413b4c -> fe2a9c4d57)
This is an automated email from the ASF dual-hosted git repository. markt pushed a change to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git from 9fe8413b4c Fix potential (not observed) concurrency issues new 001cd8c10c Fix duplicate Poller registration with HTTP/2, NIO and async IO new 4d97a4928b Only need to check socket/network buffers for writes new fe2a9c4d57 Fix logic for sending HTTP/2 pings The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: java/org/apache/coyote/AbstractProtocol.java | 5 - java/org/apache/coyote/http2/Http2UpgradeHandler.java | 16 +++- java/org/apache/tomcat/util/net/AbstractEndpoint.java | 2 +- java/org/apache/tomcat/util/net/NioEndpoint.java | 4 ++-- webapps/docs/changelog.xml| 4 5 files changed, 22 insertions(+), 9 deletions(-) - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 01/03: Fix duplicate Poller registration with HTTP/2, NIO and async IO
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git commit 001cd8c10c43cdf93b03b0ab7a6974ad3137a2e7 Author: Mark Thomas AuthorDate: Tue Jun 28 20:31:41 2022 +0100 Fix duplicate Poller registration with HTTP/2, NIO and async IO This could cause HTTP/2 connections to unexpectedly fail --- java/org/apache/coyote/AbstractProtocol.java | 5 - java/org/apache/coyote/http2/Http2UpgradeHandler.java | 13 ++--- java/org/apache/tomcat/util/net/AbstractEndpoint.java | 2 +- webapps/docs/changelog.xml| 4 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/java/org/apache/coyote/AbstractProtocol.java b/java/org/apache/coyote/AbstractProtocol.java index 562daec0f8..f969779d9d 100644 --- a/java/org/apache/coyote/AbstractProtocol.java +++ b/java/org/apache/coyote/AbstractProtocol.java @@ -942,7 +942,7 @@ public abstract class AbstractProtocol implements ProtocolHandler, if (httpUpgradeHandler instanceof InternalHttpUpgradeHandler) { if (((InternalHttpUpgradeHandler) httpUpgradeHandler).hasAsyncIO()) { // The handler will initiate all further I/O -state = SocketState.UPGRADED; +state = SocketState.ASYNC_IO; } } } @@ -978,6 +978,9 @@ public abstract class AbstractProtocol implements ProtocolHandler, longPoll(wrapper, processor); getProtocol().addWaitingProcessor(processor); } +} else if (state == SocketState.ASYNC_IO) { +// Don't add sockets back to the poller. +// The handler will initiate all further I/O } else if (state == SocketState.SUSPENDED) { // Don't add sockets back to the poller. // The resumeProcessing() method will add this socket diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java index 56928c20cc..d0a3ee5519 100644 --- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java +++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java @@ -388,14 +388,21 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH } if (connectionState.get() != ConnectionState.CLOSED) { -result = SocketState.UPGRADED; +if (socketWrapper.hasAsyncIO()) { +result = SocketState.ASYNC_IO; +} else { +result = SocketState.UPGRADED; +} } break; case OPEN_WRITE: processWrites(); - -result = SocketState.UPGRADED; +if (socketWrapper.hasAsyncIO()) { +result = SocketState.ASYNC_IO; +} else { +result = SocketState.UPGRADED; +} break; case TIMEOUT: diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java b/java/org/apache/tomcat/util/net/AbstractEndpoint.java index 6ff8ada975..6624ddae88 100644 --- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java +++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java @@ -77,7 +77,7 @@ public abstract class AbstractEndpoint { public enum SocketState { // TODO Add a new state to the AsyncStateMachine and remove // ASYNC_END (if possible) -OPEN, CLOSED, LONG, ASYNC_END, SENDFILE, UPGRADING, UPGRADED, SUSPENDED +OPEN, CLOSED, LONG, ASYNC_END, SENDFILE, UPGRADING, UPGRADED, ASYNC_IO, SUSPENDED } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index cb89936cc8..472e2d97bf 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -132,6 +132,10 @@ default value for the jmvRoute attribute of an Engine. (markt) + +Fix duplicate Poller registration with HTTP/2, NIO and async IO that +could cause HTTP/2 connections to unexpectedly fail. (markt) + - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 02/03: Only need to check socket/network buffers for writes
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git commit 4d97a4928b4a55c4bf1bd4a668f64b5a2810e6fd Author: Mark Thomas AuthorDate: Tue Jun 28 19:51:28 2022 +0100 Only need to check socket/network buffers for writes --- java/org/apache/tomcat/util/net/NioEndpoint.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index bd637311a9..d7425916c4 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -1688,7 +1688,7 @@ public class NioEndpoint extends AbstractJsseEndpoint } } if (nBytes != 0 || (!buffersArrayHasRemaining(buffers, offset, length) && -!socketOrNetworkBufferHasDataLeft())) { +(read || !socketOrNetworkBufferHasDataLeft( { completionDone = false; } } @@ -1697,7 +1697,7 @@ public class NioEndpoint extends AbstractJsseEndpoint } } if (nBytes > 0 || (nBytes == 0 && !buffersArrayHasRemaining(buffers, offset, length) && -!socketOrNetworkBufferHasDataLeft())) { +(read || !socketOrNetworkBufferHasDataLeft( { // The bytes processed are only updated in the completion handler completion.completed(Long.valueOf(nBytes), this); } else if (nBytes < 0 || getError() != null) { - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] 03/03: Fix logic for sending HTTP/2 pings
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git commit fe2a9c4d57eea17c371da13703a51c8bca88bfdd Author: Mark Thomas AuthorDate: Tue Jun 28 19:52:30 2022 +0100 Fix logic for sending HTTP/2 pings --- java/org/apache/coyote/http2/Http2UpgradeHandler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java index d0a3ee5519..f8d8235dea 100644 --- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java +++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java @@ -327,14 +327,13 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH // Might not be necessary. init() will handle that. init(null); - SocketState result = SocketState.CLOSED; try { switch(status) { case OPEN_READ: synchronized (socketWrapper) { -if (!socketWrapper.canWrite()) { +if (socketWrapper.canWrite()) { // Only send a ping if there is no other data waiting to be sent. // Ping manager will ensure they aren't sent too frequently. pingManager.sendPing(false); - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
[tomcat] branch 8.5.x updated: Fix logic for sending HTTP/2 pings
This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git The following commit(s) were added to refs/heads/8.5.x by this push: new f5f2fa4a78 Fix logic for sending HTTP/2 pings f5f2fa4a78 is described below commit f5f2fa4a78dc39003e24a57c6f888649cc105abf Author: Mark Thomas AuthorDate: Tue Jun 28 19:52:30 2022 +0100 Fix logic for sending HTTP/2 pings --- java/org/apache/coyote/http2/Http2UpgradeHandler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java index e93e29dc49..4d43f7c3ef 100644 --- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java +++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java @@ -321,14 +321,13 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH // Might not be necessary. init() will handle that. init(null); - SocketState result = SocketState.CLOSED; try { switch(status) { case OPEN_READ: synchronized (socketWrapper) { -if (!socketWrapper.canWrite()) { +if (socketWrapper.canWrite()) { // Only send a ping if there is no other data waiting to be sent. // Ping manager will ensure they aren't sent too frequently. pingManager.sendPing(false); - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
svn commit: r1902327 - in /tomcat/site/trunk: docs/index.html xdocs/index.xml
Author: markt Date: Tue Jun 28 19:46:21 2022 New Revision: 1902327 URL: http://svn.apache.org/viewvc?rev=1902327&view=rev Log: Fix copy/paste error Modified: tomcat/site/trunk/docs/index.html tomcat/site/trunk/xdocs/index.xml Modified: tomcat/site/trunk/docs/index.html URL: http://svn.apache.org/viewvc/tomcat/site/trunk/docs/index.html?rev=1902327&r1=1902326&r2=1902327&view=diff == --- tomcat/site/trunk/docs/index.html (original) +++ tomcat/site/trunk/docs/index.html Tue Jun 28 19:46:21 2022 @@ -37,7 +37,7 @@ project logo are trademarks of the Apach 2022-06-14 Tomcat Native 1.2.34 Released The Apache Tomcat Project is proud to announce the release of version 1.2.34 of -Tomcat Native. The notable changes since 1.2.32 include: +Tomcat Native. The notable changes since 1.2.33 include: Refactor the initialization of the native code so it is compatible Modified: tomcat/site/trunk/xdocs/index.xml URL: http://svn.apache.org/viewvc/tomcat/site/trunk/xdocs/index.xml?rev=1902327&r1=1902326&r2=1902327&view=diff == --- tomcat/site/trunk/xdocs/index.xml (original) +++ tomcat/site/trunk/xdocs/index.xml Tue Jun 28 19:46:21 2022 @@ -58,7 +58,7 @@ project logo are trademarks of the Apach The Apache Tomcat Project is proud to announce the release of version 1.2.34 of -Tomcat Native. The notable changes since 1.2.32 include: +Tomcat Native. The notable changes since 1.2.33 include: Refactor the initialization of the native code so it is compatible - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org