mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
sorcery: Make is_object_field_registered handle field names that are regexes.
As a result of https://reviewboard.asterisk.org/r/3305, res_sorcery_realtime was tossing database fields that didn't have an exact match to a sorcery registered field. This broke the ability to use regexes as field names which manifested itself as a failure of res_pjsip_phoneprov_provider which uses this capability. It also broke handling of fields that start with '@' in realtime but I don't think anyone noticed. This patch does the following... * Modifies ast_sorcery_fields_register to pre-compile the name regex. * Modifies ast_sorcery_is_object_field_registered to test the regex if it exists instead of doing an exact strcmp. * Modifies res_pjsip_phoneprov_provider with a few tweaks to get it to work with realtime. Tested-by: George Joseph Review: https://reviewboard.asterisk.org/r/4185/ ........ Merged revisions 428543 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 428544 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@428545 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -289,7 +289,7 @@ static int load_users(void)
|
||||
int user_count = 0;
|
||||
char port_string[6];
|
||||
|
||||
c = ast_sorcery_retrieve_by_regex(sorcery, "phoneprov", "");
|
||||
c = ast_sorcery_retrieve_by_fields(sorcery, "phoneprov", AST_RETRIEVE_FLAG_MULTIPLE, NULL);
|
||||
if (!c) {
|
||||
ast_log(LOG_ERROR, "Retrieve by regex failed to allocate a container.\n");
|
||||
return -1;
|
||||
@@ -377,12 +377,7 @@ static int load_module(void)
|
||||
return AST_MODULE_LOAD_DECLINE;
|
||||
}
|
||||
|
||||
if (ast_sorcery_apply_default(sorcery, "phoneprov", "config",
|
||||
"pjsip.conf,criteria=type=phoneprov")) {
|
||||
ast_log(LOG_ERROR, "Unable to register object phoneprov.\n");
|
||||
ast_sorcery_unref(sorcery);
|
||||
return AST_MODULE_LOAD_DECLINE;
|
||||
}
|
||||
ast_sorcery_apply_default(sorcery, "phoneprov", "config", "pjsip.conf,criteria=type=phoneprov");
|
||||
|
||||
ast_sorcery_object_register(sorcery, "phoneprov", phoneprov_alloc, NULL,
|
||||
users_apply_handler);
|
||||
|
Reference in New Issue
Block a user