[asterisk-commits] rmudgett: branch 1.8 r321436 - /branches/1.8/res/res_agi.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri May 27 19:27:56 CDT 2011
Author: rmudgett
Date: Fri May 27 19:27:52 2011
New Revision: 321436
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=321436
Log:
Some hagi launch cleanup.
Inspired by issue 19256. This patch would also fix the crash.
Modified:
branches/1.8/res/res_agi.c
Modified: branches/1.8/res/res_agi.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_agi.c?view=diff&rev=321436&r1=321435&r2=321436
==============================================================================
--- branches/1.8/res/res_agi.c (original)
+++ branches/1.8/res/res_agi.c Fri May 27 19:27:52 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