You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2001/10/24 01:00:51 UTC

cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/valves AccessLogValve.java

remm        01/10/23 16:00:51

  Modified:    catalina/src/share/org/apache/catalina/valves
                        AccessLogValve.java
  Log:
  - Fix 4327.
    A second instant is needed to do the check for the rotation (since the first one
    is updated at the beginning at the invoke, a sevlet invocation which would spend more than
    1s to complete was needed to trigger a rotation).
  
  Revision  Changes    Path
  1.11      +16 -5     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/valves/AccessLogValve.java
  
  Index: AccessLogValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/valves/AccessLogValve.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AccessLogValve.java	2001/08/27 19:10:26	1.10
  +++ AccessLogValve.java	2001/10/23 23:00:51	1.11
  @@ -128,7 +128,7 @@
    *
    * @author Craig R. McClanahan
    * @author Jason Brittain
  - * @version $Revision: 1.10 $ $Date: 2001/08/27 19:10:26 $
  + * @version $Revision: 1.11 $ $Date: 2001/10/23 23:00:51 $
    */
   
   public final class AccessLogValve
  @@ -300,6 +300,12 @@
       private boolean resolveHosts = false;
   
   
  +    /**
  +     * Instant when the log daily rotation was last checked.
  +     */
  +    private long rotationLastChecked = 0L;
  +
  +
       // ------------------------------------------------------------- Properties
   
   
  @@ -594,9 +600,11 @@
   
           // Only do a logfile switch check once a second, max.
           long systime = System.currentTimeMillis();
  -        if ((systime - currentDate.getTime()) > 1000) {
  +        if ((systime - rotationLastChecked) > 1000) {
  +
               // We need a new currentDate
               currentDate = new Date(systime);
  +            rotationLastChecked = systime;
   
               // Check for a change of date
               String tsDate = dateFormatter.format(currentDate);
  @@ -604,11 +612,14 @@
               // If the date has changed, switch log files
               if (!dateStamp.equals(tsDate)) {
                   synchronized (this) {
  -                    close();
  -                    dateStamp = tsDate;
  -                    open();
  +                    if (!dateStamp.equals(tsDate)) {
  +                        close();
  +                        dateStamp = tsDate;
  +                        open();
  +                    }
                   }
               }
  +
           }
   
           // Log this message