summaryrefslogtreecommitdiff
path: root/support/rotatelogs.c
diff options
context:
space:
mode:
authorRainer Jung <rjung@apache.org>2009-01-11 16:03:57 +0000
committerRainer Jung <rjung@apache.org>2009-01-11 16:03:57 +0000
commit88d19bfcc5be83222a28e1727d516a8722a816ec (patch)
tree8ca3f41c67aa717070b85dc02738f67d180b36de /support/rotatelogs.c
parent4807369a2cc14d3e01b8057c1460cb63b06e1602 (diff)
downloadhttpd-88d19bfcc5be83222a28e1727d516a8722a816ec.tar.gz
Addition to r733479 and r733479:
Mainly cleanup plus correct decision in checkRotate() if status->nLogFD is NULL. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@733484 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'support/rotatelogs.c')
-rw-r--r--support/rotatelogs.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/support/rotatelogs.c b/support/rotatelogs.c
index 290fad3e26..4ba339ec63 100644
--- a/support/rotatelogs.c
+++ b/support/rotatelogs.c
@@ -143,11 +143,12 @@ static int get_now(int use_localtime, int utc_offset)
void checkRotate(rotate_config_t *config, rotate_status_t *status) {
- if (status->nLogFD == NULL)
- return;
- if (config->tRotation) {
+ if (status->nLogFD == NULL) {
+ status->needsRotate = 1;
+ }
+ else if (config->tRotation) {
status->now = get_now(config->use_localtime, config->utc_offset);
- if (status->nLogFD != NULL && status->now >= status->tLogEnd) {
+ if (status->now >= status->tLogEnd) {
status->needsRotate = 1;
}
}
@@ -155,8 +156,7 @@ void checkRotate(rotate_config_t *config, rotate_status_t *status) {
apr_finfo_t finfo;
apr_off_t current_size = -1;
- if ((status->nLogFD != NULL) &&
- (apr_file_info_get(&finfo, APR_FINFO_SIZE, status->nLogFD) == APR_SUCCESS)) {
+ if (apr_file_info_get(&finfo, APR_FINFO_SIZE, status->nLogFD) == APR_SUCCESS) {
current_size = finfo.size;
}
@@ -180,10 +180,12 @@ void doRotate(rotate_config_t *config, rotate_status_t *status) {
status->needsRotate = 0;
status->nLogFDprev = status->nLogFD;
status->nLogFD = NULL;
+ status->pfile_prev = status->pfile;
status->now = get_now(config->use_localtime, config->utc_offset);
if (config->tRotation) {
tLogStart = (status->now / config->tRotation) * config->tRotation;
+ status->tLogEnd = tLogStart + config->tRotation;
}
else {
tLogStart = status->now;
@@ -200,8 +202,6 @@ void doRotate(rotate_config_t *config, rotate_status_t *status) {
else {
sprintf(status->filename, "%s.%010d", config->szLogRoot, tLogStart);
}
- status->tLogEnd = tLogStart + config->tRotation;
- status->pfile_prev = status->pfile;
apr_pool_create(&status->pfile, status->pool);
rv = apr_file_open(&status->nLogFD, status->filename, APR_WRITE | APR_CREATE | APR_APPEND,
APR_OS_DEFAULT, status->pfile);
@@ -240,6 +240,7 @@ void doRotate(rotate_config_t *config, rotate_status_t *status) {
apr_file_close(status->nLogFDprev);
if (status->pfile_prev) {
apr_pool_destroy(status->pfile_prev);
+ status->pfile_prev = NULL;
}
}
status->nMessCount = 0;
@@ -377,7 +378,7 @@ int main (int argc, const char * const argv[])
apr_file_trunc(status.nLogFD, 0);
if (apr_file_write(status.nLogFD, status.errbuf, &nWrite) != APR_SUCCESS) {
fprintf(stderr, "Error writing to the file %s\n", status.filename);
- exit(2);
+ exit(2);
}
}
else {