summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2013-03-29 18:18:42 +0000
committerMaxim Dounin <mdounin@mdounin.ru>2013-03-29 18:18:42 +0000
commite693243a9f0382486b74fe9ca4248f9e4eca507e (patch)
tree452759c29f59fff4c2202acd7d6791a1f768d644
parent4e2bbc23c1564ac1458dc17c5c6c38ca52ae012d (diff)
downloadnginx-e693243a9f0382486b74fe9ca4248f9e4eca507e.tar.gz
Merge of r5138: use of NGX_FILE_ERROR.
Use NGX_FILE_ERROR for handling file operations errors. On Win32 platforms 0 is used to indicate errors in file operations, so comparing against either -1 or NGX_OK is not portable. This was not much of an issue in patched code, since only ngx_fd_info() test is actually reachable on Win32 and in worst case it might result in bogus error log entry. Patch by Piotr Sikora.
-rw-r--r--src/core/nginx.c6
-rw-r--r--src/core/ngx_conf_file.c2
-rw-r--r--src/core/ngx_connection.c4
-rw-r--r--src/core/ngx_cycle.c2
-rw-r--r--src/os/unix/ngx_process_cycle.c2
5 files changed, 9 insertions, 7 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 045977691..94df9bf74 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -637,7 +637,7 @@ ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv)
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
- if (ngx_rename_file(ccf->pid.data, ccf->oldpid.data) != NGX_OK) {
+ if (ngx_rename_file(ccf->pid.data, ccf->oldpid.data) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
ngx_rename_file_n " %s to %s failed "
"before executing new binary process \"%s\"",
@@ -652,7 +652,9 @@ ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv)
pid = ngx_execute(cycle, &ctx);
if (pid == NGX_INVALID_PID) {
- if (ngx_rename_file(ccf->oldpid.data, ccf->pid.data) != NGX_OK) {
+ if (ngx_rename_file(ccf->oldpid.data, ccf->pid.data)
+ == NGX_FILE_ERROR)
+ {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
ngx_rename_file_n " %s back to %s failed after "
"an attempt to execute new binary process \"%s\"",
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index ed7a2ce92..a26267213 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -133,7 +133,7 @@ ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
cf->conf_file = &conf_file;
- if (ngx_fd_info(fd, &cf->conf_file->file.info) == -1) {
+ if (ngx_fd_info(fd, &cf->conf_file->file.info) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
ngx_fd_info_n " \"%s\" failed", filename->data);
}
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
index 3ba5e7682..8fae8c122 100644
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -412,7 +412,7 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
}
if (ngx_test_config) {
- if (ngx_delete_file(name) == -1) {
+ if (ngx_delete_file(name) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
ngx_delete_file_n " %s failed", name);
}
@@ -739,7 +739,7 @@ ngx_close_listening_sockets(ngx_cycle_t *cycle)
{
u_char *name = ls[i].addr_text.data + sizeof("unix:") - 1;
- if (ngx_delete_file(name) == -1) {
+ if (ngx_delete_file(name) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
ngx_delete_file_n " %s failed", name);
}
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index dc4dc8993..87b6d7daa 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -679,7 +679,7 @@ old_shm_zone_done:
ngx_log_error(NGX_LOG_WARN, cycle->log, 0,
"deleting socket %s", name);
- if (ngx_delete_file(name) == -1) {
+ if (ngx_delete_file(name) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
ngx_delete_file_n " %s failed", name);
}
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
index c9b0266ed..dfdfae081 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -647,7 +647,7 @@ ngx_reap_children(ngx_cycle_t *cycle)
if (ngx_rename_file((char *) ccf->oldpid.data,
(char *) ccf->pid.data)
- != NGX_OK)
+ == NGX_FILE_ERROR)
{
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
ngx_rename_file_n " %s back to %s failed "