Welcome! Log In Create A New Profile

Advanced

[nginx] Core: close PID file when writing fails.

July 21, 2020 01:38PM
details: https://hg.nginx.org/nginx/rev/4f30f75dbdf3
branches:
changeset: 7685:4f30f75dbdf3
user: Ruslan Ermilov <ru@nginx.com>
date: Tue Jul 21 20:34:29 2020 +0300
description:
Core: close PID file when writing fails.

Reported by Jinhua Tan.

diffstat:

src/core/ngx_cycle.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)

diffs (35 lines):

diff -r 32a343635b50 -r 4f30f75dbdf3 src/core/ngx_cycle.c
--- a/src/core/ngx_cycle.c Thu Jul 09 16:21:37 2020 +0300
+++ b/src/core/ngx_cycle.c Tue Jul 21 20:34:29 2020 +0300
@@ -1009,6 +1009,7 @@ ngx_int_t
ngx_create_pidfile(ngx_str_t *name, ngx_log_t *log)
{
size_t len;
+ ngx_int_t rc;
ngx_uint_t create;
ngx_file_t file;
u_char pid[NGX_INT64_LEN + 2];
@@ -1033,11 +1034,13 @@ ngx_create_pidfile(ngx_str_t *name, ngx_
return NGX_ERROR;
}

+ rc = NGX_OK;
+
if (!ngx_test_config) {
len = ngx_snprintf(pid, NGX_INT64_LEN + 2, "%P%N", ngx_pid) - pid;

if (ngx_write_file(&file, pid, len, 0) == NGX_ERROR) {
- return NGX_ERROR;
+ rc = NGX_ERROR;
}
}

@@ -1046,7 +1049,7 @@ ngx_create_pidfile(ngx_str_t *name, ngx_
ngx_close_file_n " \"%s\" failed", file.name.data);
}

- return NGX_OK;
+ return rc;
}


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

[nginx] Core: close PID file when writing fails.

ru@nginx.com 84 July 21, 2020 01:38PM



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

Online Users

Guests: 110
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready