diff options
author | Igor Sysoev <igor@sysoev.ru> | 2008-11-11 16:17:45 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2008-11-11 16:17:45 +0000 |
commit | f2884e194ab1bfe7bec979d04b21dc5f5e4a3628 (patch) | |
tree | 8f3b8c6e72e2a63ebfa6c49fec1b3d39580995f2 /src/core/ngx_cycle.c | |
parent | ead8091746f136d7563824c7468d570481fb4e3c (diff) | |
download | nginx-f2884e194ab1bfe7bec979d04b21dc5f5e4a3628.tar.gz nginx-f2884e194ab1bfe7bec979d04b21dc5f5e4a3628.zip |
compatibility with glibc 2.3, warn_unused_result attribute for write()
Diffstat (limited to 'src/core/ngx_cycle.c')
-rw-r--r-- | src/core/ngx_cycle.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c index 39d1e4c81..aa0d9ce7e 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c @@ -996,6 +996,7 @@ ngx_test_lockfile(u_char *file, ngx_log_t *log) void ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user) { + ssize_t n, len; ngx_fd_t fd; ngx_uint_t i; ngx_list_part_t *part; @@ -1019,9 +1020,23 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user) continue; } - if (file[i].buffer && file[i].pos - file[i].buffer != 0) { - ngx_write_fd(file[i].fd, file[i].buffer, - file[i].pos - file[i].buffer); + len = file[i].pos - file[i].buffer; + + if (file[i].buffer && len != 0) { + + 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); + } + file[i].pos = file[i].buffer; } |