]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
634. [bug] A log file will completely stop being written when
authorDavid Lawrence <source@isc.org>
Sat, 23 Dec 2000 19:23:48 +0000 (19:23 +0000)
committerDavid Lawrence <source@isc.org>
Sat, 23 Dec 2000 19:23:48 +0000 (19:23 +0000)
it reaches the maximum size in all cases, not just
when versioning is also enabled. [RT #570]

CHANGES
lib/isc/include/isc/log.h
lib/isc/log.c

diff --git a/CHANGES b/CHANGES
index ad958459eb35ddf8e2d1abd2ab367cc56c77b3f7..2426218170a4d9f0b831eee53a20b4535588c62c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,8 @@
 
+ 634.  [bug]           A log file will completely stop being written when
+                       it reaches the maximum size in all cases, not just
+                       when versioning is also enabled. [RT #570]
+
  633.  [port]          Cope with rlim_t missing on BSD/OS systems. [RT #575]
 
        --- 9.1.0b2 released ---
index cd10da29eaca184bb2a8fae9061ca3042c8e3fde..d3ad6af08ac35eb5d56de7d5a6319819f2a5fc70 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: log.h,v 1.34 2000/12/12 05:29:33 tale Exp $ */
+/* $Id: log.h,v 1.35 2000/12/23 19:23:47 tale Exp $ */
 
 #ifndef ISC_LOG_H
 #define ISC_LOG_H 1
@@ -107,6 +107,7 @@ typedef struct isc_logfile {
         * to a size large enough for the largest possible file on a system.
         */
        isc_offset_t maximum_size;
+       isc_boolean_t maximum_reached; /* Private. */
 } isc_logfile_t;
 
 /*
index dc580a81be91d90539432e9db185064204042b5f..423613d13b30738663747a421ff2b065fa074acf 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: log.c,v 1.54 2000/12/12 05:29:31 tale Exp $ */
+/* $Id: log.c,v 1.55 2000/12/23 19:23:48 tale Exp $ */
 
 /* Principal Authors: DCL */
 
@@ -233,11 +233,12 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
  * Convenience macros.
  */
 
-#define FACILITY(channel)      (channel->destination.facility)
-#define FILE_NAME(channel)     (channel->destination.file.name)
-#define FILE_STREAM(channel)   (channel->destination.file.stream)
-#define FILE_VERSIONS(channel) (channel->destination.file.versions)
-#define FILE_MAXSIZE(channel)  (channel->destination.file.maximum_size)
+#define FACILITY(channel)       (channel->destination.facility)
+#define FILE_NAME(channel)      (channel->destination.file.name)
+#define FILE_STREAM(channel)    (channel->destination.file.stream)
+#define FILE_VERSIONS(channel)  (channel->destination.file.versions)
+#define FILE_MAXSIZE(channel)   (channel->destination.file.maximum_size)
+#define FILE_MAXREACHED(channel) (channel->destination.file.maximum_reached)
 
 /****
  **** Public interfaces.
@@ -724,8 +725,9 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name,
                FILE_NAME(channel) =
                        isc_mem_strdup(mctx, destination->file.name);
                FILE_STREAM(channel) = NULL;
-               FILE_MAXSIZE(channel) = destination->file.maximum_size;
                FILE_VERSIONS(channel) = destination->file.versions;
+               FILE_MAXSIZE(channel) = destination->file.maximum_size;
+               FILE_MAXREACHED(channel) = ISC_FALSE;
                break;
 
        case ISC_LOG_TOFILEDESC:
@@ -1588,6 +1590,31 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
 
                switch (channel->type) {
                case ISC_LOG_TOFILE:
+                       if (FILE_MAXREACHED(channel)) {
+                               /*
+                                * If the file can be rolled, OR
+                                * If the file no longer exists, OR
+                                * If the file is less than the maximum size,
+                                *    (such as if it had been renamed and
+                                *     a new one touched, or it was truncated
+                                *     in place)
+                                * ... then close it to trigger reopening.
+                                */
+                               if (FILE_VERSIONS(channel) !=
+                                   ISC_LOG_ROLLNEVER ||
+                                   (stat(FILE_NAME(channel), &statbuf) != 0 &&
+                                    errno == ENOENT) ||
+                                   statbuf.st_size < FILE_MAXSIZE(channel)) {
+                                       fclose(FILE_STREAM(channel));
+                                       FILE_STREAM(channel) = NULL;
+                                       FILE_MAXREACHED(channel) = ISC_FALSE;
+                               } else
+                                       /*
+                                        * Eh, skip it.
+                                        */
+                                       break;
+                       }
+
                        if (FILE_STREAM(channel) == NULL) {
                                result = isc_log_open(channel);
                                if (result != ISC_R_SUCCESS)
@@ -1617,8 +1644,8 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
 
                        /*
                         * If the file now exceeds its maximum size
-                        * threshold, close it and mark it ready
-                        * for reopening the next time the channel is used.
+                        * threshold, note it so that it will not be logged
+                        * to any more.
                         */
                        if (FILE_MAXSIZE(channel) != 0) {
                                INSIST(channel->type == ISC_LOG_TOFILE);
@@ -1627,10 +1654,8 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
                                /* XXXDCL complain if fstat fails? */
                                if (fstat(fileno(FILE_STREAM(channel)),
                                          &statbuf) >= 0 &&
-                                   statbuf.st_size > FILE_MAXSIZE(channel)) {
-                                       fclose(FILE_STREAM(channel));
-                                       FILE_STREAM(channel) = NULL;
-                               }
+                                   statbuf.st_size > FILE_MAXSIZE(channel))
+                                       FILE_MAXREACHED(channel) = ISC_TRUE;
                        }
 
                        break;