Welcome! Log In Create A New Profile

Advanced

[nginx] Core: added disk_full_time checks to error log.

Maxim Dounin
January 13, 2015 11:56AM
details: http://hg.nginx.org/nginx/rev/727177743c3c
branches:
changeset: 5962:727177743c3c
user: Maxim Dounin <mdounin@mdounin.ru>
date: Tue Jan 13 19:51:37 2015 +0300
description:
Core: added disk_full_time checks to error log.

diffstat:

src/core/ngx_log.c | 25 +++++++++++++++++++++----
src/core/ngx_log.h | 2 ++
2 files changed, 23 insertions(+), 4 deletions(-)

diffs (62 lines):

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
@@ -91,8 +91,9 @@ ngx_log_error_core(ngx_uint_t level, ngx
va_list args;
#endif
u_char *p, *last, *msg;
+ ssize_t n;
+ ngx_uint_t wrote_stderr, debug_connection;
u_char errstr[NGX_MAX_ERROR_STR];
- ngx_uint_t wrote_stderr, debug_connection;

last = errstr + NGX_MAX_ERROR_STR;

@@ -150,16 +151,32 @@ ngx_log_error_core(ngx_uint_t level, ngx

if (log->writer) {
log->writer(log, level, errstr, p - errstr);
- log = log->next;
- continue;
+ goto next;
}

- (void) ngx_write_fd(log->file->fd, errstr, p - errstr);
+ if (ngx_time() == log->disk_full_time) {
+
+ /*
+ * on FreeBSD writing to a full filesystem with enabled softupdates
+ * may block process for much longer time than writing to non-full
+ * filesystem, so we skip writing to a log for one second
+ */
+
+ goto next;
+ }
+
+ n = ngx_write_fd(log->file->fd, errstr, p - errstr);
+
+ if (n == -1 && ngx_errno == NGX_ENOSPC) {
+ log->disk_full_time = ngx_time();
+ }

if (log->file->fd == ngx_stderr) {
wrote_stderr = 1;
}

+ next:
+
log = log->next;
}

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,6 +53,8 @@ struct ngx_log_s {

ngx_atomic_uint_t connection;

+ time_t disk_full_time;
+
ngx_log_handler_pt handler;
void *data;


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Core: added disk_full_time checks to error log.

Maxim Dounin 837 January 13, 2015 11:56AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 131
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready