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 2015/01/15 15:56:53 UTC
svn commit: r1652122 -
/tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
Author: markt
Date: Thu Jan 15 14:56:53 2015
New Revision: 1652122
URL: http://svn.apache.org/r1652122
Log:
Simplify
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
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=1652122&r1=1652121&r2=1652122&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Thu Jan 15 14:56:53 2015
@@ -1031,8 +1031,6 @@ public class Nio2Endpoint extends Abstra
}
// Copy what data there is in the read buffer to the byte array
- int leftToWrite = len;
- int newOffset = off;
if (remaining > 0) {
socketBufferHandler.getReadBuffer().get(b, off, remaining);
// This may be sufficient to complete the request and we
@@ -1046,8 +1044,8 @@ public class Nio2Endpoint extends Abstra
// Fill the read buffer as best we can. Only do a blocking read if
// the current read is blocking AND there wasn't any data left over
// in the read buffer.
- int nRead = fillReadBuffer(block && remaining == 0);
- if (block && remaining == 0) {
+ int nRead = fillReadBuffer(block);
+ if (block) {
// Just did a blocking read so release the semaphore
readPending.release();
}
@@ -1056,12 +1054,10 @@ public class Nio2Endpoint extends Abstra
// data that was just read
if (nRead > 0) {
socketBufferHandler.configureReadBufferForRead();
- if (nRead > leftToWrite) {
- socketBufferHandler.getReadBuffer().get(b, newOffset, leftToWrite);
- leftToWrite = 0;
+ if (nRead > len) {
+ socketBufferHandler.getReadBuffer().get(b, off, len);
} else {
- socketBufferHandler.getReadBuffer().get(b, newOffset, nRead);
- leftToWrite -= nRead;
+ socketBufferHandler.getReadBuffer().get(b, off, nRead);
}
} else if (nRead == 0 && !block) {
readInterest = true;
@@ -1070,9 +1066,9 @@ public class Nio2Endpoint extends Abstra
}
if (log.isDebugEnabled()) {
- log.debug("Socket: [" + this + "], Read: [" + (len - leftToWrite) + "]");
+ log.debug("Socket: [" + this + "], Read: [" + nRead + "]");
}
- return len - leftToWrite;
+ return nRead;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org