[asterisk-commits] mjordan: branch certified-13.1 r430865 - in /certified/branches/13.1: ./ chan...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jan 21 07:36:35 CST 2015
Author: mjordan
Date: Wed Jan 21 07:36:31 2015
New Revision: 430865
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=430865
Log:
channels/chan_sip: Fix registration leak during reload
When the SIP registrations were migrated to using ao2 in what was then trunk,
the explicit destruction of the registrations on module reload was removed and
not replaced with an ao2 equivalent. Debugging done by Stefan Engström, the
issue reporter, on ASTERISK-24673 confirmed that the reference in the
registry_list container was being leaked.
Since the purpose of cleanup_all_regs is to prep a registration for
destruction, this function now calls an ao2_callback function callback with the
OBJ_MULTIPLE | OBJ_NODATA | OBJ_UNLINK flags used to remove the registrations.
This cleans up each registration, and also removes it from the registration
container registry_list.
Review: https://reviewboard.asterisk.org/r/4355/
ASTERISK-24640 #close
Reported by: Max Man
ASTERISK-24673 #close
Reported by: Stefan Engström
Tested by: Stefan Engström
........
Merged revisions 430864 from http://svn.asterisk.org/svn/asterisk/branches/13
Modified:
certified/branches/13.1/ (props changed)
certified/branches/13.1/channels/chan_sip.c
Propchange: certified/branches/13.1/
------------------------------------------------------------------------------
--- branch-13-merged (original)
+++ branch-13-merged Wed Jan 21 07:36:31 2015
@@ -1,1 +1,1 @@
-/branches/13:429128-429222,429224-429246,429352,429407,429409,429433,429477,429497,429519,429540,429571,429739,429741,429761,429829,430010,430034,430083-430084,430092,430200,430252,430664,430776,430842
+/branches/13:429128-429222,429224-429246,429352,429407,429409,429433,429477,429497,429519,429540,429571,429739,429741,429761,429829,430010,430034,430083-430084,430092,430200,430252,430664,430776,430842,430864
Modified: certified/branches/13.1/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/channels/chan_sip.c?view=diff&rev=430865&r1=430864&r2=430865
==============================================================================
--- certified/branches/13.1/channels/chan_sip.c (original)
+++ certified/branches/13.1/channels/chan_sip.c Wed Jan 21 07:36:31 2015
@@ -31073,38 +31073,37 @@
}
}
+static int cleanup_registration(void *obj, void *arg, int flags)
+{
+ struct sip_registry *reg = obj;
+ ao2_lock(reg);
+
+ if (reg->call) {
+ ast_debug(3, "Destroying active SIP dialog for registry %s@%s\n", reg->username, reg->hostname);
+ /* This will also remove references to the registry */
+ dialog_unlink_all(reg->call);
+ reg->call = dialog_unref(reg->call, "remove iterator->call from registry traversal");
+ }
+ if (reg->expire > -1) {
+ AST_SCHED_DEL_UNREF(sched, reg->expire, ao2_t_ref(reg, -1, "reg ptr unref from reload config"));
+ }
+ if (reg->timeout > -1) {
+ AST_SCHED_DEL_UNREF(sched, reg->timeout, ao2_t_ref(reg, -1, "reg ptr unref from reload config"));
+ }
+ if (reg->dnsmgr) {
+ ast_dnsmgr_release(reg->dnsmgr);
+ reg->dnsmgr = NULL;
+ ao2_t_ref(reg, -1, "reg ptr unref from dnsmgr");
+ }
+
+ ao2_unlock(reg);
+ return CMP_MATCH;
+}
+
static void cleanup_all_regs(void)
{
- struct ao2_iterator iter;
- struct sip_registry *iterator;
- /* First, destroy all outstanding registry calls */
- /* This is needed, since otherwise active registry entries will not be destroyed */
- iter = ao2_iterator_init(registry_list, 0);
- while ((iterator = ao2_t_iterator_next(&iter, "cleanup_all_regs iter"))) {
- ao2_lock(iterator);
-
- if (iterator->call) {
- ast_debug(3, "Destroying active SIP dialog for registry %s@%s\n", iterator->username, iterator->hostname);
- /* This will also remove references to the registry */
- dialog_unlink_all(iterator->call);
- iterator->call = dialog_unref(iterator->call, "remove iterator->call from registry traversal");
- }
- if (iterator->expire > -1) {
- AST_SCHED_DEL_UNREF(sched, iterator->expire, ao2_t_ref(iterator, -1, "reg ptr unref from reload config"));
- }
- if (iterator->timeout > -1) {
- AST_SCHED_DEL_UNREF(sched, iterator->timeout, ao2_t_ref(iterator, -1, "reg ptr unref from reload config"));
- }
- if (iterator->dnsmgr) {
- ast_dnsmgr_release(iterator->dnsmgr);
- iterator->dnsmgr = NULL;
- ao2_t_ref(iterator, -1, "reg ptr unref from dnsmgr");
- }
-
- ao2_unlock(iterator);
- ao2_t_ref(iterator, -1, "cleanup_all_regs iter");
- }
- ao2_iterator_destroy(&iter);
+ ao2_t_callback(registry_list, OBJ_NODATA | OBJ_UNLINK | OBJ_MULTIPLE,
+ cleanup_registration, NULL, "remove all SIP registry items");
}
/*! \brief Re-read SIP.conf config file
More information about the asterisk-commits
mailing list