[asterisk-commits] rmudgett: trunk r321445 - in /trunk: ./ res/res_agi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 27 19:29:53 CDT 2011


Author: rmudgett
Date: Fri May 27 19:29:48 2011
New Revision: 321445

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

........
  r321436 | rmudgett | 2011-05-27 19:27:52 -0500 (Fri, 27 May 2011) | 4 lines
  
  Some hagi launch cleanup.
  
  Inspired by issue 19256.  This patch would also fix the crash.
........

Modified:
    trunk/   (props changed)
    trunk/res/res_agi.c

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

Modified: trunk/res/res_agi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_agi.c?view=diff&rev=321445&r1=321444&r2=321445
==============================================================================
--- trunk/res/res_agi.c (original)
+++ trunk/res/res_agi.c Fri May 27 19:29:48 2011
@@ -1461,21 +1461,21 @@
 	}
 	if (!(hp = ast_gethostbyname(host, &ahp))) {
 		ast_log(LOG_WARNING, "Unable to locate host '%s'\n", host);
-		return -1;
+		return AGI_RESULT_FAILURE;
 	}
 	if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
 		ast_log(LOG_WARNING, "Unable to create socket: %s\n", strerror(errno));
-		return -1;
+		return AGI_RESULT_FAILURE;
 	}
 	if ((flags = fcntl(s, F_GETFL)) < 0) {
 		ast_log(LOG_WARNING, "Fcntl(F_GETFL) failed: %s\n", strerror(errno));
 		close(s);
-		return -1;
+		return AGI_RESULT_FAILURE;
 	}
 	if (fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0) {
 		ast_log(LOG_WARNING, "Fnctl(F_SETFL) failed: %s\n", strerror(errno));
 		close(s);
-		return -1;
+		return AGI_RESULT_FAILURE;
 	}
 	memset(&addr_in, 0, sizeof(addr_in));
 	addr_in.sin_family = AF_INET;
@@ -1542,7 +1542,7 @@
 static enum agi_result launch_ha_netscript(char *agiurl, char *argv[], int *fds)
 {
 	char *host, *script;
-	enum agi_result result = AGI_RESULT_FAILURE;
+	enum agi_result result;
 	struct srv_context *context = NULL;
 	int srv_ret;
 	char service[256];
@@ -1576,16 +1576,20 @@
 		if (result == AGI_RESULT_FAILURE || result == AGI_RESULT_NOTFOUND) {
 			ast_log(LOG_WARNING, "AGI request failed for host '%s' (%s:%d)\n", host, srvhost, srvport);
 		} else {
-			break;
-		}
-	}
+			/* The script launched so we must cleanup the context. */
+			ast_srv_cleanup(&context);
+			return result;
+		}
+	}
+	/*
+	 * The DNS SRV lookup failed or we ran out of servers to check.
+	 * ast_srv_lookup() has already cleaned up the context for us.
+	 */
 	if (srv_ret < 0) {
 		ast_log(LOG_WARNING, "SRV lookup failed for %s\n", agiurl);
-	} else {
-        ast_srv_cleanup(&context);
-    }
-
-	return result;
+	}
+
+	return AGI_RESULT_FAILURE;
 }
 
 static enum agi_result launch_script(struct ast_channel *chan, char *script, char *argv[], int *fds, int *efd, int *opid)




More information about the asterisk-commits mailing list