mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-20 12:20:12 +00:00
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@phoneburner.com Change-Id: If91137493732d9034dafa381c081c69274a7dcc9
This commit is contained in:
committed by
Kevin Harwell
parent
657ada8bfd
commit
c626ccec12
@@ -640,6 +640,11 @@ static int is_absolute_path(const char *filename)
|
|||||||
return filename[0] == '/';
|
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.
|
* \brief test if a file exists for a given format.
|
||||||
* \note result_cap is OPTIONAL
|
* \note result_cap is OPTIONAL
|
||||||
@@ -653,7 +658,7 @@ static int fileexists_test(const char *filename, const char *fmt, const char *la
|
|||||||
return 0;
|
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);
|
return filehelper(buf, result_cap, NULL, ACTION_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user