[asterisk-commits] file: branch 1.4 r68370 - in /branches/1.4: ./ main/dnsmgr.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Jun 7 17:02:34 MST 2007


Author: file
Date: Thu Jun  7 19:02:34 2007
New Revision: 68370

URL: http://svn.digium.com/view/asterisk?view=rev&rev=68370
Log:
Merged revisions 68368 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r68368 | file | 2007-06-07 19:59:04 -0400 (Thu, 07 Jun 2007) | 2 lines

Do a DNS lookup immediately upon calling the dnsmgr function, don't wait until a refresh happens. (issue #9097 reported by plack)

........

Modified:
    branches/1.4/   (props changed)
    branches/1.4/main/dnsmgr.c

Propchange: branches/1.4/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Modified: branches/1.4/main/dnsmgr.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/dnsmgr.c?view=diff&rev=68370&r1=68369&r2=68370
==============================================================================
--- branches/1.4/main/dnsmgr.c (original)
+++ branches/1.4/main/dnsmgr.c Thu Jun  7 19:02:34 2007
@@ -121,6 +121,9 @@
 
 int ast_dnsmgr_lookup(const char *name, struct in_addr *result, struct ast_dnsmgr_entry **dnsmgr)
 {
+	struct ast_hostent ahp;
+	struct hostent *hp;
+
 	if (ast_strlen_zero(name) || !result || !dnsmgr)
 		return -1;
 
@@ -135,21 +138,18 @@
 	if (inet_aton(name, result))
 		return 0;
 
-	/* if the manager is disabled, do a direct lookup and return the result,
-	   otherwise register a managed lookup for the name */
-	if (!enabled) {
-		struct ast_hostent ahp;
-		struct hostent *hp;
-
-		if ((hp = ast_gethostbyname(name, &ahp)))
-			memcpy(result, hp->h_addr, sizeof(result));
+	/* do a lookup now but add a manager so it will automagically get updated in the background */
+	if ((hp = ast_gethostbyname(name, &ahp)))
+		memcpy(result, hp->h_addr, sizeof(result));
+	
+	/* if dnsmgr is not enable don't bother adding an entry */
+	if (!enabled)
 		return 0;
-	} else {
-		if (option_verbose > 2)
-			ast_verbose(VERBOSE_PREFIX_2 "adding dns manager for '%s'\n", name);
-		*dnsmgr = ast_dnsmgr_get(name, result);
-		return !*dnsmgr;
-	}
+	
+	if (option_verbose > 2)
+		ast_verbose(VERBOSE_PREFIX_2 "adding dns manager for '%s'\n", name);
+	*dnsmgr = ast_dnsmgr_get(name, result);
+	return !*dnsmgr;
 }
 
 /*



More information about the asterisk-commits mailing list