|
|
07ea28 |
diff --git a/support/rotatelogs.c b/support/rotatelogs.c
|
|
|
07ea28 |
index d75d018..216bb12 100644
|
|
|
07ea28 |
--- a/support/rotatelogs.c
|
|
|
07ea28 |
+++ b/support/rotatelogs.c
|
|
|
07ea28 |
@@ -178,14 +178,14 @@ static void usage(const char *argv0, const char *reason)
|
|
|
07ea28 |
exit(1);
|
|
|
07ea28 |
}
|
|
|
07ea28 |
|
|
|
07ea28 |
-/*
|
|
|
07ea28 |
- * Get the unix time with timezone corrections
|
|
|
07ea28 |
- * given in the config struct.
|
|
|
07ea28 |
- */
|
|
|
07ea28 |
-static int get_now(rotate_config_t *config)
|
|
|
07ea28 |
+/* This function returns the current Unix time (time_t) plus any
|
|
|
07ea28 |
+ * configured or derived local time offset. The offset applied is
|
|
|
07ea28 |
+ * returned via *offset. */
|
|
|
07ea28 |
+static int get_now(rotate_config_t *config, apr_int32_t *offset)
|
|
|
07ea28 |
{
|
|
|
07ea28 |
apr_time_t tNow = apr_time_now();
|
|
|
07ea28 |
- int utc_offset = config->utc_offset;
|
|
|
07ea28 |
+ int utc_offset;
|
|
|
07ea28 |
+
|
|
|
07ea28 |
if (config->use_localtime) {
|
|
|
07ea28 |
/* Check for our UTC offset before using it, since it might
|
|
|
07ea28 |
* change if there's a switch between standard and daylight
|
|
|
07ea28 |
@@ -195,6 +195,13 @@ static int get_now(rotate_config_t *config)
|
|
|
07ea28 |
apr_time_exp_lt(<, tNow);
|
|
|
07ea28 |
utc_offset = lt.tm_gmtoff;
|
|
|
07ea28 |
}
|
|
|
07ea28 |
+ else {
|
|
|
07ea28 |
+ utc_offset = config->utc_offset;
|
|
|
07ea28 |
+ }
|
|
|
07ea28 |
+
|
|
|
07ea28 |
+ if (offset)
|
|
|
07ea28 |
+ *offset = utc_offset;
|
|
|
07ea28 |
+
|
|
|
07ea28 |
return (int)apr_time_sec(tNow) + utc_offset;
|
|
|
07ea28 |
}
|
|
|
07ea28 |
|
|
|
07ea28 |
@@ -258,13 +265,13 @@ static void checkRotate(rotate_config_t *config, rotate_status_t *status)
|
|
|
07ea28 |
status->rotateReason = ROTATE_SIZE;
|
|
|
07ea28 |
}
|
|
|
07ea28 |
else if (config->tRotation) {
|
|
|
07ea28 |
- if (get_now(config) >= status->tLogEnd) {
|
|
|
07ea28 |
+ if (get_now(config, NULL) >= status->tLogEnd) {
|
|
|
07ea28 |
status->rotateReason = ROTATE_TIME;
|
|
|
07ea28 |
}
|
|
|
07ea28 |
}
|
|
|
07ea28 |
}
|
|
|
07ea28 |
else if (config->tRotation) {
|
|
|
07ea28 |
- if (get_now(config) >= status->tLogEnd) {
|
|
|
07ea28 |
+ if (get_now(config, NULL) >= status->tLogEnd) {
|
|
|
07ea28 |
status->rotateReason = ROTATE_TIME;
|
|
|
07ea28 |
}
|
|
|
07ea28 |
}
|
|
|
07ea28 |
@@ -371,12 +378,16 @@ static void post_rotate(apr_pool_t *pool, struct logfile *newlog,
|
|
|
07ea28 |
static void doRotate(rotate_config_t *config, rotate_status_t *status)
|
|
|
07ea28 |
{
|
|
|
07ea28 |
|
|
|
07ea28 |
- int now = get_now(config);
|
|
|
07ea28 |
+ apr_int32_t offset;
|
|
|
07ea28 |
+ int now;
|
|
|
07ea28 |
int tLogStart;
|
|
|
07ea28 |
apr_status_t rv;
|
|
|
07ea28 |
struct logfile newlog;
|
|
|
07ea28 |
int thisLogNum = -1;
|
|
|
07ea28 |
|
|
|
07ea28 |
+ /* Retrieve local-time-adjusted-Unix-time. */
|
|
|
07ea28 |
+ now = get_now(config, &offset);
|
|
|
07ea28 |
+
|
|
|
07ea28 |
status->rotateReason = ROTATE_NONE;
|
|
|
07ea28 |
|
|
|
07ea28 |
if (config->tRotation) {
|
|
|
07ea28 |
@@ -401,7 +412,13 @@ static void doRotate(rotate_config_t *config, rotate_status_t *status)
|
|
|
07ea28 |
apr_time_exp_t e;
|
|
|
07ea28 |
apr_size_t rs;
|
|
|
07ea28 |
|
|
|
07ea28 |
- apr_time_exp_gmt(&e, tNow);
|
|
|
07ea28 |
+ /* Explode the local-time-adjusted-Unix-time into a struct tm,
|
|
|
07ea28 |
+ * first *reversing* local-time-adjustment applied by
|
|
|
07ea28 |
+ * get_now() if we are using localtime. */
|
|
|
07ea28 |
+ if (config->use_localtime)
|
|
|
07ea28 |
+ apr_time_exp_lt(&e, tNow - apr_time_from_sec(offset));
|
|
|
07ea28 |
+ else
|
|
|
07ea28 |
+ apr_time_exp_gmt(&e, tNow);
|
|
|
07ea28 |
apr_strftime(newlog.name, &rs, sizeof(newlog.name), config->szLogRoot, &e);
|
|
|
07ea28 |
}
|
|
|
07ea28 |
else {
|
|
|
07ea28 |
@@ -648,7 +665,7 @@ int main (int argc, const char * const argv[])
|
|
|
07ea28 |
nRead = sizeof(buf);
|
|
|
07ea28 |
#if APR_FILES_AS_SOCKETS
|
|
|
07ea28 |
if (config.create_empty && config.tRotation) {
|
|
|
07ea28 |
- polltimeout = status.tLogEnd ? status.tLogEnd - get_now(&config) : config.tRotation;
|
|
|
07ea28 |
+ polltimeout = status.tLogEnd ? status.tLogEnd - get_now(&config, NULL) : config.tRotation;
|
|
|
07ea28 |
if (polltimeout <= 0) {
|
|
|
07ea28 |
pollret = APR_TIMEUP;
|
|
|
07ea28 |
}
|