tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1176590 - in /tomcat/trunk/java/org/apache: catalina/connector/ coyote/ajp/ coyote/http11/
Date Tue, 27 Sep 2011 20:15:41 GMT
Author: markt
Date: Tue Sep 27 20:15:41 2011
New Revision: 1176590

URL: http://svn.apache.org/viewvc?rev=1176590&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51872
Ensure access log always logs the correct remote IP.
Ensure requests with multiple errors do not result in multiple access log entries. 

Modified:
    tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
    tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java

Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=1176590&r1=1176589&r2=1176590&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Tue Sep 27 20:15:41
2011
@@ -466,10 +466,8 @@ public class CoyoteAdapter implements Ad
 
         Request request = (Request) req.getNote(ADAPTER_NOTES);
         Response response = (Response) res.getNote(ADAPTER_NOTES);
-        boolean create = false;
         
         if (request == null) {
-            create = true;
             // Create objects
             request = connector.createRequest();
             request.setCoyoteRequest(req);
@@ -511,9 +509,7 @@ public class CoyoteAdapter implements Ad
         } catch (Throwable t) {
             ExceptionUtils.handleThrowable(t);
             log.warn(sm.getString("coyoteAdapter.accesslogFail"), t);
-        }
-        
-        if (create) {
+        } finally {
             request.recycle();
             response.recycle();
         }

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=1176590&r1=1176589&r2=1176590&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java Tue Sep 27 20:15:41
2011
@@ -759,7 +759,6 @@ public abstract class AbstractAjpProcess
                     secret = true;
                     if (!tmpMB.equals(requiredSecret)) {
                         response.setStatus(403);
-                        adapter.log(request, response, 0);
                         error = true;
                     }
                 }
@@ -776,7 +775,6 @@ public abstract class AbstractAjpProcess
         // Check if secret was submitted if required
         if ((requiredSecret != null) && !secret) {
             response.setStatus(403);
-            adapter.log(request, response, 0);
             error = true;
         }
 
@@ -810,6 +808,9 @@ public abstract class AbstractAjpProcess
         MessageBytes valueMB = request.getMimeHeaders().getValue("host");
         parseHost(valueMB);
 
+        if (error) {
+            adapter.log(request, response, 0);
+        }
     }
 
 
@@ -825,7 +826,6 @@ public abstract class AbstractAjpProcess
                 request.serverName().duplicate(request.localName());
             } catch (IOException e) {
                 response.setStatus(400);
-                adapter.log(request, response, 0);
                 error = true;
             }
             return;
@@ -877,7 +877,6 @@ public abstract class AbstractAjpProcess
                     error = true;
                     // 400 - Bad request
                     response.setStatus(400);
-                    adapter.log(request, response, 0);
                     break;
                 }
                 port = port + (charValue * mult);

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=1176590&r1=1176589&r2=1176590&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java Tue Sep 27 20:15:41 2011
@@ -182,7 +182,7 @@ public class AjpAprProcessor extends Abs
                 }
             }
 
-            if (!cping && endpoint.isPaused()) {
+            if (!error && !cping && endpoint.isPaused()) {
                 // 503 - Service unavailable
                 response.setStatus(503);
                 adapter.log(request, response, 0);

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java?rev=1176590&r1=1176589&r2=1176590&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java Tue Sep 27 20:15:41 2011
@@ -169,7 +169,7 @@ public class AjpNioProcessor extends Abs
                 }
             }
 
-            if (!cping && endpoint.isPaused()) {
+            if (!error && !cping && endpoint.isPaused()) {
                 // 503 - Service unavailable
                 response.setStatus(503);
                 adapter.log(request, response, 0);

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java?rev=1176590&r1=1176589&r2=1176590&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java Tue Sep 27 20:15:41 2011
@@ -185,7 +185,7 @@ public class AjpProcessor extends Abstra
                 }
             }
 
-            if (!cping && endpoint.isPaused()) {
+            if (!error && !cping && endpoint.isPaused()) {
                 // 503 - Service unavailable
                 response.setStatus(503);
                 adapter.log(request, response, 0);

Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1176590&r1=1176589&r2=1176590&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Tue Sep 27 20:15:41
2011
@@ -893,7 +893,6 @@ public abstract class AbstractHttp11Proc
                 if (endpoint.isPaused()) {
                     // 503 - Service unavailable
                     response.setStatus(503);
-                    adapter.log(request, response, 0);
                     error = true;
                 } else {
                     request.setStartTime(System.currentTimeMillis());
@@ -1083,7 +1082,6 @@ public abstract class AbstractHttp11Proc
                           " Unsupported HTTP version \""+protocolMB+"\"");
             }
             response.setStatus(505);
-            adapter.log(request, response, 0);
         }
 
         MessageBytes methodMB = request.method();
@@ -1179,7 +1177,6 @@ public abstract class AbstractHttp11Proc
                     error = true;
                     // 501 - Unimplemented
                     response.setStatus(501);
-                    adapter.log(request, response, 0);
                 }
                 startPos = commaPos + 1;
                 commaPos = transferEncodingValue.indexOf(',', startPos);
@@ -1195,7 +1192,6 @@ public abstract class AbstractHttp11Proc
                               " Unsupported transfer encoding \""+encodingName+"\"");
                 }
                 response.setStatus(501);
-                adapter.log(request, response, 0);
             }
         }
 
@@ -1218,7 +1214,6 @@ public abstract class AbstractHttp11Proc
                           " host header missing");
             }
             response.setStatus(400);
-            adapter.log(request, response, 0);
         }
 
         parseHost(valueMB);
@@ -1248,6 +1243,10 @@ public abstract class AbstractHttp11Proc
             request.setAttribute("org.apache.tomcat.comet.timeout.support",
                     Boolean.TRUE);
         }
+        
+        if (error) {
+            adapter.log(request, response, 0);
+        }
     }
 
 
@@ -1467,7 +1466,6 @@ public abstract class AbstractHttp11Proc
                     error = true;
                     // 400 - Bad request
                     response.setStatus(400);
-                    adapter.log(request, response, 0);
                     break;
                 }
                 port = port + (charValue * mult);
@@ -1548,8 +1546,9 @@ public abstract class AbstractHttp11Proc
             ExceptionUtils.handleThrowable(t);
             getLog().error(sm.getString("http11processor.request.finish"), t);
             // 500 - Internal Server Error
+            // Can't add a 500 to the access log since that has already been
+            // written in the Adapter.service method.
             response.setStatus(500);
-            adapter.log(request, response, 0);
             error = true;
         }
         try {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message