Author: violetagg
Date: Wed Aug 31 10:49:10 2016
New Revision: 1758580
URL: http://svn.apache.org/viewvc?rev=1758580&view=rev
Log:
When AprEndpoint.write(boolean, ByteBuffer) is invoked with a non direct
ByteBuffer then copy that ByteBuffer to the socket write buffer before
transferring the data to the socket.
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.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=1758580&r1=1758579&r2=1758580&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Wed Aug 31
10:49:10 2016
@@ -2479,6 +2479,59 @@ public class AprEndpoint extends Abstrac
@Override
+ protected void writeByteBufferBlocking(ByteBuffer from) throws
IOException {
+ if (from.isDirect()) {
+ super.writeByteBufferBlocking(from);
+ } else {
+ // The socket write buffer capacity is socket.appWriteBufSize
+ ByteBuffer writeBuffer = socketBufferHandler.getWriteBuffer();
+ int limit = writeBuffer.capacity();
+ while (from.remaining() >= limit) {
+ socketBufferHandler.configureWriteBufferForWrite();
+ transfer(from, writeBuffer);
+ doWrite(true);
+ }
+
+ if (from.remaining() > 0) {
+ socketBufferHandler.configureWriteBufferForWrite();
+ transfer(from, writeBuffer);
+ }
+ }
+ }
+
+
+ @Override
+ protected boolean writeByteBufferNonBlocking(ByteBuffer from) throws
IOException {
+ if (from.isDirect()) {
+ return super.writeByteBufferNonBlocking(from);
+ } else {
+ // The socket write buffer capacity is socket.appWriteBufSize
+ ByteBuffer writeBuffer = socketBufferHandler.getWriteBuffer();
+ int limit = writeBuffer.capacity();
+ while (from.remaining() >= limit) {
+ socketBufferHandler.configureWriteBufferForWrite();
+ transfer(from, writeBuffer);
+ int newPosition = writeBuffer.position() + limit;
+ doWrite(false);
+ if (writeBuffer.position() != newPosition) {
+ // Didn't write the whole amount of data in the last
+ // non-blocking write.
+ // Exit the loop.
+ return true;
+ }
+ }
+
+ if (from.remaining() > 0) {
+ socketBufferHandler.configureWriteBufferForWrite();
+ transfer(from, writeBuffer);
+ }
+
+ return false;
+ }
+ }
+
+
+ @Override
protected void doWrite(boolean block, ByteBuffer from) throws
IOException {
if (closed) {
throw new IOException(sm.getString("socket.apr.closed",
getSocket()));
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=1758580&r1=1758579&r2=1758580&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java Wed Aug
31 10:49:10 2016
@@ -453,7 +453,7 @@ public abstract class SocketWrapperBase<
}
- private void writeByteBufferBlocking(ByteBuffer from) throws IOException {
+ protected void writeByteBufferBlocking(ByteBuffer from) throws IOException
{
// The socket write buffer capacity is socket.appWriteBufSize
int limit = socketBufferHandler.getWriteBuffer().capacity();
int fromLimit = from.limit();
@@ -551,7 +551,7 @@ public abstract class SocketWrapperBase<
}
- private boolean writeByteBufferNonBlocking(ByteBuffer from) throws
IOException {
+ protected boolean writeByteBufferNonBlocking(ByteBuffer from) throws
IOException {
// The socket write buffer capacity is socket.appWriteBufSize
int limit = socketBufferHandler.getWriteBuffer().capacity();
int fromLimit = from.limit();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]