You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2017/10/18 17:01:08 UTC
svn commit: r1812551 - in /tomcat/trunk:
java/org/apache/tomcat/util/net/Nio2Endpoint.java webapps/docs/changelog.xml
Author: remm
Date: Wed Oct 18 17:01:08 2017
New Revision: 1812551
URL: http://svn.apache.org/viewvc?rev=1812551&view=rev
Log:
Cleanup the async IO syncs a bit.
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java?rev=1812551&r1=1812550&r2=1812551&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Wed Oct 18 17:01:08 2017
@@ -894,14 +894,14 @@ public class Nio2Endpoint extends Abstra
}
}
if (complete) {
- readPending.release();
- if (state.block == BlockingMode.BLOCK && currentState != CompletionState.INLINE) {
- synchronized (this) {
+ synchronized (state) {
+ readPending.release();
+ if (state.block == BlockingMode.BLOCK && currentState != CompletionState.INLINE) {
+ state.state = currentState;
+ state.notify();
+ } else {
state.state = currentState;
- notify();
}
- } else {
- state.state = currentState;
}
if (completion && state.handler != null) {
state.handler.completed(Long.valueOf(state.nBytes), state.attachment);
@@ -921,14 +921,14 @@ public class Nio2Endpoint extends Abstra
ioe = new IOException(exc);
}
setError(ioe);
- readPending.release();
- if (state.block == BlockingMode.BLOCK) {
- synchronized (this) {
+ synchronized (this) {
+ readPending.release();
+ if (state.block == BlockingMode.BLOCK) {
+ state.state = Nio2Endpoint.isInline() ? CompletionState.ERROR : CompletionState.DONE;
+ state.notify();
+ } else {
state.state = Nio2Endpoint.isInline() ? CompletionState.ERROR : CompletionState.DONE;
- notify();
}
- } else {
- state.state = Nio2Endpoint.isInline() ? CompletionState.ERROR : CompletionState.DONE;
}
if (exc instanceof AsynchronousCloseException) {
// If already closed, don't call onError and close again
@@ -963,14 +963,14 @@ public class Nio2Endpoint extends Abstra
}
}
if (complete) {
- writePending.release();
- if (state.block == BlockingMode.BLOCK && currentState != CompletionState.INLINE) {
- synchronized (this) {
+ synchronized (state) {
+ writePending.release();
+ if (state.block == BlockingMode.BLOCK && currentState != CompletionState.INLINE) {
+ state.state = currentState;
+ state.notify();
+ } else {
state.state = currentState;
- notify();
}
- } else {
- state.state = currentState;
}
if (completion && state.handler != null) {
state.handler.completed(Long.valueOf(state.nBytes), state.attachment);
@@ -990,14 +990,14 @@ public class Nio2Endpoint extends Abstra
ioe = new IOException(exc);
}
setError(ioe);
- writePending.release();
- if (state.block == BlockingMode.BLOCK) {
- synchronized (this) {
+ synchronized (state) {
+ writePending.release();
+ if (state.block == BlockingMode.BLOCK) {
+ state.state = Nio2Endpoint.isInline() ? CompletionState.ERROR : CompletionState.DONE;
+ state.notify();
+ } else {
state.state = Nio2Endpoint.isInline() ? CompletionState.ERROR : CompletionState.DONE;
- notify();
}
- } else {
- state.state = Nio2Endpoint.isInline() ? CompletionState.ERROR : CompletionState.DONE;
}
if (state.handler != null) {
state.handler.failed(ioe, state.attachment);
@@ -1009,6 +1009,11 @@ public class Nio2Endpoint extends Abstra
public <A> CompletionState read(ByteBuffer[] dsts, int offset, int length,
BlockingMode block, long timeout, TimeUnit unit, A attachment,
CompletionCheck check, CompletionHandler<Long, ? super A> handler) {
+ IOException ioe = getError();
+ if (ioe != null) {
+ handler.failed(ioe, attachment);
+ return CompletionState.ERROR;
+ }
if (block != BlockingMode.NON_BLOCK) {
try {
if (!readPending.tryAcquire(timeout, unit)) {
@@ -1030,10 +1035,10 @@ public class Nio2Endpoint extends Abstra
getSocket().read(dsts, offset, length, timeout, unit, state, completion);
Nio2Endpoint.endInline();
if (block == BlockingMode.BLOCK) {
- synchronized (completion) {
+ synchronized (state) {
if (state.state == CompletionState.PENDING) {
try {
- completion.wait(unit.toMillis(timeout));
+ state.wait(unit.toMillis(timeout));
if (state.state == CompletionState.PENDING) {
handler.failed(new SocketTimeoutException(), attachment);
return CompletionState.ERROR;
@@ -1085,10 +1090,10 @@ public class Nio2Endpoint extends Abstra
getSocket().write(srcs, offset, length, timeout, unit, state, completion);
Nio2Endpoint.endInline();
if (block == BlockingMode.BLOCK) {
- synchronized (completion) {
+ synchronized (state) {
if (state.state == CompletionState.PENDING) {
try {
- completion.wait(unit.toMillis(timeout));
+ state.wait(unit.toMillis(timeout));
if (state.state == CompletionState.PENDING) {
handler.failed(new SocketTimeoutException(), attachment);
return CompletionState.ERROR;
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1812551&r1=1812550&r2=1812551&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed Oct 18 17:01:08 2017
@@ -74,6 +74,9 @@
have the same password. This fixes PKCS11 key store handling with
multiple keys selected with an alias. (markt)
</fix>
+ <fix>
+ Improve NIO2 syncing for async IO operations. (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1812551 - in /tomcat/trunk:
java/org/apache/tomcat/util/net/Nio2Endpoint.java webapps/docs/changelog.xml
Posted by Mark Thomas <ma...@apache.org>.
On 23/10/17 14:48, Rémy Maucherat wrote:
> On Wed, Oct 18, 2017 at 7:01 PM, <re...@apache.org> wrote:
>
>> Author: remm
>> Date: Wed Oct 18 17:01:08 2017
>> New Revision: 1812551
>>
>> URL: http://svn.apache.org/viewvc?rev=1812551&view=rev
>> Log:
>> Cleanup the async IO syncs a bit.
>>
>> Modified:
>> tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
>> tomcat/trunk/webapps/docs/changelog.xml
>>
>
> Following that, I am still satisfied with the HTTP/2 performance, with the
> exception of the default value for DEFAULT_MAX_CONCURRENT_STREAM_EXECUTION
> being unreasonably high (IMO). Ultimately, things are rather comparable to
> the 2 connections per client recommendation in HTTP/1.1. Here, the default
> is 200. 20 would already be quite high actually.
> Can I change it ?
No objection here.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1812551 - in /tomcat/trunk: java/org/apache/tomcat/util/net/Nio2Endpoint.java
webapps/docs/changelog.xml
Posted by Rémy Maucherat <re...@apache.org>.
On Wed, Oct 18, 2017 at 7:01 PM, <re...@apache.org> wrote:
> Author: remm
> Date: Wed Oct 18 17:01:08 2017
> New Revision: 1812551
>
> URL: http://svn.apache.org/viewvc?rev=1812551&view=rev
> Log:
> Cleanup the async IO syncs a bit.
>
> Modified:
> tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
> tomcat/trunk/webapps/docs/changelog.xml
>
Following that, I am still satisfied with the HTTP/2 performance, with the
exception of the default value for DEFAULT_MAX_CONCURRENT_STREAM_EXECUTION
being unreasonably high (IMO). Ultimately, things are rather comparable to
the 2 connections per client recommendation in HTTP/1.1. Here, the default
is 200. 20 would already be quite high actually.
Can I change it ?
Rémy