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

Chris Newton cnewton at netflix.com
Thu Dec 10 16:04:44 UTC 2020


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20201210/a3274221/attachment.htm>


More information about the nginx-devel mailing list