Author: markt Date: Fri Dec 18 14:13:18 2015 New Revision: 1720789 URL: http://svn.apache.org/viewvc?rev=1720789&view=rev Log: Comet processing in 7.0.x is a little messier than in 8.0.x. Refactor the BZ 58702 patch to take account of that.
Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/valves/TesterAccessLogValve.java Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=1720789&r1=1720788&r2=1720789&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Fri Dec 18 14:13:18 2015 @@ -319,6 +319,8 @@ public class CoyoteAdapter implements Ad if (event(req, res, SocketStatus.OPEN_READ)) { comet = true; res.action(ActionCode.COMET_BEGIN, null); + } else { + return false; } } else { comet = true; @@ -331,8 +333,23 @@ public class CoyoteAdapter implements Ad } } if (!request.isAsync() && !comet) { - request.finishRequest(); - response.finishResponse(); + try { + request.finishRequest(); + response.finishResponse(); + } finally { + long time = 0; + if (req.getStartTime() != -1) { + time = System.currentTimeMillis() - req.getStartTime(); + } + if (request.getMappingData().context != null) { + ((Context) request.getMappingData().context).logAccess( + request, response, time, false); + } else { + log(req, res, time); + } + + req.action(ActionCode.POST_REQUEST , null); + } } // Check to see if the processor is in an error state. If it is, @@ -350,22 +367,6 @@ public class CoyoteAdapter implements Ad success = false; log.error(sm.getString("coyoteAdapter.service"), t); } finally { - // Access logging - if (!request.isAsync() && !comet) { - long time = 0; - if (req.getStartTime() != -1) { - time = System.currentTimeMillis() - req.getStartTime(); - } - if (request.getMappingData().context != null) { - ((Context) request.getMappingData().context).logAccess( - request, response, time, false); - } else { - log(req, res, time); - } - - req.action(ActionCode.POST_REQUEST , null); - } - req.getRequestProcessor().setWorkerThreadName(null); // Recycle the wrapper request and response if (!success || (!comet && !request.isAsync())) { @@ -441,6 +442,8 @@ public class CoyoteAdapter implements Ad if (event(req, res, SocketStatus.OPEN_READ)) { comet = true; res.action(ActionCode.COMET_BEGIN, null); + } else { + return; } } else { comet = true; @@ -458,27 +461,26 @@ public class CoyoteAdapter implements Ad if (asyncConImpl != null) { async = true; } else if (!comet) { - request.finishRequest(); - response.finishResponse(); + try { + request.finishRequest(); + response.finishResponse(); + } finally { + if (postParseSuccess) { + // Log only if processing was invoked. + // If postParseRequest() failed, it has already logged it. + // If context is null this was the start of a comet request + // that failed and has already been logged. + ((Context) request.getMappingData().context).logAccess( + request, response, + System.currentTimeMillis() - req.getStartTime(), + false); + } + req.action(ActionCode.POST_REQUEST , null); + } } } catch (IOException e) { // Ignore } finally { - // Access log - if (!async && !comet) { - if (postParseSuccess) { - // Log only if processing was invoked. - // If postParseRequest() failed, it has already logged it. - // If context is null this was the start of a comet request - // that failed and has already been logged. - ((Context) request.getMappingData().context).logAccess( - request, response, - System.currentTimeMillis() - req.getStartTime(), - false); - } - req.action(ActionCode.POST_REQUEST , null); - } - req.getRequestProcessor().setWorkerThreadName(null); AtomicBoolean error = new AtomicBoolean(false); res.action(ActionCode.IS_ERROR, error); @@ -494,7 +496,6 @@ public class CoyoteAdapter implements Ad response.clearEncoders(); } } - } Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/valves/TesterAccessLogValve.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/valves/TesterAccessLogValve.java?rev=1720789&r1=1720788&r2=1720789&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/valves/TesterAccessLogValve.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/valves/TesterAccessLogValve.java Fri Dec 18 14:13:18 2015 @@ -43,6 +43,7 @@ public class TesterAccessLogValve extend @Override public void log(Request request, Response response, long time) { + (new Exception("Do log")).printStackTrace(); entries.add(new Entry(request.getRequestURI(), response.getStatus(), time)); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org