Author: markt
Date: Tue Jun 10 09:37:39 2014
New Revision: 1601583
URL: http://svn.apache.org/r1601583
Log:
Pull up waitingRequests.
NIO2 used a ConcurrentHashMap whereas BIO and APR/native used a Queue. Switch
to ConcurrentHashMap for all since what we really want here is a Set (and there
isn't a ConcurrentHashSet implementation).
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java
tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java?rev=1601583&r1=1601582&r2=1601583&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java Tue Jun
10 09:37:39 2014
@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.StringTokenizer;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
@@ -974,5 +975,7 @@ public abstract class AbstractEndpoint<S
}
}
+ protected ConcurrentHashMap<SocketWrapper<S>, SocketWrapper<S>>
waitingRequests =
+ new ConcurrentHashMap<>();
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1601583&r1=1601582&r2=1601583&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Tue Jun 10
09:37:39 2014
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.tomcat.util.net;
import java.util.ArrayList;
@@ -22,7 +21,6 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
@@ -95,9 +93,6 @@ public class AprEndpoint extends Abstrac
protected long sslContext = 0;
- protected ConcurrentLinkedQueue<SocketWrapper<Long>> waitingRequests =
- new ConcurrentLinkedQueue<>();
-
private final Map<Long,AprSocketWrapper> connections = new
ConcurrentHashMap<>();
// ------------------------------------------------------------ Constructor
@@ -886,7 +881,7 @@ public class AprEndpoint extends Abstrac
// result of calling AsyncContext.dispatch() from a non-container
// thread
synchronized (socket) {
- if (waitingRequests.remove(socket)) {
+ if (waitingRequests.remove(socket) != null) {
SocketProcessor proc = new SocketProcessor(socket, status);
Executor executor = getExecutor();
if (dispatch && executor != null) {
@@ -1075,8 +1070,7 @@ public class AprEndpoint extends Abstrac
// Ignore
}
long now = System.currentTimeMillis();
- Iterator<SocketWrapper<Long>> sockets =
- waitingRequests.iterator();
+ Iterator<SocketWrapper<Long>> sockets =
waitingRequests.keySet().iterator();
while (sockets.hasNext()) {
SocketWrapper<Long> socket = sockets.next();
if (socket.isAsync()) {
@@ -2394,7 +2388,7 @@ public class AprEndpoint extends Abstrac
} else if (state == Handler.SocketState.LONG) {
socket.access();
if (socket.isAsync()) {
- waitingRequests.add(socket);
+ waitingRequests.put(socket, socket);
}
}
}
@@ -2456,7 +2450,7 @@ public class AprEndpoint extends Abstrac
} else if (state == Handler.SocketState.LONG) {
socket.access();
if (socket.isAsync()) {
- waitingRequests.add(socket);
+ waitingRequests.put(socket, socket);
}
} else if (state == Handler.SocketState.ASYNC_END) {
socket.access();
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java?rev=1601583&r1=1601582&r2=1601583&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java Tue Jun 10
09:37:39 2014
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.tomcat.util.net;
import java.io.IOException;
@@ -23,7 +22,6 @@ import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.util.Iterator;
-import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
@@ -164,8 +162,7 @@ public class JIoEndpoint extends Abstrac
// Ignore
}
long now = System.currentTimeMillis();
- Iterator<SocketWrapper<Socket>> sockets =
- waitingRequests.iterator();
+ Iterator<SocketWrapper<Socket>> sockets =
waitingRequests.keySet().iterator();
while (sockets.hasNext()) {
SocketWrapper<Socket> socket = sockets.next();
if (socket.isAsync()) {
@@ -347,7 +344,7 @@ public class JIoEndpoint extends Abstrac
launch = true;
} else if (state == SocketState.LONG) {
socket.access();
- waitingRequests.add(socket);
+ waitingRequests.put(socket, socket);
}
} finally {
if (launch) {
@@ -562,7 +559,7 @@ public class JIoEndpoint extends Abstrac
// result of calling AsyncContext.dispatch() from a non-container
// thread
synchronized (socket) {
- if (waitingRequests.remove(socket)) {
+ if (waitingRequests.remove(socket) != null) {
SocketProcessor proc = new SocketProcessor(socket,status);
Executor executor = getExecutor();
if (dispatch && executor != null) {
@@ -586,9 +583,6 @@ public class JIoEndpoint extends Abstrac
}
}
- protected ConcurrentLinkedQueue<SocketWrapper<Socket>> waitingRequests =
- new ConcurrentLinkedQueue<>();
-
@Override
protected Log getLog() {
return log;
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=1601583&r1=1601582&r2=1601583&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Tue Jun 10
09:37:39 2014
@@ -31,7 +31,6 @@ import java.nio.channels.CompletionHandl
import java.nio.channels.FileChannel;
import java.nio.file.StandardOpenOption;
import java.util.Iterator;
-import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
@@ -874,9 +873,6 @@ public class Nio2Endpoint extends Abstra
public void onCreateSSLEngine(SSLEngine engine);
}
- protected ConcurrentHashMap<SocketWrapper<Nio2Channel>,
SocketWrapper<Nio2Channel>> waitingRequests =
- new ConcurrentHashMap<>();
-
/**
* The completion handler used for asynchronous read operations
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]