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 2011/12/28 22:21:31 UTC
svn commit: r1225343 - in /tomcat/trunk:
java/org/apache/catalina/valves/AccessLogValve.java
webapps/docs/config/valve.xml
Author: markt
Date: Wed Dec 28 21:21:31 2011
New Revision: 1225343
URL: http://svn.apache.org/viewvc?rev=1225343&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=52316
Improve response length logging when sendfile is being used
Modified:
tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java
tomcat/trunk/webapps/docs/config/valve.xml
Modified: tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java?rev=1225343&r1=1225342&r2=1225343&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java Wed Dec 28 21:21:31 2011
@@ -1617,6 +1617,20 @@ public class AccessLogValve extends Valv
// Don't need to flush since trigger for log message is after the
// response has been committed
long length = response.getBytesWritten(false);
+ if (length <= 0) {
+ // Protect against nulls and unexpected types as these values
+ // may be set by untrusted applications
+ Object start = request.getAttribute(
+ "org.apache.tomcat.sendfile.start");
+ if (start instanceof Long) {
+ Object end = request.getAttribute(
+ "org.apache.tomcat.sendfile.end");
+ if (end instanceof Long) {
+ length = ((Long) end).longValue() -
+ ((Long) start).longValue();
+ }
+ }
+ }
if (length <= 0 && conversion) {
buf.append('-');
} else {
Modified: tomcat/trunk/webapps/docs/config/valve.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/valve.xml?rev=1225343&r1=1225342&r2=1225343&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/valve.xml (original)
+++ tomcat/trunk/webapps/docs/config/valve.xml Wed Dec 28 21:21:31 2011
@@ -80,6 +80,11 @@
<code>AccessLog</code> implementation found to log those requests that are
rejected before they are passed to a container.</p>
+ <p>If sendfile is used, the response bytes will be written asynchronously
+ in a separate thread and the access log valve will not know how many bytes
+ were actually written. In this case, the number of bytes that was passed to
+ the sendfile thread for writing will be recorded in the access log valve.
+ </p>
</subsection>
<subsection name="Attributes">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org