Author: markt
Date: Thu Jul 2 20:49:33 2015
New Revision: 1688907
URL: http://svn.apache.org/r1688907
Log:
Simplify
Setting socket to null is pointless
Should set ka to null
Modified:
tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
Modified: tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=1688907&r1=1688906&r2=1688907&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
(original)
+++ tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Thu
Jul 2 20:49:33 2015
@@ -1469,25 +1469,24 @@ public class NioEndpoint extends Abstrac
@Override
public void run() {
NioChannel socket = ka.getSocket();
- SelectionKey key = socket.getIOChannel().keyFor(
- socket.getPoller().getSelector());
// Upgraded connections need to allow multiple threads to access
the
// connection at the same time to enable blocking IO to be used
when
// NIO has been configured
if (ka.isUpgraded() && SocketStatus.OPEN_WRITE == status) {
synchronized (ka.getWriteThreadLock()) {
- doRun(key, ka);
+ doRun();
}
} else {
synchronized (socket) {
- doRun(key, ka);
+ doRun();
}
}
}
- private void doRun(SelectionKey key, KeyAttachment ka) {
+ private void doRun() {
NioChannel socket = ka.getSocket();
+ SelectionKey key =
socket.getIOChannel().keyFor(socket.getPoller().getSelector());
try {
int handshake = -1;
@@ -1527,28 +1526,20 @@ public class NioEndpoint extends Abstrac
state = handler.process(ka, status);
}
if (state == SocketState.CLOSED) {
- close(ka, socket, key, SocketStatus.ERROR);
- socket = null;
- ka = null;
+ close(socket, key, SocketStatus.ERROR);
}
} else if (handshake == -1 ) {
- close(ka, socket, key, SocketStatus.DISCONNECT);
- socket = null;
- ka = null;
+ close(socket, key, SocketStatus.DISCONNECT);
} else {
ka.getPoller().add(socket,handshake);
}
} catch (CancelledKeyException cx) {
- if (socket != null) {
- socket.getPoller().cancelledKey(key, null);
- }
+ socket.getPoller().cancelledKey(key, null);
} catch (OutOfMemoryError oom) {
try {
oomParachuteData = null;
log.error("", oom);
- if (socket != null) {
-
socket.getPoller().cancelledKey(key,SocketStatus.ERROR);
- }
+ socket.getPoller().cancelledKey(key,SocketStatus.ERROR);
releaseCaches();
} catch (Throwable oomt) {
try {
@@ -1562,11 +1553,9 @@ public class NioEndpoint extends Abstrac
ExceptionUtils.handleThrowable(vme);
} catch (Throwable t) {
log.error("", t);
- if (socket != null) {
- socket.getPoller().cancelledKey(key,SocketStatus.ERROR);
- }
+ socket.getPoller().cancelledKey(key,SocketStatus.ERROR);
} finally {
- socket = null;
+ ka = null;
status = null;
//return to cache
if (running && !paused) {
@@ -1575,8 +1564,7 @@ public class NioEndpoint extends Abstrac
}
}
- private void close(KeyAttachment ka, NioChannel socket, SelectionKey
key,
- SocketStatus socketStatus) {
+ private void close(NioChannel socket, SelectionKey key, SocketStatus
socketStatus) {
// Close socket and pool
try {
ka.setComet(false);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]