<p>Joshua C. Colp <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13486">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Joshua C. Colp: Looks good to me, approved; Approved for Submit
  Friendly Automation: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">main/file.c: Limit media cache usage to remote files.<br><br>When testing for the existance of a file, the media cache is searched even if<br>the file has no chance of being in it.  This can cause performance issues<br>as the media cache size increases.<br><br>As a result, calls to applications like Read and Playback using local files<br>must scan through the media cache before playing.  Under load and with a<br>large cache, this can delay the playback of those files.<br><br>This patch updates the function that checks for the existance of a file to<br>only consult the media cache database if the requested file is a remote path.<br>It introduces a new is_remote_path() function in main/file.c.<br><br>ASTERISK-28625  #close<br>Reported-by: kevin@phoneburner.com<br><br>Change-Id: If91137493732d9034dafa381c081c69274a7dcc9<br>---<br>M main/file.c<br>1 file changed, 6 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/file.c b/main/file.c</span><br><span>index 9896c7e..a0616c8 100644</span><br><span>--- a/main/file.c</span><br><span>+++ b/main/file.c</span><br><span>@@ -640,6 +640,11 @@</span><br><span>      return filename[0] == '/';</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static int is_remote_path(const char *filename)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       return strstr(filename, "://") ? 1 : 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*!</span><br><span>  * \brief test if a file exists for a given format.</span><br><span>  * \note result_cap is OPTIONAL</span><br><span>@@ -653,7 +658,7 @@</span><br><span>                return 0;</span><br><span>    }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   if (!ast_media_cache_retrieve(filename, NULL, buf, buflen)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (is_remote_path(filename) && !ast_media_cache_retrieve(filename, NULL, buf, buflen)) {</span><br><span>            return filehelper(buf, result_cap, NULL, ACTION_EXISTS);</span><br><span>     }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13486">change 13486</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/13486"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: If91137493732d9034dafa381c081c69274a7dcc9 </div>
<div style="display:none"> Gerrit-Change-Number: 13486 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua C. Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Reeves <kevin@phoneburner.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>