]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
When handling a reload of chan_iax2, don't use an ao2_callback() to POKE all
authorRussell Bryant <russell@russellbryant.com>
Wed, 19 Sep 2007 19:13:29 +0000 (19:13 +0000)
committerRussell Bryant <russell@russellbryant.com>
Wed, 19 Sep 2007 19:13:29 +0000 (19:13 +0000)
peers.  Instead, use an iterator.  By using an iterator, the peers container
is not locked while the POKE is being done.  It can cause a deadlock if the
peers container is locked because poking a peer will try to lock pvt structs,
while there is a lot of other code that will hold a pvt lock when trying to
go lock the peers container.
(reported to me directly by Loic Didelot.  Thank you for the debug info!)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@83175 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c

index 3e530997046c6b91b0e7b9bc7b58250f10ce2b3c..8fcf40139d3419b38ebeb793eaad63441fe19c0c 100644 (file)
@@ -9812,6 +9812,17 @@ static int set_config(char *config_file, int reload)
        return capability;
 }
 
+static void poke_all_peers(void)
+{
+       struct ao2_iterator i;
+       struct iax2_peer *peer;
+
+       i = ao2_iterator_init(peers, 0);
+       while ((peer = ao2_iterator_next(&i))) {
+               iax2_poke_peer(peer, 0);
+               peer_unref(peer);
+       }
+}
 static int reload_config(void)
 {
        char *config = "iax.conf";
@@ -9836,7 +9847,7 @@ static int reload_config(void)
                iax2_do_register(reg);
        AST_LIST_UNLOCK(&registrations);
        /* Qualify hosts, too */
-       ao2_callback(peers, 0, iax2_poke_peer_cb, NULL);
+       poke_all_peers();
        reload_firmware(0);
        iax_provision_reload();