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/12 10:00:00 UTC
svn commit: r1651046 - in /tomcat/trunk/java/org/apache/tomcat/util/net:
AprEndpoint.java Nio2Endpoint.java NioEndpoint.java SocketWrapperBase.java
Author: markt
Date: Mon Jan 12 08:59:59 2015
New Revision: 1651046
URL: http://svn.apache.org/r1651046
Log:
No need to return value from doWrite so remove it allowing slightly
simpler code.
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java
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=1651046&r1=1651045&r2=1651046&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Mon Jan 12 08:59:59 2015
@@ -2509,7 +2509,7 @@ public class AprEndpoint extends Abstrac
@Override
- protected int doWrite(boolean block) throws IOException {
+ protected void doWrite(boolean block) throws IOException {
if (closed) {
throw new IOException(sm.getString("apr.closed", getSocket()));
}
@@ -2520,7 +2520,7 @@ public class AprEndpoint extends Abstrac
readLock.lock();
try {
if (getBlockingStatus() == block) {
- return doWriteInternal();
+ doWriteInternal();
}
} finally {
readLock.unlock();
@@ -2540,7 +2540,7 @@ public class AprEndpoint extends Abstrac
readLock.lock();
try {
writeLock.unlock();
- return doWriteInternal();
+ doWriteInternal();
} finally {
readLock.unlock();
}
@@ -2554,13 +2554,12 @@ public class AprEndpoint extends Abstrac
}
- private int doWriteInternal() throws IOException {
+ private void doWriteInternal() throws IOException {
if (!writeBufferFlipped) {
socketWriteBuffer.flip();
writeBufferFlipped = true;
}
- int written = 0;
int thisTime;
do {
@@ -2599,7 +2598,6 @@ public class AprEndpoint extends Abstrac
throw new IOException(sm.getString("socket.apr.write.error",
Integer.valueOf(-thisTime), getSocket(), this));
}
- written += thisTime;
socketWriteBuffer.position(socketWriteBuffer.position() + thisTime);
} while ((thisTime > 0 || getBlockingStatus()) && socketWriteBuffer.hasRemaining());
@@ -2611,8 +2609,6 @@ public class AprEndpoint extends Abstrac
// write further up the stack. This is to ensure the socket is only
// registered for write once as both container and user code can trigger
// write registration.
-
- return written;
}
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=1651046&r1=1651045&r2=1651046&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Mon Jan 12 08:59:59 2015
@@ -1153,18 +1153,15 @@ public class Nio2Endpoint extends Abstra
* blocking case
*/
@Override
- protected int doWrite(boolean block) throws IOException {
- int result = -1;
+ protected void doWrite(boolean block) throws IOException {
try {
socketWriteBuffer.flip();
- result = socketWriteBuffer.remaining();
while (socketWriteBuffer.hasRemaining()) {
if (getSocket().write(socketWriteBuffer).get(getTimeout(), TimeUnit.MILLISECONDS).intValue() < 0) {
throw new EOFException(sm.getString("iob.failedwrite"));
}
}
socketWriteBuffer.clear();
- return result;
} catch (ExecutionException e) {
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
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=1651046&r1=1651045&r2=1651046&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Mon Jan 12 08:59:59 2015
@@ -1512,14 +1512,12 @@ public class NioEndpoint extends Abstrac
@Override
- protected synchronized int doWrite(boolean block)
- throws IOException {
+ protected synchronized void doWrite(boolean block) throws IOException {
if (!writeBufferFlipped) {
socketWriteBuffer.flip();
writeBufferFlipped = true;
}
- int written = 0;
long writeTimeout = getWriteTimeout();
Selector selector = null;
try {
@@ -1528,7 +1526,7 @@ public class NioEndpoint extends Abstrac
// Ignore
}
try {
- written = pool.write(socketWriteBuffer, getSocket(), selector, writeTimeout, block);
+ pool.write(socketWriteBuffer, getSocket(), selector, writeTimeout, block);
// Make sure we are flushed
do {
if (getSocket().flush(true, selector, writeTimeout)) break;
@@ -1546,8 +1544,6 @@ public class NioEndpoint extends Abstrac
// write further up the stack. This is to ensure the socket is only
// registered for write once as both container and user code can trigger
// write registration.
-
- return written;
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java?rev=1651046&r1=1651045&r2=1651046&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java Mon Jan 12 08:59:59 2015
@@ -372,9 +372,7 @@ public abstract class SocketWrapperBase<
len = len - thisTime;
while (socketWriteBuffer.remaining() == 0) {
off = off + thisTime;
- if (doWrite(false) == 0) {
- break;
- }
+ doWrite(false);
if (writeBufferFlipped) {
thisTime = 0;
} else {
@@ -484,12 +482,10 @@ public abstract class SocketWrapperBase<
*
* @param block Should the write be blocking or not?
*
- * @return The number of bytes written
- *
* @throws IOException If an I/O error such as a timeout occurs during the
* write
*/
- protected abstract int doWrite(boolean block) throws IOException;
+ protected abstract void doWrite(boolean block) throws IOException;
protected void addToBuffers(byte[] buf, int offset, int length) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org