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