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 2012/12/29 00:33:33 UTC
svn commit: r1426662 -
/tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
Author: markt
Date: Fri Dec 28 23:33:32 2012
New Revision: 1426662
URL: http://svn.apache.org/viewvc?rev=1426662&view=rev
Log:
Make distinction between wrapper and socket clearer
It is the socket that is the key for the connections map, not the processor
Modified:
tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
Modified: tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java?rev=1426662&r1=1426661&r2=1426662&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java Fri Dec 28 23:33:32 2012
@@ -579,9 +579,10 @@ public abstract class AbstractProtocol i
}
- public SocketState process(SocketWrapper<S> socket,
+ public SocketState process(SocketWrapper<S> wrapper,
SocketStatus status) {
- Processor<S> processor = connections.get(socket.getSocket());
+ S socket = wrapper.getSocket();
+ Processor<S> processor = connections.get(socket);
if (status == SocketStatus.DISCONNECT && processor == null) {
//nothing more to be done endpoint requested a close
@@ -589,7 +590,7 @@ public abstract class AbstractProtocol i
return SocketState.CLOSED;
}
- socket.setAsync(false);
+ wrapper.setAsync(false);
try {
if (processor == null) {
@@ -599,7 +600,7 @@ public abstract class AbstractProtocol i
processor = createProcessor();
}
- initSsl(socket, processor);
+ initSsl(wrapper, processor);
SocketState state = SocketState.CLOSED;
do {
@@ -616,7 +617,7 @@ public abstract class AbstractProtocol i
} else if (processor.isUpgrade()) {
state = processor.upgradeDispatch(status);
} else {
- state = processor.process(socket);
+ state = processor.process(wrapper);
}
if (state != SocketState.CLOSED && processor.isAsync()) {
@@ -628,14 +629,14 @@ public abstract class AbstractProtocol i
javax.servlet.http.ProtocolHandler httpUpgradeHandler =
processor.getHttpUpgradeHandler();
// Release the Http11 processor to be re-used
- release(socket, processor, false, false);
+ release(wrapper, processor, false, false);
// Create the light-weight upgrade processor
processor = createUpgradeProcessor(
- socket, httpUpgradeHandler);
- socket.setUpgraded(true);
+ wrapper, httpUpgradeHandler);
+ wrapper.setUpgraded(true);
}
if (getLog().isDebugEnabled()) {
- getLog().debug("Socket: [" + socket +
+ getLog().debug("Socket: [" + wrapper +
"], Status in: [" + status +
"], State out: [" + state + "]");
}
@@ -646,29 +647,29 @@ public abstract class AbstractProtocol i
// In the middle of processing a request/response. Keep the
// socket associated with the processor. Exact requirements
// depend on type of long poll
- connections.put(socket.getSocket(), processor);
- longPoll(socket, processor);
+ connections.put(socket, processor);
+ longPoll(wrapper, processor);
} else if (state == SocketState.OPEN) {
// In keep-alive but between requests. OK to recycle
// processor. Continue to poll for the next request.
- connections.remove(processor);
- release(socket, processor, false, true);
+ connections.remove(socket);
+ release(wrapper, processor, false, true);
} else if (state == SocketState.SENDFILE) {
// Sendfile in progress. If it fails, the socket will be
// closed. If it works, the socket will be re-added to the
// poller
- connections.remove(processor);
- release(socket, processor, false, false);
+ connections.remove(socket);
+ release(wrapper, processor, false, false);
} else if (state == SocketState.UPGRADED) {
// Need to keep the connection associated with the processor
- connections.put(socket.getSocket(), processor);
- longPoll(socket, processor);
+ connections.put(socket, processor);
+ longPoll(wrapper, processor);
} else {
// Connection closed. OK to recycle the processor. Upgrade
// processors are not recycled.
- connections.remove(processor);
+ connections.remove(socket);
if (!processor.isUpgrade()) {
- release(socket, processor, true, false);
+ release(wrapper, processor, true, false);
}
}
return state;
@@ -692,9 +693,12 @@ public abstract class AbstractProtocol i
getLog().error(
sm.getString("abstractConnectionHandler.error"), e);
}
+ // Make sure socket/processor is removed from the list of current
+ // connections
+ connections.remove(socket);
// Don't try to add upgrade processors back into the pool
if (processor !=null && !processor.isUpgrade()) {
- release(socket, processor, true, false);
+ release(wrapper, processor, true, false);
}
return SocketState.CLOSED;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org