+
+ 796. [func] When a size limit is associated with a log file,
+ only roll it when the size is reached, not every
+ time the log file is opened. [RT #1096]
+
795. [func] Add the +multiline option to dig. [RT #1095]
794. [func] Implement the "port" and "default-port" statements
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: log.c,v 1.57 2001/02/23 23:12:25 marka Exp $ */
+/* $Id: log.c,v 1.58 2001/03/28 04:16:32 tale Exp $ */
/* Principal Authors: DCL */
#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>
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);
/*
* 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 = regular_file &&
+ (FILE_MAXSIZE(channel) == 0 ||
+ 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