summaryrefslogtreecommitdiff
path: root/res/res_pjsip/location.c
diff options
context:
space:
mode:
authorSean Bright <sean.bright@gmail.com>2017-11-16 16:00:20 -0500
committerSean Bright <sean.bright@gmail.com>2017-11-16 16:48:29 -0500
commitdb2677133cbffa275fa595e29a6ad9881a9fb780 (patch)
treef7193798ad2758b8ee78f6933292d5a7bf9459a0 /res/res_pjsip/location.c
parent8d55b132b94c830f3dae18e4c5519e5ce5af9a33 (diff)
res_pjsip: Use sorcery prefix operation for contact lookup
This improves performance for registrations assuming that res_config_astdb is not in use. Change-Id: I86f37aa9ef07a4fe63448cb881bbadd996834bb1
Diffstat (limited to 'res/res_pjsip/location.c')
-rw-r--r--res/res_pjsip/location.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index 8ba409e2e..2bd40e84f 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -71,16 +71,17 @@ static void aor_deleted_observer(const void *object)
{
const struct ast_sip_aor *aor = object;
const char *aor_id = ast_sorcery_object_get_id(object);
- /* Give enough space for ^ at the beginning and ;@ at the end, since that is our object naming scheme */
- char regex[strlen(aor_id) + 4];
+ /* Give enough space for ;@ at the end, since that is our object naming scheme */
+ size_t prefix_len = strlen(aor_id) + sizeof(";@") - 1;
+ char prefix[prefix_len + 1];
struct ao2_container *contacts;
if (aor->permanent_contacts) {
ao2_callback(aor->permanent_contacts, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, destroy_contact, NULL);
}
- snprintf(regex, sizeof(regex), "^%s;@", aor_id);
- if (!(contacts = ast_sorcery_retrieve_by_regex(ast_sip_get_sorcery(), "contact", regex))) {
+ sprintf(prefix, "%s;@", aor_id); /* Safe */
+ if (!(contacts = ast_sorcery_retrieve_by_prefix(ast_sip_get_sorcery(), "contact", prefix, prefix_len))) {
return;
}
/* Destroy any contacts that may still exist that were made for this AoR */
@@ -217,13 +218,13 @@ struct ao2_container *ast_sip_location_retrieve_aor_contacts_nolock(const struct
struct ao2_container *ast_sip_location_retrieve_aor_contacts_nolock_filtered(const struct ast_sip_aor *aor,
unsigned int flags)
{
- /* Give enough space for ^ at the beginning and ;@ at the end, since that is our object naming scheme */
- char regex[strlen(ast_sorcery_object_get_id(aor)) + 4];
+ /* Give enough space for ;@ at the end, since that is our object naming scheme */
+ size_t prefix_len = strlen(ast_sorcery_object_get_id(aor)) + sizeof(";@") - 1;
+ char prefix[prefix_len + 1];
struct ao2_container *contacts;
- snprintf(regex, sizeof(regex), "^%s;@", ast_sorcery_object_get_id(aor));
-
- if (!(contacts = ast_sorcery_retrieve_by_regex(ast_sip_get_sorcery(), "contact", regex))) {
+ sprintf(prefix, "%s;@", ast_sorcery_object_get_id(aor)); /* Safe */
+ if (!(contacts = ast_sorcery_retrieve_by_prefix(ast_sip_get_sorcery(), "contact", prefix, prefix_len))) {
return NULL;
}