Author: markt
Date: Wed Sep 4 21:15:33 2013
New Revision: 1520145
URL: http://svn.apache.org/r1520145
Log:
Add some plumbing with a view to supporting non-blocking writes.
Modified:
tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java
Modified: tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java?rev=1520145&r1=1520144&r2=1520145&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java Wed Sep
4 21:15:33 2013
@@ -158,6 +158,13 @@ public abstract class AbstractAjpProcess
/**
+ * Location of next write of the response message (used withnon-blocking
+ * writes when the message may not be written in a single write). Avalue of
+ * -1 indicates that no message has been written to the buffer.
+ */
+ private int responseMsgPos = -1;
+
+ /**
* Body message.
*/
protected final AjpMessage bodyMessage;
@@ -1452,6 +1459,25 @@ public abstract class AbstractAjpProcess
}
+ private void writeResponseMessage(boolean block) throws IOException {
+ int len = responseMessage.getLen();
+ int written = 1;
+ if (responseMsgPos == -1) {
+ // New message. Advance the write position to the beginning
+ responseMsgPos = 0;
+ }
+
+ while (written > 0 && responseMsgPos < len) {
+ written = output(
+ responseMessage.getBuffer(), responseMsgPos, len, block);
+ responseMsgPos += written;
+ }
+
+ if (responseMsgPos == len) {
+ responseMsgPos = -1;
+ }
+ }
+
// ------------------------------------- InputStreamInputBuffer Inner Class
@@ -1526,7 +1552,7 @@ public abstract class AbstractAjpProcess
responseMessage.appendByte(Constants.JK_AJP13_SEND_BODY_CHUNK);
responseMessage.appendBytes(chunk.getBytes(),
chunk.getOffset() + off, thisTime);
responseMessage.end();
- output(responseMessage.getBuffer(), 0,
responseMessage.getLen(), true);
+ writeResponseMessage(true);
off += thisTime;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]