typedef struct rotate_status rotate_status_t;
+/* "adjusted_time_t" is used to store Unix time (seconds since epoch)
+ * which has been adjusted for some timezone fudge factor. It should
+ * be used for storing the return values from get_now(). A typedef is
+ * used since this type is similar to time_t, but different. */
+typedef long adjusted_time_t;
+
/* Structure to contain relevant logfile state: fd, pool and
* filename. */
struct logfile {
struct logfile current; /* current logfile. */
apr_pool_t *pool; /* top-level pool */
int rotateReason;
- int tLogEnd;
+ adjusted_time_t tLogEnd;
int nMessCount;
int fileNum;
};
exit(1);
}
-/* This function returns the current Unix time (time_t) plus any
- * configured or derived local time offset. The offset applied is
+/* This function returns the current Unix time (time_t) adjusted for
+ * any configured or derived local time offset. The offset applied is
* returned via *offset. */
-static int get_now(rotate_config_t *config, apr_int32_t *offset)
+static adjusted_time_t get_now(rotate_config_t *config, apr_int32_t *offset)
{
apr_time_t tNow = apr_time_now();
- int utc_offset;
+ apr_int32_t utc_offset;
if (config->use_localtime) {
/* Check for our UTC offset before using it, since it might
if (offset)
*offset = utc_offset;
- return (int)apr_time_sec(tNow) + utc_offset;
+ return apr_time_sec(tNow) + utc_offset;
}
/*
static void doRotate(rotate_config_t *config, rotate_status_t *status)
{
apr_int32_t offset;
- int now;
- int tLogStart;
+ adjusted_time_t now, tLogStart;
apr_status_t rv;
struct logfile newlog;
int thisLogNum = -1;
status->rotateReason = ROTATE_NONE;
if (config->tRotation) {
- int tLogEnd;
+ adjusted_time_t tLogEnd;
+
tLogStart = (now / config->tRotation) * config->tRotation;
tLogEnd = tLogStart + config->tRotation;
/*
}
}
else {
- apr_snprintf(newlog.name, sizeof(newlog.name), "%s.%010d", config->szLogRoot,
+ apr_snprintf(newlog.name, sizeof(newlog.name), "%s.%010ld", config->szLogRoot,
tLogStart);
}
}
#if APR_FILES_AS_SOCKETS
apr_pollfd_t pollfd = { 0 };
apr_status_t pollret = APR_SUCCESS;
- int polltimeout;
+ long polltimeout;
#endif
apr_app_initialize(&argc, &argv, NULL);