Index: server/core.c =================================================================== --- server/core.c (revision 1031037) +++ server/core.c (working copy) @@ -3328,6 +3328,32 @@ return a; } +static const char *set_errorlog_name(cmd_parms *cmd, void *dummy, + const char *arg1, const char *arg2) +{ + const char *err_string = NULL; + core_server_config *conf = ap_get_module_config(cmd->server->module_config, + &core_module); + + cmd->server->error_fname = (char *)arg1; + + if (arg2 != NULL) { + if (strncmp(arg2, "rotating", 8) == 0) { + if (arg2[8] == '\0') { + cmd->server->error_rotating = -1; + } + else { + cmd->server->error_rotating = atoi(arg2+9); + } + } + else { + err_string = "ErrorLogFormat third param format is rotating[:]"; + } + } + + return err_string; +} + static const char *set_errorlog_format(cmd_parms *cmd, void *dummy, const char *arg1, const char *arg2) { @@ -3478,8 +3504,7 @@ "En-/disable server signature (on|off|email)"), AP_INIT_TAKE1("ServerRoot", set_server_root, NULL, RSRC_CONF | EXEC_ON_READ, "Common directory of server-related files (logs, confs, etc.)"), -AP_INIT_TAKE1("ErrorLog", set_server_string_slot, - (void *)APR_OFFSETOF(server_rec, error_fname), RSRC_CONF, +AP_INIT_TAKE12("ErrorLog", set_errorlog_name, NULL, RSRC_CONF, "The filename of the error log"), AP_INIT_TAKE12("ErrorLogFormat", set_errorlog_format, NULL, RSRC_CONF, "Format string for the ErrorLog"), Index: server/log.c =================================================================== --- server/log.c (revision 1031037) +++ server/log.c (working copy) @@ -422,6 +422,7 @@ } #endif else { + apr_int32_t flags = APR_APPEND | APR_WRITE | APR_CREATE | APR_LARGEFILE; fname = ap_server_root_relative(p, s->error_fname); if (!fname) { ap_log_error(APLOG_MARK, APLOG_STARTUP, APR_EBADPATH, NULL, @@ -429,14 +430,22 @@ ap_server_argv0, s->error_fname); return DONE; } - if ((rc = apr_file_open(&s->error_log, fname, - APR_APPEND | APR_WRITE | APR_CREATE | APR_LARGEFILE, + + if (s->error_rotating != 0) { + flags |= APR_FOPEN_ROTATING; + } + + if ((rc = apr_file_open(&s->error_log, fname, flags, APR_OS_DEFAULT, p)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL, "%s: could not open error log file %s.", ap_server_argv0, fname); return DONE; } + + if (s->error_rotating > 0) { + apr_file_rotating_interval_set(s->error_log, s->error_rotating); + } } return OK; Index: include/httpd.h =================================================================== --- include/httpd.h (revision 1031037) +++ include/httpd.h (working copy) @@ -1201,6 +1201,10 @@ /** The name of the error log */ char *error_fname; + + /* time for rotating */ + apr_interval_time_t error_rotating; + /** A file descriptor that references the error log */ apr_file_t *error_log; /** The log level configuration */ Index: srclib/apr/include/apr_file_io.h =================================================================== --- srclib/apr/include/apr_file_io.h (revision 1031042) +++ srclib/apr/include/apr_file_io.h (working copy) @@ -87,9 +87,9 @@ * sparse file support, see WARNING below */ -#define APR_FOPEN_ROTATING 0x10000 /**< Do file file rotation checking */ +#define APR_FOPEN_ROTATING 0x10000 /**< Do file rotation checking */ -#define APR_FOPEN_MANUAL_ROTATE 0x20000 /**< Enable Manual rotation */ +#define APR_FOPEN_MANUAL_ROTATE 0x20000 /**< Enable Manual file rotation */ #define APR_FOPEN_NONBLOCK 0x40000 /**< Platform dependent flag to enable * non blocking file io */ @@ -979,9 +979,27 @@ apr_pool_t *p); +/** + * Check a file to see if it needs to check for rotating and re-opening + * @param thefile The file to check + */ APR_DECLARE(apr_status_t) apr_file_rotating_check(apr_file_t *thefile); + +/** + * Check a file to see if it needs to check for rotating and re-opening + * using the supplied time instead of now + * @param thefile The file to check + * @param time The time to use for the check + */ APR_DECLARE(apr_status_t) apr_file_rotating_manual_check(apr_file_t *thefile, apr_time_t time); +/** + * Set the rotation check interval for a file + * @param thefile The file struct to set interval + * @param time The interval to use + */ +APR_DECLARE(apr_status_t) apr_file_rotating_interval_set(apr_file_t *thefile, apr_interval_time_t interval); + /** @} */ Index: srclib/apr/file_io/unix/open.c =================================================================== --- srclib/apr/file_io/unix/open.c (revision 1031042) +++ srclib/apr/file_io/unix/open.c (working copy) @@ -88,6 +88,16 @@ return file_cleanup(thefile, 1); } +APR_DECLARE(apr_status_t) apr_file_rotating_interval_set(apr_file_t *thefile, apr_interval_time_t interval) +{ + if (thefile->rotating) { + thefile->rotating->timeout = interval; + return APR_SUCCESS; + } + + return APR_EGENERAL; +} + APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname, apr_int32_t flag,