Mercurial > hg > nginx
changeset 5962:727177743c3c
Core: added disk_full_time checks to error log.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 13 Jan 2015 19:51:37 +0300 |
parents | 7554c83287dc |
children | e0920ea61632 |
files | src/core/ngx_log.c src/core/ngx_log.h |
diffstat | 2 files changed, 23 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/ngx_log.c Tue Jan 13 18:58:23 2015 +0300 +++ b/src/core/ngx_log.c Tue Jan 13 19:51:37 2015 +0300 @@ -91,8 +91,9 @@ 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 @@ 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; }