diff options
author | Igor Sysoev <igor@sysoev.ru> | 2008-11-11 19:17:45 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2008-11-11 19:17:45 +0300 |
commit | f2884e194ab1bfe7bec979d04b21dc5f5e4a3628 (patch) | |
tree | 8f3b8c6e72e2a63ebfa6c49fec1b3d39580995f2 /src/core/ngx_conf_file.c | |
parent | ead8091746f136d7563824c7468d570481fb4e3c (diff) |
compatibility with glibc 2.3, warn_unused_result attribute for write()
Diffstat (limited to 'src/core/ngx_conf_file.c')
-rw-r--r-- | src/core/ngx_conf_file.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index d9683161b..31d00de39 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -912,6 +912,7 @@ ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name) static void ngx_conf_flush_files(ngx_cycle_t *cycle) { + ssize_t n, len; ngx_uint_t i; ngx_list_part_t *part; ngx_open_file_t *file; @@ -932,11 +933,24 @@ ngx_conf_flush_files(ngx_cycle_t *cycle) i = 0; } - if (file[i].buffer == NULL || file[i].pos - file[i].buffer == 0) { + len = file[i].pos - file[i].buffer; + + if (file[i].buffer == NULL || len == 0) { continue; } - ngx_write_fd(file[i].fd, file[i].buffer, file[i].pos - file[i].buffer); + n = ngx_write_fd(file[i].fd, file[i].buffer, len); + + if (n == NGX_FILE_ERROR) { + ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, + ngx_write_fd_n " to \"%s\" failed", + file[i].name.data); + + } else if (n != len) { + ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, + ngx_write_fd_n " to \"%s\" was incomplete: %z of %uz", + file[i].name.data, n, len); + } } } |