diff options
author | Mark Michelson <mmichelson@digium.com> | 2013-10-03 14:58:16 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2013-10-03 14:58:16 +0000 |
commit | ee21eee7e067573ad83bd0df492036094b4dbaca (patch) | |
tree | 024e25a92079bc7e5348bd55cc29eff2f3c38dec /tests | |
parent | c977f73e136eca1f2aaccd0ea0fe45c350906374 (diff) |
Cache string values of formats on ast_format_cap() to save processing.
Channel snapshots have string representations of the channel's native formats.
Prior to this change, the format strings were re-created on ever channel snapshot
creation. Since channel native formats rarely change, this was very wasteful.
Now, string representations of formats may optionally be stored on the ast_format_cap
for cases where string representations may be requested frequently. When formats
are altered, the string cache is marked as invalid. When strings are requested, the
cache validity is checked. If the cache is valid, then the cached strings are copied.
If the cache is invalid, then the string cache is rebuilt and copied, and the cache
is marked as being valid again.
Review: https://reviewboard.asterisk.org/r/2879
........
Merged revisions 400356 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400363 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_config.c | 6 | ||||
-rw-r--r-- | tests/test_format_api.c | 24 |
2 files changed, 15 insertions, 15 deletions
diff --git a/tests/test_config.c b/tests/test_config.c index 6b1a8e420..f9e9a6f48 100644 --- a/tests/test_config.c +++ b/tests/test_config.c @@ -671,7 +671,7 @@ static void *test_item_alloc(const char *cat) ao2_ref(item, -1); return NULL; } - if (!(item->codeccapopt = ast_format_cap_alloc())) { + if (!(item->codeccapopt = ast_format_cap_alloc(0))) { ao2_ref(item, -1); return NULL; } @@ -855,10 +855,10 @@ AST_TEST_DEFINE(config_options_test) ast_sockaddr_parse(&acl_allow, "1.2.3.4", PARSE_PORT_FORBID); ast_sockaddr_parse(&acl_fail, "1.1.1.1", PARSE_PORT_FORBID); - defaults.codeccapopt = ast_format_cap_alloc(); + defaults.codeccapopt = ast_format_cap_alloc(0); ast_parse_allow_disallow(&defaults.codecprefopt, defaults.codeccapopt, CODEC_DEFAULT, 1); - configs.codeccapopt = ast_format_cap_alloc(); + configs.codeccapopt = ast_format_cap_alloc(0); ast_parse_allow_disallow(&configs.codecprefopt, configs.codeccapopt, CODEC_CONFIG, 1); ast_string_field_init(&defaults, 128); diff --git a/tests/test_format_api.c b/tests/test_format_api.c index c429e0895..6cc349570 100644 --- a/tests/test_format_api.c +++ b/tests/test_format_api.c @@ -622,8 +622,8 @@ AST_TEST_DEFINE(container_test1_nolock) break; } - cap1 = ast_format_cap_alloc_nolock(); - cap2 = ast_format_cap_alloc_nolock(); + cap1 = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK); + cap2 = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK); if (!cap1 || !cap2) { ast_test_status_update(test, "cap alloc failed.\n"); @@ -654,8 +654,8 @@ AST_TEST_DEFINE(container_test1_withlock) break; } - cap1 = ast_format_cap_alloc(); - cap2 = ast_format_cap_alloc(); + cap1 = ast_format_cap_alloc(0); + cap2 = ast_format_cap_alloc(0); if (!cap1 || !cap2) { ast_test_status_update(test, "cap alloc failed.\n"); @@ -710,7 +710,7 @@ AST_TEST_DEFINE(container_test2_no_locking) break; } - cap = ast_format_cap_alloc_nolock(); + cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK); if (!cap) { ast_test_status_update(test, "alloc failed\n"); return AST_TEST_FAIL; @@ -737,7 +737,7 @@ AST_TEST_DEFINE(container_test2_with_locking) break; } - cap = ast_format_cap_alloc(); + cap = ast_format_cap_alloc(0); if (!cap) { ast_test_status_update(test, "alloc failed\n"); return AST_TEST_FAIL; @@ -756,13 +756,13 @@ static int container_test3_helper(int nolocking, struct ast_test *test) for (x = 0; x < 2000; x++) { if (nolocking) { - cap1 = ast_format_cap_alloc_nolock(); - cap2 = ast_format_cap_alloc_nolock(); - joint = ast_format_cap_alloc_nolock(); + cap1 = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK); + cap2 = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK); + joint = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK); } else { - cap1 = ast_format_cap_alloc(); - cap2 = ast_format_cap_alloc(); - joint = ast_format_cap_alloc(); + cap1 = ast_format_cap_alloc(0); + cap2 = ast_format_cap_alloc(0); + joint = ast_format_cap_alloc(0); } if (!cap1 || !cap2 || !joint) { ast_test_status_update(test, "cap alloc fail\n"); |