Welcome! Log In Create A New Profile

Advanced

[nginx] Fixed double close of non-regular files in flv and mp4.

Maxim Dounin
December 11, 2020 07:34PM
details: https://hg.nginx.org/nginx/rev/7a55311b0dc3
branches:
changeset: 7754:7a55311b0dc3
user: Maxim Dounin <mdounin@mdounin.ru>
date: Fri Dec 11 13:42:07 2020 +0300
description:
Fixed double close of non-regular files in flv and mp4.

With introduction of open_file_cache in 1454:f497ed7682a7, opening a file
with ngx_open_cached_file() automatically adds a cleanup handler to close
the file. As such, calling ngx_close_file() directly for non-regular files
is no longer needed and will result in duplicate close() call.

In 1454:f497ed7682a7 ngx_close_file() call for non-regular files was removed
in the static module, but wasn't in the flv module. And the resulting
incorrect code was later copied to the mp4 module. Fix is to remove the
ngx_close_file() call from both modules.

Reported by Chris Newton.

diffstat:

src/http/modules/ngx_http_flv_module.c | 6 ------
src/http/modules/ngx_http_mp4_module.c | 6 ------
2 files changed, 0 insertions(+), 12 deletions(-)

diffs (32 lines):

diff -r 2fec22332ff4 -r 7a55311b0dc3 src/http/modules/ngx_http_flv_module.c
--- a/src/http/modules/ngx_http_flv_module.c Thu Dec 10 20:09:39 2020 +0300
+++ b/src/http/modules/ngx_http_flv_module.c Fri Dec 11 13:42:07 2020 +0300
@@ -156,12 +156,6 @@ ngx_http_flv_handler(ngx_http_request_t
}

if (!of.is_file) {
-
- if (ngx_close_file(of.fd) == NGX_FILE_ERROR) {
- ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
- ngx_close_file_n " \"%s\" failed", path.data);
- }
-
return NGX_DECLINED;
}

diff -r 2fec22332ff4 -r 7a55311b0dc3 src/http/modules/ngx_http_mp4_module.c
--- a/src/http/modules/ngx_http_mp4_module.c Thu Dec 10 20:09:39 2020 +0300
+++ b/src/http/modules/ngx_http_mp4_module.c Fri Dec 11 13:42:07 2020 +0300
@@ -521,12 +521,6 @@ ngx_http_mp4_handler(ngx_http_request_t
}

if (!of.is_file) {
-
- if (ngx_close_file(of.fd) == NGX_FILE_ERROR) {
- ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
- ngx_close_file_n " \"%s\" failed", path.data);
- }
-
return NGX_DECLINED;
}

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

[nginx] Fixed double close of non-regular files in flv and mp4.

Maxim Dounin 314 December 11, 2020 07:34PM



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

Online Users

Guests: 160
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