[svn-commits] twilson: trunk r333838 - in /trunk: ./ channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Aug 29 16:43:39 CDT 2011


Author: twilson
Date: Mon Aug 29 16:43:33 2011
New Revision: 333838

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=333838
Log:
Merged revisions 333837 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/10

................
  r333837 | twilson | 2011-08-29 16:41:13 -0500 (Mon, 29 Aug 2011) | 22 lines
  
  Merged revisions 333836 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.8
  
  ........
    r333836 | twilson | 2011-08-29 16:38:31 -0500 (Mon, 29 Aug 2011) | 15 lines
    
    Refresh peer address if DNS unavailable at peer creation
    
    If Asterisk starts and no DNS is available, outbound registrations will fail
    indefinitely. This patch copies the address from the sip_registry struct, which
    will be updated, to the peer->addr when necessary.
    
    If dnsmgr is enabled, the registration fails without the patch because even
    though the address on the registry is updated via dnsmgr, the address is just
    copied on the first try. Since we use ast_sockaddr_copy, dnsmgr can't update
    the address that is copied to the sip_pvt or peers.
    
    Closes issue ASTERISK-18000
    
    Review: https://reviewboard.asterisk.org/r/1335/
  ........
................

Modified:
    trunk/   (props changed)
    trunk/channels/chan_sip.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=333838&r1=333837&r2=333838
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Mon Aug 29 16:43:33 2011
@@ -12916,8 +12916,17 @@
 	}
 
 	if (r->dnsmgr) {
+		struct sip_peer *peer;
 		/* If the registration has timed out, maybe the IP changed.  Force a refresh. */
 		ast_dnsmgr_refresh(r->dnsmgr);
+		/* If we are resolving a peer, we have to make sure the refreshed address gets copied */
+		if ((peer = find_peer(r->hostname, NULL, TRUE, FINDPEERS, FALSE, 0))) {
+			ast_sockaddr_copy(&peer->addr, &r->us);
+			if (r->portno) {
+				ast_sockaddr_set_port(&peer->addr, r->portno);
+			}
+			peer = unref_peer(peer, "unref after find_peer");
+		}
 	}
 
 	/* If the initial tranmission failed, we may not have an existing dialog,
@@ -13034,6 +13043,16 @@
 		/* Use port number specified if no SRV record was found */
 		if (!ast_sockaddr_port(&r->us) && r->portno) {
 			ast_sockaddr_set_port(&r->us, r->portno);
+		}
+
+		/* It is possible that DNS is unavailable at the time the peer is created. Here, if
+		 * we've updated the address in the registry, we copy it to the peer so that
+		 * create_addr() can copy it to the dialog via create_addr_from_peer */
+		if ((peer = find_peer(r->hostname, NULL, TRUE, FINDPEERS, FALSE, 0))) {
+			if (ast_sockaddr_isnull(&peer->addr) && !(ast_sockaddr_isnull(&r->us))) {
+				ast_sockaddr_copy(&peer->addr, &r->us);
+			}
+			peer = unref_peer(peer, "unref after find_peer");
 		}
 
 		/* Find address to hostname */




More information about the svn-commits mailing list