[Asterisk-code-review] media_cache: Don't lock when curl the remote file (asterisk[master])
Kevin Harwell
asteriskteam at digium.com
Fri Aug 13 11:28:04 CDT 2021
Attention is currently required from: Andre Barbosa.
Kevin Harwell has posted comments on this change. ( https://gerrit.asterisk.org/c/asterisk/+/16233 )
Change subject: media_cache: Don't lock when curl the remote file
......................................................................
Patch Set 1: Code-Review-1
(3 comments)
File main/media_cache.c:
https://gerrit.asterisk.org/c/asterisk/+/16233/comment/b4f7221c_8371a806
PS1, Line 192: // we unlock to curl the file
Coding guidelines: Don't use C++ type e.g. // but only use C style /* */
https://gerrit.asterisk.org/c/asterisk/+/16233/comment/5a3e87a1_7e319009
PS1, Line 204: //we lock again, before updating cache
Use /* */ style comment here too
https://gerrit.asterisk.org/c/asterisk/+/16233/comment/9f86883f_5ab2af00
PS1, Line 210: if (ast_media_cache_exists(uri)) {
While this call should be okay it 1) locks the cache again (but lock should be re-entrant so fine) 2) if it doesn't find it in the cache is calls ast_bucket_file_retrieve again (which first time through will call again since it's not in the cache yet thus potentially doubling your time)
That said I you should just be able to check to see if it in the cache similar to the above:
bucket_file = ao2_find(media_cache, uri, OBJ_SEARCH_KEY | OBJ_NOLOCK);
if (bucket_file) {
/* in cache, so un-ref, unlock cache and return */
}
/* No in cache so add ... */
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16233
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I8d4142b463ae4a1d4c41bff2bf63324821567408
Gerrit-Change-Number: 16233
Gerrit-PatchSet: 1
Gerrit-Owner: Andre Barbosa <andre.emanuel.barbosa at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Attention: Andre Barbosa <andre.emanuel.barbosa at gmail.com>
Gerrit-Comment-Date: Fri, 13 Aug 2021 16:28:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210813/52d06b35/attachment.html>
More information about the asterisk-code-review
mailing list