httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Behlendorf <br...@hyperreal.com>
Subject cvs commit: apache/src conf.h httpd.h mod_log_config.c mod_rewrite.c util.c
Date Thu, 14 Nov 1996 07:24:49 GMT
brian       96/11/13 23:24:49

  Modified:    src       conf.h httpd.h mod_log_config.c mod_rewrite.c
                        util.c
  Log:
  Reviewed by:	Brian Behlendorf
  Submitted by:	Paul Eggert <eggert@twinsun.com>
  
  Fixes time zone problems.
  
  Old behavior:
  
  * When the time zone is not an integral multiple of 1 hour,
  the logs report bogus UTC offsets.  E.g. if the time zone
  is +0530 the reported UTC offset is +051800.
  
  * If !defined(HAS_GMTOFF) && !defined(NO_TIMEZONE), when the
  daylight-saving offset is not exactly 1 hour, the logs compute the UTC
  offset incorrectly when daylight saving is in effect.
  
  * If !defined(HAS_GMTOFF) && defined(NO_TIMEZONE), the code invokes
  mktime twice, once on the output of localtime and once on the output
  of gmtime, and subtracts the results.  This method is incorrect when
  the time is near a daylight-saving shift boundary.  For example,
  suppose we are in US Pacific time and the current time is 1996-10-27
  00:00:00 local time, just before a daylight saving time shift.  The
  correct UTC offset is -0700, but in this case get_gmtoff incorrectly
  computes an offset of -0800, because mktime(gmtime(...)) applies
  mktime to `1996-10-27 07:00:00' (actually a UTC time, not a local
  time) and the UTC offset as of 1996-10-27 07:00:00 local time is -0800.
  
  Here is a patch.  The key idea of the patch, which you'll find at the
  end, is an idea stolen from INN 1.5b1: assume that we are no more than
  24 hours away from UTC, which is a reasonable assumption (among other
  things, Posix requires support only for -2400 through +2400 time
  zones)
  
  Revision  Changes    Path
  1.43      +0 -2      apache/src/conf.h
  
  Index: conf.h
  ===================================================================
  RCS file: /export/home/cvs/apache/src/conf.h,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -C3 -r1.42 -r1.43
  *** conf.h	1996/11/03 21:25:05	1.42
  --- conf.h	1996/11/14 07:24:41	1.43
  ***************
  *** 300,306 ****
    #undef HAVE_GMTOFF
    #undef NO_KILLPG
    #undef NO_SETSID
  - #define timezone	_bky_timezone
    
    #elif defined(__FreeBSD__) || defined(__bsdi__)
    #define HAVE_SYS_RESOURCE_H
  --- 300,305 ----
  ***************
  *** 323,329 ****
    #elif defined(LYNXOS)
    #undef NO_KILLPG
    #undef NO_SETSID
  - #define NO_TIMEZONE
    #define NEED_STRCASECMP
    #define NEED_STRNCASECMP
    #define NEED_INITGROUPS
  --- 322,327 ----
  
  
  
  1.61      +1 -1      apache/src/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /export/home/cvs/apache/src/httpd.h,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -C3 -r1.60 -r1.61
  *** httpd.h	1996/11/04 18:10:02	1.60
  --- httpd.h	1996/11/14 07:24:42	1.61
  ***************
  *** 596,602 ****
    /* Time */
    extern const char month_snames[12][4];
    
  ! struct tm *get_gmtoff(long *tz);
    char *get_time();
    char *ht_time (pool *p, time_t t, const char *fmt, int gmt);     
    char *gm_timestr_822(pool *p, time_t t);
  --- 596,602 ----
    /* Time */
    extern const char month_snames[12][4];
    
  ! struct tm *get_gmtoff(int *tz);
    char *get_time();
    char *ht_time (pool *p, time_t t, const char *fmt, int gmt);     
    char *gm_timestr_822(pool *p, time_t t);
  
  
  
  1.16      +3 -3      apache/src/mod_log_config.c
  
  Index: mod_log_config.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/mod_log_config.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -C3 -r1.15 -r1.16
  *** mod_log_config.c	1996/11/04 01:06:10	1.15
  --- mod_log_config.c	1996/11/14 07:24:42	1.16
  ***************
  *** 287,293 ****
    
    char *log_request_time (request_rec *r, char *a)
    {
  !     long timz;
        struct tm *t;
        char tstr[MAX_STRING_LEN];
        
  --- 287,293 ----
    
    char *log_request_time (request_rec *r, char *a)
    {
  !     int timz;
        struct tm *t;
        char tstr[MAX_STRING_LEN];
        
  ***************
  *** 301,308 ****
    	if(timz < 0) timz = -timz;
    
    	strftime(tstr,MAX_STRING_LEN,"[%d/%b/%Y:%H:%M:%S ",t);
  ! 	sprintf (tstr + strlen(tstr), "%c%02ld%02ld]",
  ! 		 sign, timz/3600, timz%3600);
        }
    
        return pstrdup (r->pool, tstr);
  --- 301,308 ----
    	if(timz < 0) timz = -timz;
    
    	strftime(tstr,MAX_STRING_LEN,"[%d/%b/%Y:%H:%M:%S ",t);
  ! 	sprintf (tstr + strlen(tstr), "%c%.2d%.2d]",
  ! 		 sign, timz/60, timz%60);
        }
    
        return pstrdup (r->pool, tstr);
  
  
  
  1.8       +2 -2      apache/src/mod_rewrite.c
  
  Index: mod_rewrite.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/mod_rewrite.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -C3 -r1.7 -r1.8
  *** mod_rewrite.c	1996/10/31 17:19:36	1.7
  --- mod_rewrite.c	1996/11/14 07:24:43	1.8
  ***************
  *** 2134,2140 ****
    
    static char *current_logtime(request_rec *r)
    {
  !     long timz;
        struct tm *t;
        static char tstr[MAX_STRING_LEN];
        char sign;
  --- 2134,2140 ----
    
    static char *current_logtime(request_rec *r)
    {
  !     int timz;
        struct tm *t;
        static char tstr[MAX_STRING_LEN];
        char sign;
  ***************
  *** 2146,2152 ****
    
        strftime(tstr, MAX_STRING_LEN,"[%d/%b/%Y:%H:%M:%S ",t);
    
  !     sprintf(tstr + strlen(tstr), "%c%02ld%02ld]", sign, timz/3600, timz%3600);
    
        return pstrdup(r->pool, tstr);
    }
  --- 2146,2152 ----
    
        strftime(tstr, MAX_STRING_LEN,"[%d/%b/%Y:%H:%M:%S ",t);
    
  !     sprintf(tstr + strlen(tstr), "%c%.2d%.2d]", sign, timz/60, timz%60);
    
        return pstrdup(r->pool, tstr);
    }
  
  
  
  1.31      +14 -19    apache/src/util.c
  
  Index: util.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/util.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -C3 -r1.30 -r1.31
  *** util.c	1996/11/12 18:24:35	1.30
  --- util.c	1996/11/14 07:24:44	1.31
  ***************
  *** 103,129 ****
    }
    
    /* What a pain in the ass. */
  ! struct tm *get_gmtoff(long *tz) {
  !     time_t tt;
  !     struct tm *t;
    
  !     tt = time(NULL);
  !     t = localtime(&tt);
  ! #if defined(HAVE_GMTOFF)
  !     *tz = t->tm_gmtoff;
  ! #elif !defined(NO_TIMEZONE)
  !     *tz = - timezone;
  !     if(t->tm_isdst)
  !         *tz += 3600;
    #else
  !   {
  !     static struct tm loc_t;
  ! 
  !     loc_t = *t;   /* save it */
  !     t = gmtime(&tt);
  !     *tz = mktime(&loc_t) - mktime(t);
  !     t = &loc_t; /* return pointer to saved time */
  !   }
    #endif
        return t;
    }
  --- 103,124 ----
    }
    
    /* What a pain in the ass. */
  ! struct tm *get_gmtoff(int *tz) {
  !     time_t tt = time(NULL);
  ! #if !defined(HAS_GMTOFF)
  !     struct tm gmt = *gmtime(&tt);
  ! #endif
  !     struct tm *t = localtime(&tt);
    
  ! #if defined(HAS_GMTOFF)
  !     *tz = (int) (t->tm_gmtoff / 60);
    #else
  !     /* Assume we are never more than 24 hours away. */
  !     int days = t->tm_yday - gmt.tm_yday;
  !     int hours = ((days < -1 ? 24 : 1 < days ? -24 : days * 24)
  ! 		 + t->tm_hour - gmt.tm_hour);
  !     int minutes = hours * 60 + t->tm_min - gmt.tm_min;
  !     *tz = minutes;
    #endif
        return t;
    }
  
  
  

Mime
View raw message