You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rj...@apache.org on 2009/01/11 17:03:57 UTC
svn commit: r733484 - /httpd/httpd/trunk/support/rotatelogs.c
Author: rjung
Date: Sun Jan 11 08:03:57 2009
New Revision: 733484
URL: http://svn.apache.org/viewvc?rev=733484&view=rev
Log:
Addition to r733479 and r733479:
Mainly cleanup plus correct decision in checkRotate()
if status->nLogFD is NULL.
Modified:
httpd/httpd/trunk/support/rotatelogs.c
Modified: httpd/httpd/trunk/support/rotatelogs.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/support/rotatelogs.c?rev=733484&r1=733483&r2=733484&view=diff
==============================================================================
--- httpd/httpd/trunk/support/rotatelogs.c (original)
+++ httpd/httpd/trunk/support/rotatelogs.c Sun Jan 11 08:03:57 2009
@@ -143,11 +143,12 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 {