Welcome! Log In Create A New Profile

Advanced

filesystem entries that are neither 'file' nor 'dir' can result in double ngx_close_file() if processed as FLV or MP4

Chris Newton
December 10, 2020 11:06AM
Hello

It has been noticed that when 'of' as returned by ngx_open_cached_file() is
not is_file, but otherwise valid and also not is_dir, then both the
ngx_http_flv_handler() and ngx_http_mp4_handler() functions will call
ngx_close_file() immediately. However, the ngx_pool_cleanup_file() will
still be called, leading to a duplicate ngx_close_file() being performed.

It seems that these calls to ngx_close_file() should just be removed; eg.,
with the following.

*--- a/src/http/modules/ngx_http_mp4_module.c*

*+++ b/src/http/modules/ngx_http_mp4_module.c*

@@ -522,10 +522,8 @@ ngx_http_mp4_handler(ngx_http_request_t *r)



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);

- }

+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, log, 0,

+ "%s: %V is not a file", __func__, &path);



return NGX_DECLINED;

}


*--- a/src/http/modules/ngx_http_flv_module.c*

*+++ b/src/http/modules/ngx_http_flv_module.c*

@@ -157,10 +157,8 @@ ngx_http_flv_handler(ngx_http_request_t *r)



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);

- }

+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, log, 0,

+ "%s: %V is not a file", __func__, &path);



return NGX_DECLINED;

}

TIA

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

filesystem entries that are neither 'file' nor 'dir' can result in double ngx_close_file() if processed as FLV or MP4

Chris Newton 340 December 10, 2020 11:06AM

Re: filesystem entries that are neither 'file' nor 'dir' can result in double ngx_close_file() if processed as FLV or MP4

Maxim Dounin 104 December 10, 2020 12:26PM

Re: filesystem entries that are neither 'file' nor 'dir' can result in double ngx_close_file() if processed as FLV or MP4

Maxim Dounin 130 December 11, 2020 07:36PM



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

Online Users

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