Welcome! Log In Create A New Profile

Advanced

[nginx] svn commit: r4967 - trunk/src/core

Anonymous User
December 14, 2012 10:26AM
Author: vbart
Date: 2012-12-14 15:24:24 +0000 (Fri, 14 Dec 2012)
New Revision: 4967
URL: http://trac.nginx.org/nginx/changeset/4967/nginx

Log:
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.



Modified:
trunk/src/core/ngx_conf_file.c
trunk/src/core/ngx_cycle.c
trunk/src/core/ngx_file.c

Modified: trunk/src/core/ngx_conf_file.c
===================================================================
--- trunk/src/core/ngx_conf_file.c 2012-12-14 15:17:58 UTC (rev 4966)
+++ trunk/src/core/ngx_conf_file.c 2012-12-14 15:24:24 UTC (rev 4967)
@@ -983,7 +983,7 @@

n = ngx_write_fd(file[i].fd, file[i].buffer, len);

- if (n == NGX_FILE_ERROR) {
+ if (n == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
ngx_write_fd_n " to \"%s\" failed",
file[i].name.data);

Modified: trunk/src/core/ngx_cycle.c
===================================================================
--- trunk/src/core/ngx_cycle.c 2012-12-14 15:17:58 UTC (rev 4966)
+++ trunk/src/core/ngx_cycle.c 2012-12-14 15:24:24 UTC (rev 4967)
@@ -1145,7 +1145,7 @@

n = ngx_write_fd(file[i].fd, file[i].buffer, len);

- if (n == NGX_FILE_ERROR) {
+ if (n == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
ngx_write_fd_n " to \"%s\" failed",
file[i].name.data);

Modified: trunk/src/core/ngx_file.c
===================================================================
--- trunk/src/core/ngx_file.c 2012-12-14 15:17:58 UTC (rev 4966)
+++ trunk/src/core/ngx_file.c 2012-12-14 15:24:24 UTC (rev 4967)
@@ -732,14 +732,14 @@

n = ngx_read_fd(fd, buf, len);

- if (n == NGX_FILE_ERROR) {
+ if (n == -1) {
ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
ngx_read_fd_n " \"%s\" failed", from);
goto failed;
}

if ((size_t) n != len) {
- ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
+ ngx_log_error(NGX_LOG_ALERT, cf->log, 0,
ngx_read_fd_n " has read only %z of %uz from %s",
n, size, from);
goto failed;
@@ -747,14 +747,14 @@

n = ngx_write_fd(nfd, buf, len);

- if (n == NGX_FILE_ERROR) {
+ if (n == -1) {
ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
ngx_write_fd_n " \"%s\" failed", to);
goto failed;
}

if ((size_t) n != len) {
- ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
+ ngx_log_error(NGX_LOG_ALERT, cf->log, 0,
ngx_write_fd_n " has written only %z of %uz to %s",
n, size, to);
goto failed;

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] svn commit: r4967 - trunk/src/core

Anonymous User 997 December 14, 2012 10:26AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 182
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready