summaryrefslogtreecommitdiff
path: root/lib/isc/log.c
diff options
context:
space:
mode:
authorInternet Software Consortium, Inc <@isc.org>2007-09-07 14:11:04 -0600
committerLaMont Jones <lamont@debian.org>2007-09-07 14:11:04 -0600
commit4dd5eedee98c3fc2f40a45078bc7006cd5efd7f0 (patch)
tree85b4b951eb54c6a7d489139cdc8f8a0b1fb87eeb /lib/isc/log.c
parente71238b670ee683d2177c93695465bb6b181c4b8 (diff)
downloadbind9-4dd5eedee98c3fc2f40a45078bc7006cd5efd7f0.tar.gz
9.2.0a1
Diffstat (limited to 'lib/isc/log.c')
-rw-r--r--lib/isc/log.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/isc/log.c b/lib/isc/log.c
index ebbfd325..6412dbe9 100644
--- a/lib/isc/log.c
+++ b/lib/isc/log.c
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: log.c,v 1.55.2.4 2001/05/29 22:35:37 bwelling Exp $ */
+/* $Id: log.c,v 1.64 2001/05/29 22:35:54 bwelling Exp $ */
/* Principal Authors: DCL */
@@ -35,6 +35,7 @@
#include <isc/mem.h>
#include <isc/msgs.h>
#include <isc/print.h>
+#include <isc/stdio.h>
#include <isc/string.h>
#include <isc/time.h>
#include <isc/util.h>
@@ -193,6 +194,7 @@ isc_logcategory_t isc_categories[] = {
*/
isc_logmodule_t isc_modules[] = {
{ "socket", 0 },
+ { "time", 0 },
{ NULL, 0 }
};
@@ -1238,9 +1240,10 @@ roll_log(isc_logchannel_t *channel) {
static isc_result_t
isc_log_open(isc_logchannel_t *channel) {
- FILE *stream;
struct stat statbuf;
isc_boolean_t regular_file;
+ isc_boolean_t roll = ISC_FALSE;
+ isc_result_t result = ISC_R_SUCCESS;
const char *path;
REQUIRE(channel->type == ISC_LOG_TOFILE);
@@ -1252,31 +1255,32 @@ isc_log_open(isc_logchannel_t *channel) {
/*
* Determine type of file; only regular files will be
- * version renamed.
+ * version renamed, and only if the base file exists
+ * and either has no size limit or has reached its size limit.
*/
- if (stat(path, &statbuf) == 0)
+ if (stat(path, &statbuf) == 0) {
regular_file = (statbuf.st_mode & S_IFREG) ?
ISC_TRUE : ISC_FALSE;
- else if (errno == ENOENT)
+ /* XXXDCL if not regular_file complain? */
+ roll = ISC_TF(regular_file &&
+ statbuf.st_size >= FILE_MAXSIZE(channel));
+ } else if (errno == ENOENT)
regular_file = ISC_TRUE;
else
- return (ISC_R_INVALIDFILE);
+ result = ISC_R_INVALIDFILE;
/*
* Version control.
*/
- if (regular_file)
- if (roll_log(channel) != ISC_R_SUCCESS)
- return (ISC_R_INVALIDFILE);
- /* XXXDCL if not regular_file complain? */
-
- stream = fopen(path, "a");
- if (stream == NULL)
- return (ISC_R_INVALIDFILE);
+ if (result == ISC_R_SUCCESS && roll) {
+ result = roll_log(channel);
+ if (result != ISC_R_SUCCESS)
+ return (result);
+ }
- FILE_STREAM(channel) = stream;
+ result = isc_stdio_open(path, "a", &FILE_STREAM(channel));
- return (ISC_R_SUCCESS);
+ return (result);
}
isc_boolean_t