You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/11/10 17:45:06 UTC
svn commit: r1637917 [2/2] - in /tomcat/trunk: java/org/apache/coyote/
java/org/apache/coyote/ajp/ java/org/apache/coyote/http11/
java/org/apache/coyote/http11/upgrade/ java/org/apache/coyote/spdy/
java/org/apache/tomcat/util/net/ test/org/apache/coyot...
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=1637917&r1=1637916&r2=1637917&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Mon Nov 10 16:45:04 2014
@@ -378,7 +378,7 @@ public class Nio2Endpoint extends Abstra
@Override
public void run() {
// Timeout any pending async request
- for (SocketWrapper<Nio2Channel> socket : waitingRequests) {
+ for (SocketWrapperBase<Nio2Channel> socket : waitingRequests) {
processSocket(socket, SocketStatus.TIMEOUT, false);
}
// Then close all active connections if any remains
@@ -566,12 +566,12 @@ public class Nio2Endpoint extends Abstra
@Override
- public void processSocket(SocketWrapper<Nio2Channel> socketWrapper,
+ public void processSocket(SocketWrapperBase<Nio2Channel> socketWrapper,
SocketStatus socketStatus, boolean dispatch) {
processSocket0(socketWrapper, socketStatus, dispatch);
}
- protected boolean processSocket0(SocketWrapper<Nio2Channel> socketWrapper, SocketStatus status, boolean dispatch) {
+ protected boolean processSocket0(SocketWrapperBase<Nio2Channel> socketWrapper, SocketStatus status, boolean dispatch) {
try {
SocketProcessor sc = (useCaches) ? processorCache.pop() : null;
if (sc == null) {
@@ -598,7 +598,7 @@ public class Nio2Endpoint extends Abstra
return true;
}
- public void closeSocket(SocketWrapper<Nio2Channel> socket) {
+ public void closeSocket(SocketWrapperBase<Nio2Channel> socket) {
if (socket == null) {
return;
}
@@ -727,7 +727,7 @@ public class Nio2Endpoint extends Abstra
}
- public static class Nio2SocketWrapper extends SocketWrapper<Nio2Channel> {
+ public static class Nio2SocketWrapper extends SocketWrapperBase<Nio2Channel> {
private SendfileData sendfileData = null;
private boolean upgradeInit = false;
@@ -799,9 +799,9 @@ public class Nio2Endpoint extends Abstra
* thread local fields.
*/
public interface Handler extends AbstractEndpoint.Handler {
- public SocketState process(SocketWrapper<Nio2Channel> socket,
+ public SocketState process(SocketWrapperBase<Nio2Channel> socket,
SocketStatus status);
- public void release(SocketWrapper<Nio2Channel> socket);
+ public void release(SocketWrapperBase<Nio2Channel> socket);
public void closeAll();
public SSLImplementation getSslImplementation();
public void onCreateSSLEngine(SSLEngine engine);
@@ -810,11 +810,11 @@ public class Nio2Endpoint extends Abstra
/**
* The completion handler used for asynchronous read operations
*/
- private CompletionHandler<Integer, SocketWrapper<Nio2Channel>> awaitBytes
- = new CompletionHandler<Integer, SocketWrapper<Nio2Channel>>() {
+ private CompletionHandler<Integer, SocketWrapperBase<Nio2Channel>> awaitBytes
+ = new CompletionHandler<Integer, SocketWrapperBase<Nio2Channel>>() {
@Override
- public synchronized void completed(Integer nBytes, SocketWrapper<Nio2Channel> attachment) {
+ public synchronized void completed(Integer nBytes, SocketWrapperBase<Nio2Channel> attachment) {
if (nBytes.intValue() < 0) {
failed(new ClosedChannelException(), attachment);
return;
@@ -823,16 +823,16 @@ public class Nio2Endpoint extends Abstra
}
@Override
- public void failed(Throwable exc, SocketWrapper<Nio2Channel> attachment) {
+ public void failed(Throwable exc, SocketWrapperBase<Nio2Channel> attachment) {
processSocket0(attachment, SocketStatus.DISCONNECT, true);
}
};
- public void addTimeout(SocketWrapper<Nio2Channel> socket) {
+ public void addTimeout(SocketWrapperBase<Nio2Channel> socket) {
waitingRequests.add(socket);
}
- public boolean removeTimeout(SocketWrapper<Nio2Channel> socket) {
+ public boolean removeTimeout(SocketWrapperBase<Nio2Channel> socket) {
return waitingRequests.remove(socket);
}
@@ -853,7 +853,7 @@ public class Nio2Endpoint extends Abstra
}
}
- public void awaitBytes(SocketWrapper<Nio2Channel> socket) {
+ public void awaitBytes(SocketWrapperBase<Nio2Channel> socket) {
if (socket == null || socket.getSocket() == null) {
return;
}
@@ -996,14 +996,14 @@ public class Nio2Endpoint extends Abstra
*/
protected class SocketProcessor implements Runnable {
- private SocketWrapper<Nio2Channel> socket = null;
+ private SocketWrapperBase<Nio2Channel> socket = null;
private SocketStatus status = null;
- public SocketProcessor(SocketWrapper<Nio2Channel> socket, SocketStatus status) {
+ public SocketProcessor(SocketWrapperBase<Nio2Channel> socket, SocketStatus status) {
reset(socket,status);
}
- public void reset(SocketWrapper<Nio2Channel> socket, SocketStatus status) {
+ public void reset(SocketWrapperBase<Nio2Channel> socket, SocketStatus status) {
this.socket = socket;
this.status = status;
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java?rev=1637917&r1=1637916&r2=1637917&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java Mon Nov 10 16:45:04 2014
@@ -35,7 +35,7 @@ import org.apache.juli.logging.LogFactor
import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.collections.SynchronizedQueue;
import org.apache.tomcat.util.collections.SynchronizedStack;
-import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment;
+import org.apache.tomcat.util.net.NioEndpoint.NioSocketWrapper;
public class NioBlockingSelector {
@@ -90,7 +90,7 @@ public class NioBlockingSelector {
if (reference == null) {
reference = new KeyReference();
}
- KeyAttachment att = (KeyAttachment) key.attachment();
+ NioSocketWrapper att = (NioSocketWrapper) key.attachment();
int written = 0;
boolean timedout = false;
int keycount = 1; //assume we can write
@@ -162,7 +162,7 @@ public class NioBlockingSelector {
if (reference == null) {
reference = new KeyReference();
}
- KeyAttachment att = (KeyAttachment) key.attachment();
+ NioSocketWrapper att = (NioSocketWrapper) key.attachment();
int read = 0;
boolean timedout = false;
int keycount = 1; //assume we can read
@@ -234,7 +234,7 @@ public class NioBlockingSelector {
if (wakeupCounter.addAndGet(1)==0) selector.wakeup();
}
- public void cancel(SelectionKey sk, KeyAttachment key, int ops){
+ public void cancel(SelectionKey sk, NioSocketWrapper key, int ops){
if (sk!=null) {
sk.cancel();
sk.attach(null);
@@ -243,7 +243,7 @@ public class NioBlockingSelector {
}
}
- public void add(final KeyAttachment key, final int ops, final KeyReference ref) {
+ public void add(final NioSocketWrapper key, final int ops, final KeyReference ref) {
if ( key == null ) return;
NioChannel nch = key.getSocket();
if ( nch == null ) return;
@@ -274,7 +274,7 @@ public class NioBlockingSelector {
wakeup();
}
- public void remove(final KeyAttachment key, final int ops) {
+ public void remove(final NioSocketWrapper key, final int ops) {
if ( key == null ) return;
NioChannel nch = key.getSocket();
if ( nch == null ) return;
@@ -364,7 +364,7 @@ public class NioBlockingSelector {
// any active event.
while (run && iterator != null && iterator.hasNext()) {
SelectionKey sk = iterator.next();
- KeyAttachment attachment = (KeyAttachment)sk.attachment();
+ NioSocketWrapper attachment = (NioSocketWrapper)sk.attachment();
try {
attachment.access();
iterator.remove();
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=1637917&r1=1637916&r2=1637917&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Mon Nov 10 16:45:04 2014
@@ -132,7 +132,7 @@ public class NioEndpoint extends Abstrac
/**
* Cache for key attachment objects
*/
- private SynchronizedStack<KeyAttachment> keyCache;
+ private SynchronizedStack<NioSocketWrapper> keyCache;
/**
* Cache for poller events
@@ -590,17 +590,17 @@ public class NioEndpoint extends Abstrac
@Override
- public void processSocket(SocketWrapper<NioChannel> socketWrapper,
+ public void processSocket(SocketWrapperBase<NioChannel> socketWrapper,
SocketStatus socketStatus, boolean dispatch) {
NioChannel socket = socketWrapper.getSocket();
if (socket.isOpen() && dispatch && socketStatus == SocketStatus.OPEN_READ) {
socket.getPoller().add(socket, OP_CALLBACK);
} else {
- processSocket((KeyAttachment) socketWrapper, socketStatus, dispatch);
+ processSocket((NioSocketWrapper) socketWrapper, socketStatus, dispatch);
}
}
- protected boolean processSocket(KeyAttachment attachment, SocketStatus status, boolean dispatch) {
+ protected boolean processSocket(NioSocketWrapper attachment, SocketStatus status, boolean dispatch) {
try {
if (attachment == null) {
return false;
@@ -756,13 +756,13 @@ public class NioEndpoint extends Abstrac
private NioChannel socket;
private int interestOps;
- private KeyAttachment key;
+ private NioSocketWrapper key;
- public PollerEvent(NioChannel ch, KeyAttachment k, int intOps) {
+ public PollerEvent(NioChannel ch, NioSocketWrapper k, int intOps) {
reset(ch, k, intOps);
}
- public void reset(NioChannel ch, KeyAttachment k, int intOps) {
+ public void reset(NioChannel ch, NioSocketWrapper k, int intOps) {
socket = ch;
interestOps = intOps;
key = k;
@@ -785,7 +785,7 @@ public class NioEndpoint extends Abstrac
try {
boolean cancel = false;
if (key != null) {
- final KeyAttachment att = (KeyAttachment) key.attachment();
+ final NioSocketWrapper att = (NioSocketWrapper) key.attachment();
if ( att!=null ) {
//handle callback flag
if ((interestOps & OP_CALLBACK) == OP_CALLBACK ) {
@@ -887,7 +887,7 @@ public class NioEndpoint extends Abstrac
}
addEvent(r);
if (close) {
- NioEndpoint.KeyAttachment ka = (NioEndpoint.KeyAttachment)socket.getAttachment(false);
+ NioEndpoint.NioSocketWrapper ka = (NioEndpoint.NioSocketWrapper)socket.getAttachment(false);
processSocket(ka, SocketStatus.STOP, false);
}
}
@@ -925,8 +925,8 @@ public class NioEndpoint extends Abstrac
*/
public void register(final NioChannel socket) {
socket.setPoller(this);
- KeyAttachment key = keyCache.pop();
- final KeyAttachment ka = key!=null?key:new KeyAttachment(socket);
+ NioSocketWrapper key = keyCache.pop();
+ final NioSocketWrapper ka = key!=null?key:new NioSocketWrapper(socket);
ka.reset(this,socket,getSocketProperties().getSoTimeout());
ka.setKeepAliveLeft(NioEndpoint.this.getMaxKeepAliveRequests());
ka.setSecure(isSSLEnabled());
@@ -940,7 +940,7 @@ public class NioEndpoint extends Abstrac
public void cancelledKey(SelectionKey key) {
try {
if ( key == null ) return;//nothing to do
- KeyAttachment ka = (KeyAttachment) key.attachment();
+ NioSocketWrapper ka = (NioSocketWrapper) key.attachment();
key.attach(null);
if (ka!=null) handler.release(ka);
else handler.release((SocketChannel)key.channel());
@@ -1052,7 +1052,7 @@ public class NioEndpoint extends Abstrac
// any active event.
while (iterator != null && iterator.hasNext()) {
SelectionKey sk = iterator.next();
- KeyAttachment attachment = (KeyAttachment)sk.attachment();
+ NioSocketWrapper attachment = (NioSocketWrapper)sk.attachment();
// Attachment may be null if another thread has called
// cancelledKey()
if (attachment == null) {
@@ -1086,7 +1086,7 @@ public class NioEndpoint extends Abstrac
stopLatch.countDown();
}
- protected boolean processKey(SelectionKey sk, KeyAttachment attachment) {
+ protected boolean processKey(SelectionKey sk, NioSocketWrapper attachment) {
boolean result = true;
try {
if ( close ) {
@@ -1132,7 +1132,7 @@ public class NioEndpoint extends Abstrac
return result;
}
- public boolean processSendfile(SelectionKey sk, KeyAttachment attachment, boolean event) {
+ public boolean processSendfile(SelectionKey sk, NioSocketWrapper attachment, boolean event) {
NioChannel sc = null;
try {
unreg(sk, attachment, sk.readyOps());
@@ -1229,12 +1229,12 @@ public class NioEndpoint extends Abstrac
return true;
}
- protected void unreg(SelectionKey sk, KeyAttachment attachment, int readyOps) {
+ protected void unreg(SelectionKey sk, NioSocketWrapper attachment, int readyOps) {
//this is a must, so that we don't have multiple threads messing with the socket
reg(sk,attachment,sk.interestOps()& (~readyOps));
}
- protected void reg(SelectionKey sk, KeyAttachment attachment, int intops) {
+ protected void reg(SelectionKey sk, NioSocketWrapper attachment, int intops) {
sk.interestOps(intops);
attachment.interestOps(intops);
}
@@ -1258,7 +1258,7 @@ public class NioEndpoint extends Abstrac
SelectionKey key = iter.next();
keycount++;
try {
- KeyAttachment ka = (KeyAttachment) key.attachment();
+ NioSocketWrapper ka = (NioSocketWrapper) key.attachment();
if ( ka == null ) {
cancelledKey(key); //we don't support any keys without attachments
} else if ( ka.getError() ) {
@@ -1319,9 +1319,9 @@ public class NioEndpoint extends Abstrac
}
// ----------------------------------------------------- Key Attachment Class
- public static class KeyAttachment extends SocketWrapper<NioChannel> {
+ public static class NioSocketWrapper extends SocketWrapperBase<NioChannel> {
- public KeyAttachment(NioChannel channel) {
+ public NioSocketWrapper(NioChannel channel) {
super(channel);
}
@@ -1443,9 +1443,9 @@ public class NioEndpoint extends Abstrac
* thread local fields.
*/
public interface Handler extends AbstractEndpoint.Handler {
- public SocketState process(SocketWrapper<NioChannel> socket,
+ public SocketState process(SocketWrapperBase<NioChannel> socket,
SocketStatus status);
- public void release(SocketWrapper<NioChannel> socket);
+ public void release(SocketWrapperBase<NioChannel> socket);
public void release(SocketChannel socket);
public SSLImplementation getSslImplementation();
public void onCreateSSLEngine(SSLEngine engine);
@@ -1459,14 +1459,14 @@ public class NioEndpoint extends Abstrac
*/
protected class SocketProcessor implements Runnable {
- private KeyAttachment ka = null;
+ private NioSocketWrapper ka = null;
private SocketStatus status = null;
- public SocketProcessor(KeyAttachment ka, SocketStatus status) {
+ public SocketProcessor(NioSocketWrapper ka, SocketStatus status) {
reset(ka, status);
}
- public void reset(KeyAttachment ka, SocketStatus status) {
+ public void reset(NioSocketWrapper ka, SocketStatus status) {
this.ka = ka;
this.status = status;
}
@@ -1491,7 +1491,7 @@ public class NioEndpoint extends Abstrac
}
}
- private void doRun(SelectionKey key, KeyAttachment ka) {
+ private void doRun(SelectionKey key, NioSocketWrapper ka) {
NioChannel socket = ka.getSocket();
try {
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java?rev=1637917&r1=1637916&r2=1637917&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java Mon Nov 10 16:45:04 2014
@@ -57,8 +57,8 @@ public class SecureNio2Channel extends N
protected volatile boolean readPending;
protected volatile boolean writePending;
- private CompletionHandler<Integer, SocketWrapper<Nio2Channel>> handshakeReadCompletionHandler;
- private CompletionHandler<Integer, SocketWrapper<Nio2Channel>> handshakeWriteCompletionHandler;
+ private CompletionHandler<Integer, SocketWrapperBase<Nio2Channel>> handshakeReadCompletionHandler;
+ private CompletionHandler<Integer, SocketWrapperBase<Nio2Channel>> handshakeWriteCompletionHandler;
public SecureNio2Channel(SSLEngine engine, ApplicationBufferHandler bufHandler,
Nio2Endpoint endpoint0) {
@@ -73,9 +73,9 @@ public class SecureNio2Channel extends N
netInBuffer = ByteBuffer.allocate(netBufSize);
netOutBuffer = ByteBuffer.allocate(netBufSize);
}
- handshakeReadCompletionHandler = new CompletionHandler<Integer, SocketWrapper<Nio2Channel>>() {
+ handshakeReadCompletionHandler = new CompletionHandler<Integer, SocketWrapperBase<Nio2Channel>>() {
@Override
- public void completed(Integer result, SocketWrapper<Nio2Channel> attachment) {
+ public void completed(Integer result, SocketWrapperBase<Nio2Channel> attachment) {
if (result.intValue() < 0) {
failed(new EOFException(), attachment);
return;
@@ -83,13 +83,13 @@ public class SecureNio2Channel extends N
endpoint.processSocket(attachment, SocketStatus.OPEN_READ, false);
}
@Override
- public void failed(Throwable exc, SocketWrapper<Nio2Channel> attachment) {
+ public void failed(Throwable exc, SocketWrapperBase<Nio2Channel> attachment) {
endpoint.closeSocket(attachment);
}
};
- handshakeWriteCompletionHandler = new CompletionHandler<Integer, SocketWrapper<Nio2Channel>>() {
+ handshakeWriteCompletionHandler = new CompletionHandler<Integer, SocketWrapperBase<Nio2Channel>>() {
@Override
- public void completed(Integer result, SocketWrapper<Nio2Channel> attachment) {
+ public void completed(Integer result, SocketWrapperBase<Nio2Channel> attachment) {
if (result.intValue() < 0) {
failed(new EOFException(), attachment);
return;
@@ -97,7 +97,7 @@ public class SecureNio2Channel extends N
endpoint.processSocket(attachment, SocketStatus.OPEN_WRITE, false);
}
@Override
- public void failed(Throwable exc, SocketWrapper<Nio2Channel> attachment) {
+ public void failed(Throwable exc, SocketWrapperBase<Nio2Channel> attachment) {
endpoint.closeSocket(attachment);
}
};
@@ -108,7 +108,7 @@ public class SecureNio2Channel extends N
}
@Override
- public void reset(AsynchronousSocketChannel channel, SocketWrapper<Nio2Channel> socket)
+ public void reset(AsynchronousSocketChannel channel, SocketWrapperBase<Nio2Channel> socket)
throws IOException {
super.reset(channel, socket);
netOutBuffer.position(0);
Copied: tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java (from r1637916, tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java)
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java?p2=tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java&p1=tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java&r1=1637916&r2=1637917&rev=1637917&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java Mon Nov 10 16:45:04 2014
@@ -23,7 +23,7 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
-public class SocketWrapper<E> {
+public abstract class SocketWrapperBase<E> {
private volatile E socket;
@@ -64,7 +64,7 @@ public class SocketWrapper<E> {
private Set<DispatchType> dispatches = new CopyOnWriteArraySet<>();
- public SocketWrapper(E socket) {
+ public SocketWrapperBase(E socket) {
this.socket = socket;
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
this.blockingStatusReadLock = lock.readLock();
Propchange: tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/test/org/apache/coyote/http11/filters/TesterOutputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http11/filters/TesterOutputBuffer.java?rev=1637917&r1=1637916&r2=1637917&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http11/filters/TesterOutputBuffer.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http11/filters/TesterOutputBuffer.java Mon Nov 10 16:45:04 2014
@@ -26,7 +26,7 @@ import org.apache.coyote.Response;
import org.apache.coyote.http11.AbstractOutputBuffer;
import org.apache.tomcat.util.buf.ByteChunk;
import org.apache.tomcat.util.net.AbstractEndpoint;
-import org.apache.tomcat.util.net.SocketWrapper;
+import org.apache.tomcat.util.net.SocketWrapperBase;
/**
* Output buffer for use in unit tests. This is a minimal implementation.
@@ -52,7 +52,7 @@ public class TesterOutputBuffer extends
// --------------------------------------------------------- Public Methods
@Override
- public void init(SocketWrapper<Socket> socketWrapper,
+ public void init(SocketWrapperBase<Socket> socketWrapper,
AbstractEndpoint<Socket> endpoint) throws IOException {
// NO-OP: Unused
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org