[PATCH] Core: use NGX_FILE_ERROR when appropriate
Valentin V. Bartenev
vbart at nginx.com
Mon Mar 25 14:15:56 UTC 2013
On Thursday 21 March 2013 08:04:24 Piotr Sikora wrote:
> Hey guys,
> attached patch changes "if" tests to use "== NGX_FILE_ERROR" instead of
> "== -1" or "!= NGX_OK", because NGX_FILE_ERROR is defined as -1 on UNIX,
> but as 0 on Win32.
The patch looks good. I'll commit it as soon as Maxim acknowledges.
Thank you.
wbr, Valentin V. Bartenev
>
> This isn't much of an issue in patched code (only "ngx_fd_info()" test
> is actually reachable on Win32 and in worst case it might, but probably
> doesn't, result in bogus error log entry), so you can treat this as style
> fixes.
>
> Best regards,
> Piotr Sikora
>
>
> diff -r 3450eee1ee8d src/core/nginx.c
> --- a/src/core/nginx.c Wed Mar 20 18:07:25 2013 +0000
> +++ b/src/core/nginx.c Wed Mar 20 20:56:23 2013 -0700
> @@ -637,7 +637,7 @@
>
> 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 @@
> 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 -r 3450eee1ee8d src/core/ngx_conf_file.c
> --- a/src/core/ngx_conf_file.c Wed Mar 20 18:07:25 2013 +0000
> +++ b/src/core/ngx_conf_file.c Wed Mar 20 20:56:23 2013 -0700
> @@ -133,7 +133,7 @@
>
> 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 -r 3450eee1ee8d src/core/ngx_connection.c
> --- a/src/core/ngx_connection.c Wed Mar 20 18:07:25 2013 +0000
> +++ b/src/core/ngx_connection.c Wed Mar 20 20:56:23 2013 -0700
> @@ -412,7 +412,7 @@
> }
>
> 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 @@
> {
> 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 -r 3450eee1ee8d src/core/ngx_cycle.c
> --- a/src/core/ngx_cycle.c Wed Mar 20 18:07:25 2013 +0000
> +++ b/src/core/ngx_cycle.c Wed Mar 20 20:56:23 2013 -0700
> @@ -679,7 +679,7 @@
> 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 -r 3450eee1ee8d src/os/unix/ngx_process_cycle.c
> --- a/src/os/unix/ngx_process_cycle.c Wed Mar 20 18:07:25 2013 +0000
> +++ b/src/os/unix/ngx_process_cycle.c Wed Mar 20 20:56:23 2013 -0700
> @@ -647,7 +647,7 @@
>
> 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
> "
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
More information about the nginx-devel
mailing list