<div dir="ltr">Hello<div><br></div><div>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.</div><div><div><br></div><div>It seems that these calls to ngx_close_file() should just be removed; eg., with the following.</div><div><br></div><div>





<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b>--- a/src/http/modules/ngx_http_mp4_module.c</b></span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b>+++ b/src/http/modules/ngx_http_mp4_module.c</b></span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(46,174,187)">@@ -522,10 +522,8 @@</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"> ngx_http_mp4_handler(ngx_http_request_t *r)</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span></span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">     </span>if (!of.is_file) {</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span></span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(180,36,25)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">-<span class="gmail-Apple-converted-space">        </span>if (ngx_close_file(of.fd) == NGX_FILE_ERROR) {</span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(180,36,25)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">-<span class="gmail-Apple-converted-space">            </span>ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,</span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(180,36,25)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">-<span class="gmail-Apple-converted-space">                          </span>ngx_close_file_n " \"%s\" failed", path.data);</span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(180,36,25)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">-<span class="gmail-Apple-converted-space">        </span>}</span></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(47,180,29)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">+<span class="gmail-Apple-converted-space">        </span>ngx_log_debug2(NGX_LOG_DEBUG_HTTP, log, 0,</span></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(47,180,29)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">+ <span class="gmail-Apple-converted-space">                      </span>"%s: %V is not a file", __func__, &path);</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span></span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">         </span>return NGX_DECLINED;</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">     </span>}</span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><br></span></p><p class="gmail-p1" style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b>--- a/src/http/modules/ngx_http_flv_module.c</b></span></p><p class="gmail-p1" style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b>+++ b/src/http/modules/ngx_http_flv_module.c</b></span></p><p class="gmail-p1" style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(46,174,187)">@@ -157,10 +157,8 @@</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"> ngx_http_flv_handler(ngx_http_request_t *r)</span></p><p class="gmail-p2" style="margin:0px;font:11px Menlo;color:rgb(0,0,0);min-height:13px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span></span></p><p class="gmail-p1" style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">     </span>if (!of.is_file) {</span></p><p class="gmail-p2" style="margin:0px;font:11px Menlo;color:rgb(0,0,0);min-height:13px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span></span></p><p class="gmail-p3" style="margin:0px;font:11px Menlo;color:rgb(180,36,25)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">-<span class="gmail-Apple-converted-space">        </span>if (ngx_close_file(of.fd) == NGX_FILE_ERROR) {</span></p><p class="gmail-p3" style="margin:0px;font:11px Menlo;color:rgb(180,36,25)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">-<span class="gmail-Apple-converted-space">            </span>ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,</span></p><p class="gmail-p3" style="margin:0px;font:11px Menlo;color:rgb(180,36,25)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">-<span class="gmail-Apple-converted-space">                          </span>ngx_close_file_n " \"%s\" failed", path.data);</span></p><p class="gmail-p3" style="margin:0px;font:11px Menlo;color:rgb(180,36,25)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">-<span class="gmail-Apple-converted-space">        </span>}</span></p><p class="gmail-p4" style="margin:0px;font:11px Menlo;color:rgb(47,180,29)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">+<span class="gmail-Apple-converted-space">        </span>ngx_log_debug2(NGX_LOG_DEBUG_HTTP, log, 0,</span></p><p class="gmail-p4" style="margin:0px;font:11px Menlo;color:rgb(47,180,29)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">+ <span class="gmail-Apple-converted-space">                      </span>"%s: %V is not a file", __func__, &path);</span></p><p class="gmail-p2" style="margin:0px;font:11px Menlo;color:rgb(0,0,0);min-height:13px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span></span></p><p class="gmail-p1" style="margin:0px;font:11px Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">         </span>return NGX_DECLINED;</span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">



















</span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">     </span>}</span></p></div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><div>TIA</div><div><br></div><div>Chris</div><div dir="ltr"><br></div></div></div></div></div></div></div>