[nginx] Core: fixed ENOSPC handling for error logs.
Maxim Dounin
mdounin at mdounin.ru
Tue Jun 25 20:31:21 UTC 2024
details: http://freenginx.org/hg/nginx/rev/af5b47569cb2
branches:
changeset: 9296:af5b47569cb2
user: Maxim Dounin <mdounin at mdounin.ru>
date: Tue Jun 25 22:57:57 2024 +0300
description:
Core: fixed ENOSPC handling for error logs.
For each connection a new ngx_log_t structure is created, and saving
anything into disk_full_time field in this structure doesn't affect
other connections. Fix is to move the disk_full_time field into the
ngx_open_file_t structure.
diffstat:
src/core/ngx_conf_file.c | 1 +
src/core/ngx_conf_file.h | 2 ++
src/core/ngx_log.c | 4 ++--
src/core/ngx_log.h | 2 --
4 files changed, 5 insertions(+), 4 deletions(-)
diffs (56 lines):
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -951,6 +951,7 @@ ngx_conf_open_file(ngx_cycle_t *cycle, n
file->name = *name;
}
+ file->disk_full_time = 0;
file->flush = NULL;
file->data = NULL;
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -90,6 +90,8 @@ struct ngx_open_file_s {
ngx_fd_t fd;
ngx_str_t name;
+ time_t disk_full_time;
+
void (*flush)(ngx_open_file_t *file, ngx_log_t *log);
void *data;
};
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -169,7 +169,7 @@ ngx_log_error_core(ngx_uint_t level, ngx
goto next;
}
- if (ngx_time() == log->disk_full_time) {
+ if (ngx_time() == log->file->disk_full_time) {
/*
* on FreeBSD writing to a full filesystem with enabled softupdates
@@ -183,7 +183,7 @@ ngx_log_error_core(ngx_uint_t level, ngx
n = ngx_write_fd(log->file->fd, errstr, p - errstr);
if (n == -1 && ngx_errno == NGX_ENOSPC) {
- log->disk_full_time = ngx_time();
+ log->file->disk_full_time = ngx_time();
}
if (log->file->fd == ngx_stderr) {
diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h
--- a/src/core/ngx_log.h
+++ b/src/core/ngx_log.h
@@ -53,8 +53,6 @@ struct ngx_log_s {
ngx_atomic_uint_t connection;
- time_t disk_full_time;
-
ngx_log_handler_pt handler;
void *data;
More information about the nginx-devel
mailing list