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 2014/11/12 11:49:29 UTC
svn commit: r1638754 -
/tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
Author: markt
Date: Wed Nov 12 10:49:29 2014
New Revision: 1638754
URL: http://svn.apache.org/r1638754
Log:
Use SocketWrapper's write method for AJP APR
Modified:
tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java?rev=1638754&r1=1638753&r2=1638754&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java Wed Nov 12 10:49:29 2014
@@ -57,7 +57,6 @@ public class AjpAprProcessor extends Abs
// Allocate input and output buffers
inputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
inputBuffer.limit(0);
- outputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
}
@@ -67,12 +66,6 @@ public class AjpAprProcessor extends Abs
protected final ByteBuffer inputBuffer;
- /**
- * Direct buffer used for output.
- */
- protected final ByteBuffer outputBuffer;
-
-
@Override
protected void registerForEvent(boolean read, boolean write) {
((AprEndpoint) endpoint).getPoller().add(
@@ -84,7 +77,6 @@ public class AjpAprProcessor extends Abs
protected void setupSocket(SocketWrapperBase<Long> socketWrapper) {
long socketRef = socketWrapper.getSocket().longValue();
Socket.setrbb(socketRef, inputBuffer);
- Socket.setsbb(socketRef, outputBuffer);
}
@@ -92,74 +84,7 @@ public class AjpAprProcessor extends Abs
protected int output(byte[] src, int offset, int length, boolean block)
throws IOException {
- if (length == 0) {
- return 0;
- }
-
- outputBuffer.put(src, offset, length);
-
- int result = -1;
-
- if (socketWrapper.getSocket().longValue() != 0) {
- result = writeSocket(0, outputBuffer.position(), block);
- if (Status.APR_STATUS_IS_EAGAIN(-result)) {
- result = 0;
- }
- if (result < 0) {
- // There are no re-tries so clear the buffer to prevent a
- // possible overflow if the buffer is used again. BZ53119.
- outputBuffer.clear();
- throw new IOException(sm.getString("ajpprocessor.failedsend"));
- }
- }
- outputBuffer.clear();
-
- return result;
- }
-
-
- private int writeSocket(int pos, int len, boolean block) {
-
- Lock readLock = socketWrapper.getBlockingStatusReadLock();
- WriteLock writeLock = socketWrapper.getBlockingStatusWriteLock();
- long socket = socketWrapper.getSocket().longValue();
-
- boolean writeDone = false;
- int result = 0;
- readLock.lock();
- try {
- if (socketWrapper.getBlockingStatus() == block) {
- result = Socket.sendbb(socket, pos, len);
- writeDone = true;
- }
- } finally {
- readLock.unlock();
- }
-
- if (!writeDone) {
- writeLock.lock();
- try {
- socketWrapper.setBlockingStatus(block);
- // Set the current settings for this socket
- Socket.optSet(socket, Socket.APR_SO_NONBLOCK, (block ? 0 : 1));
- // Downgrade the lock
- readLock.lock();
- try {
- writeLock.unlock();
- result = Socket.sendbb(socket, pos, len);
- } finally {
- readLock.unlock();
- }
- } finally {
- // Should have been released above but may not have been on some
- // exception paths
- if (writeLock.isHeldByCurrentThread()) {
- writeLock.unlock();
- }
- }
- }
-
- return result;
+ return socketWrapper.write(block, src, offset, length);
}
@@ -269,7 +194,5 @@ public class AjpAprProcessor extends Abs
inputBuffer.clear();
inputBuffer.limit(0);
- outputBuffer.clear();
-
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org