Klaus Demo nginx / fac3b34
Fixed handling of ngx_write_fd() and ngx_read_fd() errors. The ngx_write_fd() and ngx_read_fd() functions return -1 in case of error, so the incorrect comparison with NGX_FILE_ERROR (which is 0 on windows platforms) might result in inaccurate error message in the error log. Also the ngx_errno global variable is being set only if the returned value is -1. Valentin Bartenev 9 years ago
3 changed file(s) with 6 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
982982
983983 n = ngx_write_fd(file[i].fd, file[i].buffer, len);
984984
985 if (n == NGX_FILE_ERROR) {
985 if (n == -1) {
986986 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
987987 ngx_write_fd_n " to \"%s\" failed",
988988 file[i].name.data);
11441144
11451145 n = ngx_write_fd(file[i].fd, file[i].buffer, len);
11461146
1147 if (n == NGX_FILE_ERROR) {
1147 if (n == -1) {
11481148 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
11491149 ngx_write_fd_n " to \"%s\" failed",
11501150 file[i].name.data);
731731
732732 n = ngx_read_fd(fd, buf, len);
733733
734 if (n == NGX_FILE_ERROR) {
734 if (n == -1) {
735735 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
736736 ngx_read_fd_n " \"%s\" failed", from);
737737 goto failed;
738738 }
739739
740740 if ((size_t) n != len) {
741 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
741 ngx_log_error(NGX_LOG_ALERT, cf->log, 0,
742742 ngx_read_fd_n " has read only %z of %uz from %s",
743743 n, size, from);
744744 goto failed;
746746
747747 n = ngx_write_fd(nfd, buf, len);
748748
749 if (n == NGX_FILE_ERROR) {
749 if (n == -1) {
750750 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
751751 ngx_write_fd_n " \"%s\" failed", to);
752752 goto failed;
753753 }
754754
755755 if ((size_t) n != len) {
756 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
756 ngx_log_error(NGX_LOG_ALERT, cf->log, 0,
757757 ngx_write_fd_n " has written only %z of %uz to %s",
758758 n, size, to);
759759 goto failed;