[svn-commits] gtjoseph: trunk r434547 - in /trunk: ./ res/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Apr 9 18:12:15 CDT 2015
Author: gtjoseph
Date: Thu Apr 9 18:12:13 2015
New Revision: 434547
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=434547
Log:
res_pjsip_phoneprov_provider: Fix reference leak on unload
res_pjsip_phoneprov_provider was leaking references to phoneprov objects due to
a missing OBJ_NODATA in an ao2_callback in load_users(). Rather than adding the
OBJ_NODATA, I changed load_users to use a more straightforward ao2_iterator.
This plugged the leak but exposed an unload order issue between
res_pjsip_phoneprov_provider, res_phoneprov and res_pjsip.
res_pjsip_phoneprov_provider unloads first, then res_phoneprov, then res_pjsip.
Since res_pjsip_phoneprov_provider uses res_pjsip's sorcery instance, when it
unloads, it's objects are still in the sorcery instance. When res_pjsip
unloads, it destroys all its objects including res_pjsip_phoneprov_provider's.
The phoneprov destructor then attempts to unregister the extension from
res_phoneprov but because res_phoneprov is already cleaned up, its users
container is gone and we get a FRACK.
Simple solution, check for the NULL users container before attempting to remove
the entry. Duh.
Ran tests/res_phoneprov/res_phoneprov_provider. No leaks in
res_pjsip_phoneprov_provider and no FRACKs.
Reported-by: Corey Farrell
Tested-by: George Joseph
Review: https://reviewboard.asterisk.org/r/4608/
ASTERISK-24935 #close
........
Merged revisions 434545 from http://svn.asterisk.org/svn/asterisk/branches/13
Modified:
trunk/ (props changed)
trunk/res/res_phoneprov.c
trunk/res/res_pjsip_phoneprov_provider.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.
Modified: trunk/res/res_phoneprov.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_phoneprov.c?view=diff&rev=434547&r1=434546&r2=434547
==============================================================================
--- trunk/res/res_phoneprov.c (original)
+++ trunk/res/res_phoneprov.c Thu Apr 9 18:12:13 2015
@@ -1581,12 +1581,20 @@
void ast_phoneprov_delete_extension(char *provider_name, char *macaddress)
{
+ if (!users) {
+ return;
+ }
+
ao2_callback_data(users, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE | OBJ_SEARCH_KEY,
extension_delete_cb, macaddress, provider_name);
}
void ast_phoneprov_delete_extensions(char *provider_name)
{
+ if (!users) {
+ return;
+ }
+
ao2_callback(users, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, extensions_delete_cb, provider_name);
}
Modified: trunk/res/res_pjsip_phoneprov_provider.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_phoneprov_provider.c?view=diff&rev=434547&r1=434546&r2=434547
==============================================================================
--- trunk/res/res_pjsip_phoneprov_provider.c (original)
+++ trunk/res/res_pjsip_phoneprov_provider.c Thu Apr 9 18:12:13 2015
@@ -286,9 +286,8 @@
}
/*! \brief Callback that validates the phoneprov object */
-static int users_apply_handler(void *obj, void *arg, int flags)
-{
- struct phoneprov *pp = obj;
+static void users_apply_handler(struct phoneprov *pp)
+{
const char *id = ast_sorcery_object_get_id(pp);
const char *endpoint_name;
char port_string[6];
@@ -296,19 +295,19 @@
if (!ast_var_find(pp->vars,
ast_phoneprov_std_variable_lookup(AST_PHONEPROV_STD_MAC))) {
ast_log(LOG_ERROR, "phoneprov %s must contain a MAC entry.\n", id);
- return 0;
+ return;
}
if (!ast_var_find(pp->vars,
ast_phoneprov_std_variable_lookup(AST_PHONEPROV_STD_PROFILE))) {
ast_log(LOG_ERROR, "phoneprov %s must contain a PROFILE entry.\n", id);
- return 0;
+ return;
}
endpoint_name = ast_var_find(pp->vars, "endpoint");
if (endpoint_name) {
if (load_endpoint(id, endpoint_name, pp->vars, port_string)) {
- return 0;
+ return;
}
}
@@ -337,13 +336,15 @@
ast_phoneprov_add_extension(AST_MODULE, pp->vars);
- return CMP_MATCH;
+ return;
}
/*! \brief Callback that loads the users from phoneprov sections */
static int load_users(void)
{
struct ao2_container *users;
+ struct ao2_iterator i;
+ struct phoneprov *pp;
ast_sorcery_reload_object(sorcery, "phoneprov");
@@ -353,12 +354,16 @@
return 0;
}
- ao2_callback(users, OBJ_MULTIPLE, users_apply_handler, sorcery);
+ i = ao2_iterator_init(users, 0);
+ while ((pp = ao2_iterator_next(&i))) {
+ users_apply_handler(pp);
+ ao2_ref(pp, -1);
+ }
+ ao2_iterator_destroy(&i);
ao2_ref(users, -1);
return 0;
}
-
static int load_module(void)
{
More information about the svn-commits
mailing list