diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2015-01-13 19:51:37 +0300 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2015-01-13 19:51:37 +0300 |
commit | a1f330a0a2b76fa00c16776f307181533130846d (patch) | |
tree | 5f3754d06efad025621c2f98b5a4a63307bb4a48 | |
parent | 2754fd3c803cce0ae7caf1a2ce2ada7e88e60b1b (diff) |
Core: added disk_full_time checks to error log.
-rw-r--r-- | src/core/ngx_log.c | 25 | ||||
-rw-r--r-- | src/core/ngx_log.h | 2 |
2 files changed, 23 insertions, 4 deletions
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c index 005d9ff88..0cf235998 100644 --- 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_log_t *log, ngx_err_t err, va_list args; #endif u_char *p, *last, *msg; - u_char errstr[NGX_MAX_ERROR_STR]; + ssize_t n; ngx_uint_t wrote_stderr, debug_connection; + u_char errstr[NGX_MAX_ERROR_STR]; last = errstr + NGX_MAX_ERROR_STR; @@ -150,16 +151,32 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, 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 index 95ecca528..6b04b7876 100644 --- 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; |