[Asterisk-code-review] main/file.c: Limit media cache usage to remote files. (asterisk[16])

Friendly Automation asteriskteam at digium.com
Thu Dec 19 10:59:53 CST 2019


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/13240 )

Change subject: main/file.c: Limit media cache usage to remote files.
......................................................................

main/file.c: Limit media cache usage to remote files.

When testing for the existance of a file, the media cache is searched even if
the file has no chance of being in it.  This can cause performance issues
as the media cache size increases.

As a result, calls to applications like Read and Playback using local files
must scan through the media cache before playing.  Under load and with a
large cache, this can delay the playback of those files.

This patch updates the function that checks for the existance of a file to
only consult the media cache database if the requested file is a remote path.
It introduces a new is_remote_path() function in main/file.c.

ASTERISK-28625  #close
Reported-by: kevin at phoneburner.com

Change-Id: If91137493732d9034dafa381c081c69274a7dcc9
---
M main/file.c
1 file changed, 6 insertions(+), 1 deletion(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Joshua C. Colp: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/main/file.c b/main/file.c
index 9896c7e..a0616c8 100644
--- a/main/file.c
+++ b/main/file.c
@@ -640,6 +640,11 @@
 	return filename[0] == '/';
 }
 
+static int is_remote_path(const char *filename)
+{
+	return strstr(filename, "://") ? 1 : 0;
+}
+
 /*!
  * \brief test if a file exists for a given format.
  * \note result_cap is OPTIONAL
@@ -653,7 +658,7 @@
 		return 0;
 	}
 
-	if (!ast_media_cache_retrieve(filename, NULL, buf, buflen)) {
+	if (is_remote_path(filename) && !ast_media_cache_retrieve(filename, NULL, buf, buflen)) {
 		return filehelper(buf, result_cap, NULL, ACTION_EXISTS);
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13240
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: If91137493732d9034dafa381c081c69274a7dcc9
Gerrit-Change-Number: 13240
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Reeves <kevin at phoneburner.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua C. Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20191219/5573392b/attachment.html>


More information about the asterisk-code-review mailing list