]> git.kaiwu.me - nginx.git/commitdiff
Fixed double close of non-regular files in flv and mp4.
authorMaxim Dounin <mdounin@mdounin.ru>
Fri, 11 Dec 2020 10:42:07 +0000 (13:42 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Fri, 11 Dec 2020 10:42:07 +0000 (13:42 +0300)
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.

src/http/modules/ngx_http_flv_module.c
src/http/modules/ngx_http_mp4_module.c

index 7b72fae0337d113f2103f62a053657479e73ae29..cc06d538a794a2eb56e172b7186819d97a7ed67e 100644 (file)
@@ -156,12 +156,6 @@ 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);
-        }
-
         return NGX_DECLINED;
     }
 
index c1006abbb52a11d92203c6779ac8025246ad2c91..0e93fbd09a68adba01974264d3ce2de0fc8df999 100644 (file)
@@ -521,12 +521,6 @@ 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);
-        }
-
         return NGX_DECLINED;
     }